Unity: Unable to convert classes into dex format Plugins: Unity IAP 1.16 Facebook SDK 7.13.0 [duplicate] - unity3d
This question already has answers here:
Too many field references: 70613; max is 65536
(2 answers)
Closed 4 years ago.
got a problem with Facebook SDK. When i installed this i got error: Unable to convert classes into dex format.
There are installed plagins: Unity IAP 1.16, Facebook SDK 7.13.0, Google Play Service 0.9.50, Appodeal 2.8.45.
Unity 2017.1.2p3.
jdk1.8.0_181 and latest version of sdk tools
No same files or files with diffrent version there.
Here is the link for pastebin with error
CommandInvokationFailure: Unable to convert classes into dex format.
C:/Program Files/Java/jdk1.8.0_181\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Program Files (x86)/Android\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
trouble writing output: Too many field references to fit in one dex file: 86260; max is 65536.
You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.
References by package:
3 android.accounts
30 android.app
1 android.bluetooth
2 android.content
60 android.content.pm
10 android.content.res
3 android.database
49 android.graphics
2 android.graphics.drawable
4 android.hardware
2 android.media
1 android.media.browse
4 android.net
6 android.net.wifi
28 android.os
3 android.print
4 android.provider
13 android.support.annotation
1546 android.support.compat
1546 android.support.coreui
1546 android.support.coreutils
1648 android.support.customtabs
1546 android.support.fragment
1705 android.support.graphics.drawable
1546 android.support.graphics.drawable.animated
1546 android.support.mediacompat
1546 android.support.v4
13 android.support.v4.accessibilityservice
17 android.support.v4.animation
885 android.support.v4.app
114 android.support.v4.content
1 android.support.v4.content.pm
1 android.support.v4.content.res
11 android.support.v4.graphics
41 android.support.v4.graphics.drawable
4 android.support.v4.hardware.display
12 android.support.v4.hardware.fingerprint
10 android.support.v4.internal.view
388 android.support.v4.media
379 android.support.v4.media.session
10 android.support.v4.net
19 android.support.v4.os
63 android.support.v4.print
10 android.support.v4.provider
55 android.support.v4.text
6 android.support.v4.text.util
118 android.support.v4.util
434 android.support.v4.view
138 android.support.v4.view.accessibility
8 android.support.v4.view.animation
495 android.support.v4.widget
409 android.support.v7.app
1546 android.support.v7.appcompat
1546 android.support.v7.cardview
8 android.support.v7.content.res
18 android.support.v7.graphics.drawable
1 android.support.v7.text
2 android.support.v7.transition
77 android.support.v7.view
249 android.support.v7.view.menu
856 android.support.v7.widget
6 android.text
1 android.text.util
16 android.util
22 android.view
8 android.view.accessibility
3 android.webkit
23 android.widget
2 bitter.jnibridge
158 bolts
1540 com.CODvinn.GameOfWords
1540 com.adcolony.adcolonysdk
1270 com.adcolony.sdk
1616 com.amazon.device.ads
1560 com.android.vending.billing
4 com.applovin.sdk
1037 com.appodeal.ads
128 com.appodeal.ads.a
129 com.appodeal.ads.b
80 com.appodeal.ads.c
98 com.appodeal.ads.d
174 com.appodeal.ads.e
58 com.appodeal.ads.f
146 com.appodeal.ads.g
150 com.appodeal.ads.native_ad
107 com.appodeal.ads.native_ad.views
49 com.appodeal.ads.networks
68 com.appodeal.ads.networks.a
45 com.appodeal.ads.networks.vpaid
177 com.appodeal.ads.utils
19 com.appodeal.ads.utils.a
47 com.appodeal.ads.utils.b
4 com.appodeal.ads.utils.c
1540 com.appodeal.appodeal.unity
1540 com.appodeal.inmobi.unity
1540 com.appodeal.ogury.unity
1 com.appodeal.sdk
1540 com.appodeal.startapp.unity
37 com.appodeal.unity
1540 com.appodeal.yandexmetrica.unity
31 com.appodealx.applovin
28 com.appodealx.mraid
66 com.appodealx.sdk
17 com.appodealx.vast
2 com.chartboost.sdk.Libraries
180 com.evernote.android.job
5 com.evernote.android.job.gcm
10 com.evernote.android.job.util
16 com.evernote.android.job.util.support
16 com.evernote.android.job.v14
2 com.evernote.android.job.v19
12 com.evernote.android.job.v21
3 com.evernote.android.job.v24
2 com.evernote.android.job.v26
3 com.facebook.ads
1540 com.google.android.gms
20 com.google.android.gms.actions
4 com.google.android.gms.ads
21 com.google.android.gms.ads.identifier
1594 com.google.android.gms.auth
5 com.google.android.gms.auth.account
1563 com.google.android.gms.auth.api
68 com.google.android.gms.auth.api.accounttransfer
97 com.google.android.gms.auth.api.credentials
6 com.google.android.gms.auth.api.phone
1540 com.google.android.gms.auth.api.phone.license
37 com.google.android.gms.auth.api.proxy
59 com.google.android.gms.auth.api.signin
34 com.google.android.gms.auth.api.signin.internal
1540 com.google.android.gms.auth.license
1540 com.google.android.gms.base
1540 com.google.android.gms.base.license
102 com.google.android.gms.common
98 com.google.android.gms.common.api
338 com.google.android.gms.common.api.internal
41 com.google.android.gms.common.data
44 com.google.android.gms.common.images
160 com.google.android.gms.common.internal
1540 com.google.android.gms.common.license
35 com.google.android.gms.common.stats
27 com.google.android.gms.common.util
1688 com.google.android.gms.drive
54 com.google.android.gms.drive.events
1540 com.google.android.gms.drive.license
10 com.google.android.gms.drive.metadata
20 com.google.android.gms.drive.metadata.internal
39 com.google.android.gms.drive.query
49 com.google.android.gms.drive.query.internal
8 com.google.android.gms.drive.widget
25 com.google.android.gms.dynamic
20 com.google.android.gms.dynamite
2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
16 com.google.android.gms.flags.impl
1915 com.google.android.gms.games
25 com.google.android.gms.games.achievement
13 com.google.android.gms.games.event
155 com.google.android.gms.games.internal
128 com.google.android.gms.games.internal.api
12 com.google.android.gms.games.internal.experience
46 com.google.android.gms.games.internal.player
61 com.google.android.gms.games.leaderboard
1540 com.google.android.gms.games.license
61 com.google.android.gms.games.multiplayer
50 com.google.android.gms.games.multiplayer.realtime
49 com.google.android.gms.games.multiplayer.turnbased
56 com.google.android.gms.games.quest
34 com.google.android.gms.games.request
46 com.google.android.gms.games.snapshot
15 com.google.android.gms.games.stats
40 com.google.android.gms.games.video
3 com.google.android.gms.iid
1518 com.google.android.gms.internal
5 com.google.android.gms.location.places
1547 com.google.android.gms.nearby
72 com.google.android.gms.nearby.connection
1540 com.google.android.gms.nearby.license
95 com.google.android.gms.nearby.messages
2 com.google.android.gms.nearby.messages.audio
163 com.google.android.gms.nearby.messages.internal
6 com.google.android.gms.security
1588 com.google.android.gms.tasks
1540 com.google.android.gms.tasks.license
1540 com.google.example.games.mainlibproj
1581 com.google.games.bridge
15 com.inmobi.a
1076 com.inmobi.ads
70 com.inmobi.ads.cache
7 com.inmobi.commons.a
39 com.inmobi.commons.core.a
24 com.inmobi.commons.core.b
13 com.inmobi.commons.core.c
62 com.inmobi.commons.core.configs
10 com.inmobi.commons.core.d
43 com.inmobi.commons.core.e
12 com.inmobi.commons.core.f
66 com.inmobi.commons.core.network
29 com.inmobi.commons.core.utilities
6 com.inmobi.commons.core.utilities.a
37 com.inmobi.commons.core.utilities.b
10 com.inmobi.commons.core.utilities.uid
160 com.inmobi.rendering
53 com.inmobi.rendering.a
83 com.inmobi.rendering.mraid
29 com.inmobi.sdk
104 com.inmobi.signals
10 com.inmobi.signals.a
13 com.inmobi.signals.activityrecognition
14 com.inmobi.signals.b
53 com.integralads.avid.library.adcolony
2 com.integralads.avid.library.adcolony.activity
2 com.integralads.avid.library.adcolony.base
4 com.integralads.avid.library.adcolony.processing
5 com.integralads.avid.library.adcolony.registration
3 com.integralads.avid.library.adcolony.session
45 com.integralads.avid.library.adcolony.session.internal
19 com.integralads.avid.library.adcolony.session.internal.jsbridge
12 com.integralads.avid.library.adcolony.session.internal.trackingwebview
14 com.integralads.avid.library.adcolony.utils
26 com.integralads.avid.library.adcolony.video
14 com.integralads.avid.library.adcolony.walking
21 com.integralads.avid.library.adcolony.walking.async
1 com.integralads.avid.library.adcolony.weakreference
53 com.integralads.avid.library.inmobi
2 com.integralads.avid.library.inmobi.activity
2 com.integralads.avid.library.inmobi.base
4 com.integralads.avid.library.inmobi.processing
5 com.integralads.avid.library.inmobi.registration
3 com.integralads.avid.library.inmobi.session
45 com.integralads.avid.library.inmobi.session.internal
19 com.integralads.avid.library.inmobi.session.internal.jsbridge
12 com.integralads.avid.library.inmobi.session.internal.trackingwebview
14 com.integralads.avid.library.inmobi.utils
26 com.integralads.avid.library.inmobi.video
14 com.integralads.avid.library.inmobi.walking
21 com.integralads.avid.library.inmobi.walking.async
1 com.integralads.avid.library.inmobi.weakreference
2 com.ironsource.mediationsdk
218 com.moat.analytics.mobile.inm
2 com.moat.analytics.mobile.inm.a.b
1 com.mobvista.msdk
1 com.squareup.okhttp
345 com.squareup.picasso
6 com.startapp.a.a.a
4 com.startapp.a.a.b
32 com.startapp.a.a.c
7 com.startapp.a.a.d
5 com.startapp.a.a.e
3 com.startapp.a.a.f
13 com.startapp.a.a.g
3 com.startapp.android.publish
6 com.startapp.android.publish.a
45 com.startapp.android.publish.ads.a
9 com.startapp.android.publish.ads.b
55 com.startapp.android.publish.ads.banner
87 com.startapp.android.publish.ads.banner.banner3d
35 com.startapp.android.publish.ads.banner.bannerstandard
2 com.startapp.android.publish.ads.c.a
5 com.startapp.android.publish.ads.c.b
111 com.startapp.android.publish.ads.list3d
49 com.startapp.android.publish.ads.nativead
123 com.startapp.android.publish.ads.splash
146 com.startapp.android.publish.ads.video
12 com.startapp.android.publish.ads.video.a
31 com.startapp.android.publish.ads.video.b
48 com.startapp.android.publish.ads.video.tracking
338 com.startapp.android.publish.adsCommon
31 com.startapp.android.publish.adsCommon.Utils
25 com.startapp.android.publish.adsCommon.a
7 com.startapp.android.publish.adsCommon.activities
26 com.startapp.android.publish.adsCommon.adListeners
90 com.startapp.android.publish.adsCommon.adinformation
11 com.startapp.android.publish.adsCommon.b
8 com.startapp.android.publish.adsCommon.c
10 com.startapp.android.publish.adsCommon.d
48 com.startapp.android.publish.adsCommon.e
13 com.startapp.android.publish.adsCommon.f
11 com.startapp.android.publish.adsCommon.g
105 com.startapp.android.publish.cache
163 com.startapp.android.publish.common.metaData
121 com.startapp.android.publish.common.model
17 com.startapp.android.publish.html
40 com.startapp.android.publish.inappbrowser
42 com.startapp.common
54 com.startapp.common.a
3 com.startapp.common.b
3 com.startapp.common.c
1546 com.unity.purchasing
34 com.unity.purchasing.common
1724 com.unity.purchasing.googleplay
1 com.unity3d.ads
1 com.unity3d.ads2
203 com.unity3d.player
2 com.vungle.warren
212 com.yandex.metrica
455 com.yandex.metrica.impl
18 com.yandex.metrica.impl.interact
924 com.yandex.metrica.impl.ob
29 com.yandex.metrica.impl.utils
3 com.yandex.mobile.ads
364 for
21 for.do
26 for.do.byte
8 for.do.case
12 for.do.char
46 for.do.do
23 for.do.for
43 for.do.if
26 for.do.int
177 for.do.new
1 for.do.try
63 if.do.do
3 if.do.do.for
82 if.do.do.if
111 if.do.do.if.do
39 if.do.do.int
71 int
135 io.presage
47 io.presage.actions
8 io.presage.actions.do
6 io.presage.activities
24 io.presage.activities.do
12 io.presage.activities.handlers
73 io.presage.ads
10 io.presage.ads.controller
35 io.presage.byte
14 io.presage.case
76 io.presage.char
27 io.presage.char.do
26 io.presage.else
44 io.presage.else.do
16 io.presage.finder
56 io.presage.finder.model
14 io.presage.flatbuffers
7 io.presage.for
47 io.presage.formats
45 io.presage.formats.multiwebviews
13 io.presage.formats.multiwebviews.video
8 io.presage.goto
17 io.presage.helper
8 io.presage.if
2 io.presage.int
59 io.presage.long
22 io.presage.long.do
27 io.presage.model
15 io.presage.new
32 io.presage.provider
9 io.presage.receiver
35 io.presage.this
20 io.presage.try
2 java.io
15 java.lang
11 java.lang.annotation
5 java.net
2 java.nio
6 java.util
6 java.util.concurrent
5 java.util.logging
1 javax.xml.xpath
14 net.vrallev.android.cat
3 net.vrallev.android.cat.instance
1 org.apache.http.conn.ssl
20 org.fmod
1 org.json
8 org.nexage.sourcekit
239 org.nexage.sourcekit.mraid
14 org.nexage.sourcekit.mraid.internal
6 org.nexage.sourcekit.mraid.nativefeature
18 org.nexage.sourcekit.mraid.properties
36 org.nexage.sourcekit.util
40 org.nexage.sourcekit.vast
139 org.nexage.sourcekit.vast.activity
114 org.nexage.sourcekit.vast.model
6 org.nexage.sourcekit.vast.processor
22 org.nexage.sourcekit.vast.view
]
stdout[
processing archive C:\Users\ZaAz\Desktop\GameOfWords2017\GameOfWords2017\Temp\StagingArea\android-libraries\GoogleAIDL\libs\.\classes.jar...
processing com/android/vending/billing/BuildConfig.class...
processing com/android/vending/billing/IInAppBillingService.class...
processing com/android/vending/billing/IInAppBillingService$Stub.class...
processing com/android/vending/billing/IInAppBillingService$Stub$Proxy.class...
processing archive C:\Users\ZaAz\Desktop\GameOfWords2017\GameOfWords2017\Temp\StagingArea\android- libraries\GooglePlay\libs\.\classes.jar...
processing com/unity/purchasing/googleplay/ActivityLauncher.class...
processing com/unity/purchasing/googleplay/BillingServiceManager.class...
processing com/unity/purchasing/googleplay/BillingServiceManager$1.class...
processing com/unity/purchasing/googleplay/BillingServiceManager$1$1.class...
processing com/unity/purchasing/googleplay/BillingServiceManager$1$2.class...
processing com/unity/purchasing/googleplay/BillingServiceManager$2.class...
processing com/unity/purchasing/googleplay/BillingServiceProcessor.class...
processing com/unity/purchasing/googleplay/BuildConfig.class...
processing com/unity/purchasing/googleplay/Consts.class...
processing com/unity/purchasing/googleplay/Consts$PurchaseState.class...
processing com/unity/purchasing/googleplay/Consts$ResponseCode.class...
processing com/unity/purchasing/googleplay/GooglePlayBillingUnAvailableException.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$1.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$2.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$3.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$4.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$5.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$6.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$7.class...
processing com/unity/purchasing/googleplay/GooglePlayPurchasing$Features.class...
processing com/unity/purchasing/googleplay/IActivityLauncher.class...
processing com/unity/purchasing/googleplay/IBillingServiceManager.class...
processing com/unity/purchasing/googlep<message truncated>
I had the same problem a few days ago. This is your error:
Too many field references to fit in one dex file: 86260; max is 65536.
The plugins you are using all have their own dex files and the combined size, especially while using something like GooglePlayGames, can ramp up quickly.
You can bypass this by switching your build type in Build Settings from Internal to Gradle.
If you are still not able to build it correctly, you may want to consider removing some Plugins if you can. (I understand this is probably not your desired approach).
I ended up removing the GooglePlayGames Plugin, which was also slowing my build and app down.
Related
Change base of whole matrix
I want to change the base of a multiplication table to another base. If I use disp(dec2base((1:10).*(1:10)',7)) the numbers come flowing out individually. However I want them to stay in the exact position in the given matrix.
The numerical base is a display issue, numbers are always stored and manipulated in base 2 internally. So all you need to do is write a loop that displays the numbers in they way you want to. For example: for ii=1:10 for jj=1:10 fprintf('%6s',dec2base(ii*jj,7)); end fprintf('\n'); end Output: 1 2 3 4 5 6 10 11 12 13 2 4 6 11 13 15 20 22 24 26 3 6 12 15 21 24 30 33 36 42 4 11 15 22 26 33 40 44 51 55 5 13 21 26 34 42 50 55 63 101 6 15 24 33 42 51 60 66 105 114 10 20 30 40 50 60 100 110 120 130 11 22 33 44 55 66 110 121 132 143 12 24 36 51 63 105 120 132 144 156 13 26 42 55 101 114 130 143 156 202 Storing base-7 representation of numbers as string array: M = (1:10).*(1:10)'; out = strings(size(M)); for jj = 1:size(M,2) for ii = 1:size(M,1) out(ii,jj) = dec2base(M(ii,jj) ,7); end end
How to apply an "interface" method to a set of rows in kdb?
Sorry if this is a newbie question again. I am trying to replicate the functionality of interfaces as seen in c++, rust etc. in kdb as is shown in a simple demonstration below: q).iface.a.fun:{x*y+z} q).iface.b.fun:{x*x+y+z} q)ifaces:`a`b; // for demonstration purposes q)tab:([]time:`datetime$();kind:`ifaces$();x:`long$();y:`long$();z:`long$()); q)n:10; q)tab,:flip(n#.z.z;n?ifaces;n?10;n?10;n?10) Now you would assume that the kind would be able to reference the `a`b fun methods of the iface interface as follows: q)?[`tab;();0b;`max`ifaceval!((max;`x);(`.iface;`kind;`fun;`x;`y;`z))] evaluation error: fun [0] ?[`tab;();0b;`max`ifaceval!((max;`x);(`.iface;`kind;`fun;`x;`y;`z))] ^ Obviously the functional nature of the select inhibits referencing the fun method on account of the symbol type field declarations. You can avert this error by using enlist as follows: q)?[`tab;();0b;`max`ifaceval!((max;`x);(`.iface;`kind;enlist`fun;`x;`y;`z))] max ifaceval .. -----------------------------------------------------------------------------.. 9 77 154 95 65 0 128 153 126 60 49 77 154 95 65 0 128 153 126 60 49 77 154 .. However this duplicates the result of fun for each row. How might one effectively go about this without getting the above malformed responses? Thanks again.
Selecting ifaceval first will ensure each row is returned. max x is a scalar, which forces all the ifaceval entries into one row. The scalar will be expanded across all rows if a vector column precedes it. q)?[`tab;();0b;`ifaceval`max!((`.iface;`kind;enlist`fun;`x;`y;`z);(max;`x))] ifaceval max ------------------------------------- 160 11 126 28 32 60 76 10 112 168 8 96 10 77 24 16 35 60 6 63 104 8 96 10 77 24 16 35 60 6 63 104 8 96 10 77 24 16 35 60 6 63 104 8 96 10 77 24 16 35 60 6 63 104 8 160 11 126 28 32 60 76 10 112 168 8 96 10 77 24 16 35 60 6 63 104 8 160 11 126 28 32 60 76 10 112 168 8 160 11 126 28 32 60 76 10 112 168 8 160 11 126 28 32 60 76 10 112 168 8 I'm not sure if this is exactly what you're looking for though. If you want to calculate ifaceval for each row in the table, this should work. q)?[tab;();0b;`ifaceval`max!(((';(`.iface;::;enlist`fun));`kind;`x;`y;`z);(max;`x))] ifaceval max ------------ 160 8 10 8 77 8 24 8 16 8 60 8 60 8 10 8 112 8 168 8 One point to make is that it's probably best to avoid using kdb keywords for column names. Although it works in functional queries, it does not for qSQL ones. q)select max:max x from tab 'assign [0] select max:max x from tab ^
missing "for loop" - pdb distance calculation
I've found many posts to calculate distance between atoms, even I've written my own code for it. Now I want it to be in very less number of lines, I've written something like follows #!/usr/bin/perl -w #ARGV = <>; for ( $i = 0; $i <= $#ARGV; $i++ ) { #temp = split( /\s+/, $ARGV[$i] ); if ( $temp[0] eq "ATOM" and $temp[2] eq "CA" ) { ( $n1, $ax, $ay, $az ) = #temp[ 5, 6, 7, 8 ]; if ( $temp[0] eq "ATOM" and $temp[2] eq "CA" ) { ( $n2, $bx, $by, $bz ) = #temp[ 5, 6, 7, 8 ]; } $dista = sprintf( "%0.3f", sqrt( ( $ax - $bx )**2 + ( $ay - $by )**2 + ( $az - $bz )**2 ) ); print "$n1\t$n2\t$dista\n"; } } A sample input file is http://www.rcsb.org/pdb/files/5PTI.pdb. When I run the program it is not taking the next "CA" atom to calculate the distance, I want to calculate first "CA" to all other "CA" atoms and 2nd CA to all other CA's and so on. I know for loop is missing in my code, I tried to include that but something was going wrong. Where can I modify my code to get correct results.
In order to compare all distinct pairs of atoms you need to access the file data out of order, so it is best to read all of the relevant data into memory before doing the calculations. This program uses a while loop to read all of the CA ATOM numbers and positions into #data, and then calculates the distance between every different pair using a double nested for loop use strict; use warnings; my #data; while ( <> ) { my #fields = split; next unless $fields[0] eq 'ATOM' and $fields[2] eq 'CA'; push #data, [ #fields[5..8] ]; } for my $i (0 .. $#data-1) { my ($an, $ax, $ay, $az) = #{ $data[$i] }; for my $j ($i+1 .. $#data) { my ($bn, $bx, $by, $bz) = #{ $data[$j] }; my ($dx, $dy, $dz) = ($ax-$bx, $ay-$by, $az-$bz); my $dist = sqrt($dx*$dx + $dy*$dy + $dz*$dz); printf "%3d %3d %6.3f\n", $an, $bn, $dist; } } output 1 2 3.772 1 3 6.357 1 4 8.230 1 5 6.883 1 6 8.835 1 7 11.836 1 8 14.819 1 9 16.272 1 10 18.781 1 11 22.069 1 12 23.577 1 13 27.304 1 14 28.550 1 15 30.435 1 16 29.411 1 17 27.994 1 18 25.290 1 19 23.197 1 20 19.549 1 21 16.377 1 22 13.683 1 23 10.803 1 24 12.584 1 25 10.300 1 26 13.713 1 27 14.787 1 28 11.633 1 29 13.140 1 30 13.576 1 31 16.899 1 32 19.413 1 33 20.494 1 34 23.292 1 35 22.504 1 36 25.633 1 37 25.598 1 38 24.936 1 39 22.477 1 40 19.299 1 41 16.005 1 42 12.638 1 43 11.659 1 44 14.746 1 45 15.146 1 46 18.399 1 47 17.588 1 48 15.860 1 49 15.021 1 50 13.194 1 51 11.300 1 52 10.500 1 53 9.874 1 54 7.246 1 55 5.502 1 56 7.255 1 57 8.869 1 58 12.364 2 3 3.712 2 4 5.264 2 5 5.705 2 6 7.882 2 7 9.931 2 8 13.310 2 9 14.660 2 10 16.571 2 11 19.974 2 12 20.988 2 13 24.611 2 14 26.005 2 15 28.222 2 16 27.436 2 17 26.450 2 18 23.863 2 19 22.267 2 20 18.602 2 21 15.926 2 22 13.079 2 23 10.991 2 24 13.023 2 25 11.272 2 26 14.827 2 27 16.369 2 28 13.696 2 29 14.802 2 30 14.428 2 31 17.305 2 32 19.214 2 33 19.670 2 34 22.010 2 35 20.704 2 36 23.494 2 37 23.285 2 38 22.198 2 39 19.454 2 40 16.542 2 41 13.059 2 42 9.817 2 43 9.717 2 44 13.047 2 45 14.062 2 46 17.571 2 47 17.545 2 48 16.496 2 49 16.013 2 50 13.461 2 51 11.599 2 52 12.013 2 53 11.355 2 54 7.839 2 55 6.843 2 56 9.812 2 57 12.211 2 58 15.658 3 4 3.765 3 5 5.298 3 6 5.675 3 7 7.436 3 8 11.137 3 9 13.211 3 10 14.962 3 11 18.642 3 12 19.458 3 13 22.991 3 14 24.871 3 15 27.175 3 16 26.862 3 17 25.995 3 18 23.864 3 19 22.429 3 20 18.984 3 21 16.478 3 22 13.154 3 23 11.180 3 24 12.363 3 25 10.420 3 26 13.564 3 27 15.868 3 28 13.932 3 29 15.417 3 30 15.143 3 31 17.475 3 32 19.250 3 33 19.132 3 34 21.369 3 35 20.109 3 36 22.662 3 37 22.879 3 38 21.582 3 39 18.587 3 40 15.998 3 41 12.239 3 42 9.840 3 43 9.607 3 44 13.335 3 45 15.232 3 46 18.951 3 47 19.301 3 48 18.221 3 49 18.412 3 50 15.954 3 51 13.507 3 52 14.244 3 53 14.343 3 54 10.830 3 55 9.041 3 56 11.810 3 57 14.209 3 58 17.229 4 5 3.820 4 6 5.318 4 7 5.362 4 8 8.786 4 9 10.091 4 10 11.574 4 11 15.140 4 12 15.971 4 13 19.569 4 14 21.246 4 15 23.537 4 16 23.146 4 17 22.377 4 18 20.242 4 19 19.031 4 20 15.631 4 21 13.511 4 22 10.308 4 23 9.277 4 24 10.980 4 25 10.254 4 26 13.570 4 27 15.521 4 28 13.857 4 29 14.475 4 30 13.337 4 31 15.229 4 32 16.434 4 33 16.013 4 34 17.953 4 35 16.460 4 36 18.973 4 37 19.118 4 38 17.898 4 39 15.038 4 40 12.292 4 41 8.585 4 42 6.257 4 43 6.086 4 44 9.793 4 45 12.070 4 46 15.828 4 47 16.653 4 48 16.036 4 49 16.682 4 50 13.996 4 51 11.475 4 52 13.125 4 53 13.565 4 54 9.951 4 55 8.588 4 56 11.858 4 57 14.982 4 58 17.912 5 6 3.786 5 7 5.549 5 8 8.148 5 9 9.417 5 10 12.003 5 11 15.345 5 12 17.034 5 13 20.795 5 14 22.183 5 15 23.943 5 16 23.209 5 17 21.821 5 18 19.548 5 19 17.663 5 20 14.226 5 21 11.392 5 22 8.020 5 23 5.923 5 24 7.697 5 25 6.909 5 26 10.530 5 27 12.000 5 28 10.100 5 29 10.716 5 30 9.947 5 31 12.216 5 32 14.072 5 33 14.342 5 34 16.948 5 35 16.188 5 36 19.251 5 37 19.710 5 38 19.200 5 39 16.885 5 40 13.668 5 41 10.418 5 42 7.851 5 43 5.721 5 44 9.267 5 45 10.954 5 46 14.616 5 47 14.695 5 48 13.357 5 49 14.154 5 50 12.112 5 51 9.007 5 52 10.078 5 53 11.232 5 54 8.148 5 55 5.688 5 56 8.503 5 57 11.702 5 58 14.362 6 7 3.831 6 8 6.572 6 9 9.275 6 10 11.961 6 11 15.547 6 12 17.196 6 13 20.827 6 14 22.748 6 15 24.452 6 16 24.212 6 17 22.799 6 18 21.078 6 19 19.207 6 20 16.153 6 21 13.423 6 22 9.721 6 23 7.486 6 24 7.340 6 25 5.698 6 26 8.505 6 27 11.057 6 28 10.121 6 29 11.598 6 30 11.538 6 31 13.190 6 32 15.162 6 33 14.966 6 34 17.633 6 35 17.217 6 36 20.067 6 37 21.104 6 38 20.504 6 39 18.040 6 40 15.210 6 41 11.855 6 42 10.280 6 43 8.110 6 44 11.650 6 45 13.922 6 46 17.544 6 47 17.700 6 48 16.106 6 49 17.323 6 50 15.639 6 51 12.259 6 52 13.014 6 53 14.602 6 54 11.760 6 55 8.788 6 56 10.724 6 57 13.305 6 58 15.397 7 8 3.788 7 9 6.501 7 10 8.500 7 11 12.241 7 12 13.561 7 13 17.118 7 14 19.243 7 15 21.116 7 16 21.202 7 17 20.145 7 18 18.765 7 19 17.426 7 20 14.643 7 21 12.683 7 22 9.085 7 23 8.406 7 24 8.404 7 25 8.354 7 26 10.628 7 27 13.077 7 28 12.781 7 29 13.456 7 30 12.474 7 31 13.236 7 32 14.271 7 33 13.178 7 34 15.234 7 35 14.441 7 36 16.903 7 37 18.077 7 38 17.268 7 39 14.740 7 40 12.239 7 41 9.000 7 42 8.569 7 43 6.762 7 44 10.022 7 45 13.081 7 46 16.670 7 47 17.588 7 48 16.646 7 49 18.349 7 50 16.355 7 51 13.074 7 52 14.771 7 53 16.437 7 54 13.415 7 55 11.103 7 56 13.508 7 57 16.519 7 58 18.574 8 9 3.829 8 10 6.391 8 11 9.730 8 12 11.714 8 13 15.183 8 14 17.246 8 15 18.615 8 16 18.817 8 17 17.467 8 18 16.564 8 19 15.151 8 20 12.958 8 21 11.376 8 22 8.076 8 23 8.330 8 24 7.464 8 25 8.810 8 26 10.170 8 27 12.231 8 28 12.876 8 29 12.969 8 30 11.707 8 31 11.373 8 32 11.921 8 33 10.304 8 34 12.345 8 35 12.170 8 36 14.656 8 37 16.484 8 38 16.239 8 39 14.329 8 40 11.939 8 41 9.623 8 42 10.141 8 43 7.644 8 44 9.770 8 45 12.967 8 46 16.144 8 47 17.164 8 48 16.234 8 49 18.629 8 50 17.098 8 51 13.644 8 52 15.542 8 53 17.852 8 54 15.331 8 55 12.977 8 56 14.899 8 57 17.929 8 58 19.411 9 10 3.796 9 11 6.560 9 12 9.191 9 13 12.815 9 14 14.244 9 15 15.405 9 16 15.226 9 17 13.799 9 18 12.745 9 19 11.505 9 20 9.462 9 21 8.624 9 22 6.111 9 23 8.130 9 24 8.288 9 25 10.836 9 26 12.463 9 27 13.537 9 28 14.017 9 29 13.030 9 30 10.756 9 31 9.762 9 32 9.230 9 33 7.106 9 34 8.767 9 35 8.406 9 36 11.173 9 37 12.963 9 38 13.196 9 39 11.907 9 40 9.274 9 41 7.975 9 42 9.009 9 43 6.426 9 44 7.058 9 45 10.329 9 46 13.110 9 47 14.574 9 48 14.241 9 49 16.984 9 50 15.450 9 51 12.315 9 52 14.872 9 53 17.243 9 54 15.016 9 55 13.356 9 56 15.411 9 57 18.781 9 58 20.275 10 11 3.828 10 12 5.496 10 13 9.172 10 14 10.923 10 15 12.620 10 16 12.993 10 17 12.458 10 18 11.905 10 19 11.855 10 20 10.354 10 21 10.795 10 22 9.077 10 23 11.601 10 24 12.078 10 25 14.440 10 26 16.059 10 27 17.305 10 28 17.774 10 29 16.703 10 30 14.136 10 31 12.928 10 32 11.515 10 33 8.580 10 34 8.535 10 35 6.945 10 36 8.611 10 37 10.409 10 38 10.097 10 39 8.733 10 40 6.955 10 41 6.570 10 42 9.147 10 43 8.045 10 44 7.942 10 45 11.516 10 46 13.970 10 47 16.239 10 48 16.684 10 49 19.362 10 50 17.428 10 51 14.794 10 52 17.795 10 53 19.775 10 54 17.311 10 55 16.195 10 56 18.651 10 57 22.165 10 58 23.882 11 12 3.829 11 13 6.896 11 14 7.832 11 15 8.935 11 16 9.358 11 17 8.968 11 18 9.167 11 19 9.914 11 20 9.600 11 21 11.270 11 22 10.756 11 23 13.943 11 24 14.437 11 25 17.339 11 26 18.680 11 27 19.414 11 28 20.142 11 29 18.516 11 30 15.604 11 31 13.656 11 32 11.238 11 33 7.743 11 34 6.051 11 35 4.259 11 36 5.107 11 37 7.753 11 38 8.381 11 39 8.497 11 40 7.487 11 41 8.904 11 42 11.750 11 43 10.782 11 44 9.363 11 45 12.346 11 46 13.858 11 47 16.459 11 48 17.387 11 49 20.381 11 50 18.730 11 51 16.466 11 52 19.658 11 53 21.770 11 54 19.716 11 55 18.921 11 56 21.179 11 57 24.715 11 58 26.195 12 13 3.798 12 14 5.872 12 15 8.412 12 16 9.787 12 17 10.835 12 18 11.309 12 19 12.940 12 20 12.564 12 21 14.413 12 22 13.731 12 23 16.751 12 24 17.446 12 25 19.934 12 26 21.458 12 27 22.598 12 28 23.145 12 29 21.769 12 30 18.861 12 31 17.257 12 32 14.923 12 33 11.528 12 34 9.487 12 35 6.828 12 36 5.623 12 37 7.368 12 38 6.441 12 39 6.083 12 40 6.825 12 41 8.668 12 42 12.254 12 43 12.427 12 44 11.299 12 45 14.440 12 46 16.010 12 47 19.024 12 48 20.323 12 49 23.002 12 50 20.893 12 51 18.915 12 52 22.282 12 53 23.962 12 54 21.538 12 55 21.023 12 56 23.674 12 57 27.301 12 58 29.102 13 14 3.879 13 15 6.705 13 16 9.300 13 17 11.362 13 18 12.772 13 19 15.105 13 20 15.435 13 21 17.730 13 22 17.366 13 23 20.477 13 24 21.031 13 25 23.571 13 26 24.880 13 27 26.028 13 28 26.780 13 29 25.340 13 30 22.400 13 31 20.523 13 32 17.874 13 33 14.332 13 34 11.618 13 35 9.221 13 36 6.442 13 37 8.090 13 38 7.079 13 39 7.719 13 40 9.752 13 41 12.037 13 42 15.744 13 43 16.183 13 44 14.857 13 45 17.760 13 46 18.893 13 47 22.081 13 48 23.627 13 49 26.366 13 50 24.297 13 51 22.512 13 52 25.936 13 53 27.588 13 54 25.210 13 55 24.803 13 56 27.451 13 57 31.078 13 58 32.820 14 15 3.805 14 16 5.952 14 17 8.843 14 18 10.375 14 19 13.401 14 20 14.307 14 21 17.253 14 22 17.705 14 23 21.206 14 24 22.143 14 25 25.041 14 26 26.510 14 27 27.150 14 28 27.737 14 29 25.808 14 30 22.545 14 31 20.510 14 32 17.400 14 33 14.104 14 34 10.779 14 35 8.226 14 36 4.525 14 37 5.440 14 38 5.667 14 39 8.155 14 40 10.012 14 41 13.178 14 42 16.588 14 43 17.017 14 44 14.871 14 45 17.120 14 46 17.488 14 47 20.842 14 48 22.838 14 49 25.579 14 50 23.675 14 51 22.349 14 52 25.908 14 53 27.494 14 54 25.489 14 55 25.493 14 56 28.046 14 57 31.725 14 58 33.414 15 16 3.763 15 17 6.550 15 18 9.298 15 19 12.391 ...etc.
I would do it in this way use strict; use warnings; sub get_ca_atom { my #result = split; return $result[0] eq 'ATOM' && $result[2] eq 'CA' && #result > 8 ? [ #result[ 5 .. 8 ] ] : (); } my #atoms = map get_ca_atom, <>; while (#atoms) { my $a = shift #atoms; for my $b (#atoms) { my $dist = sqrt( ( $$a[1] - $$b[1] )**2 + ( $$a[2] - $$b[2] )**2 + ( $$a[3] - $$b[3] )**2 ); printf "%s\t%s\t%0.3f\n", $$a[0], $$b[0], $dist; } } But in reality I would like to separate handling with the atom internals from the main algorithm to be clear and communicate an intention of the code as good as possible. There is nothing worse than dealing your own code after few months when written without keeping this in mind. use strict; use warnings; # handle CA ATOM record use constant { ATOM_TAG => 0, ATOM_TYPE => 2 }; use constant ATOM_SPLICE => ( 5 .. 8 ); use constant { NAME => 0, X => 1, Y => 2, Z => 3 }; sub get_ca_atom { my #result = split; return $result[ATOM_TAG] eq 'ATOM' && $result[ATOM_TYPE] eq 'CA' && #result > (ATOM_SPLICE)[-1] ? [ #result[ATOM_SPLICE] ] : (); } sub get_name { shift->[NAME] } sub distance { my ( $a, $b ) = #_; sqrt( ( $$a[X] - $$b[X] )**2 + ( $$a[Y] - $$b[Y] )**2 + ( $$a[Z] - $$b[Z] )**2 ); } # end of handle CA ATOM record my #atoms = map get_ca_atom, <>; while (#atoms) { my $a = shift #atoms; for my $b (#atoms) { my $dist = distance( $a, $b ); printf "%s\t%s\t%0.3f\n", get_name($a), get_name($b), $dist; } } Then you can play with the main algorithm as you wish. For example above code reads all file content into memory which should not be a problem in the real task most time. But if you wish to keep only CA ATOMS just change the line with map to the following. my #atoms; while (<>) { my $atom = get_ca_atom; push #atoms, $atom if $atom; } As you can see, intention of the code is slowly missing with more lines but it can be opposite sometimes. The main objection to code is communicating intention even it would mean more lines of code. Especially you should not mix the low level with the high level which was the reason why I separated distance and get_name in the second code example. If you prefer to process atoms in order as they go, you can use following code, but notice you will not save memory because you need #atoms stored anyway for calculating distance. my #atoms; while (<>) { my $atom = get_ca_atom; next unless $atom; for my $a (#atoms) { my $dist = distance( $atom, $a ); printf "%s\t%s\t%0.3f\n", get_name($a), get_name($atom), $dist; } push #atoms, $atom; } Note output comes in a different order. And also note I used next unless $atom; instead of using if ($atom) { and enclosing rest of the loop in block. The reason is I want to emphasize: Just skip it if it's not what you expect. If you would like to surprise yourself with the third different order of output you can replace push with unshift.
Extracting a submatrix that contains some sub-columns from A
20 4 4 74 20 20 74 85 85 85 2 1 A = 36 1 1 11 36 36 11 66 66 66 4 1 77 1 1 15 77 77 15 11 11 11 1 4 3 4 2 6 7 8 10 10 15 17 1 5 20 4 85 B = 36 1 66 77 1 11 How from the matrix A, I can extract the submatrix whose coloumns contains the vectors B(:,i): [20 36 77] , [4 1 1] and [85 66 11]? The desired result: 20 4 4 20 20 85 85 85 36 1 1 36 36 66 66 66 77 1 1 77 77 11 11 11 3 4 2 7 8 10 15 17
Now that you've explained what you want, transpose the matrices, select only the three top rows of A, and then use the third argument of ismember to specify that you want to compare entire rows: A(:,ismember(A(1:3,:).', B.', 'rows').') 20 4 4 20 20 85 85 85 36 1 1 36 36 66 66 66 77 1 1 77 77 11 11 11 3 4 2 7 8 10 15 17
Comparing area between two matrices with multiple points of intersection (MATLAB)
I have two matrices that contain the points for the top boundaries of two jigsaw puzzles. I am trying to calculate the area contained between these two matrices (of unequal rows). They have multiple points of intersection. The picture below gives a better idea of what I'm trying to accomplish. The output should be a numerical value (of the total area highlighted in blue). If this is too difficult to achieve, is there a better way to compare matrices to see which ones "fit" the best? Un-Highlighted Picture Area(in blue) that I am trying to calculate (numerical value) The matrix values are below if it helps: Matrix 1: 1 1 2 2 3 2 4 2 5 2 6 3 7 3 8 3 9 3 10 3 11 3 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 3 73 3 74 3 75 4 76 5 77 6 78 7 79 8 79 9 80 10 80 11 80 12 80 13 80 14 80 15 79 16 79 17 79 18 78 19 78 20 78 21 77 22 77 23 77 24 76 25 76 26 76 27 75 28 75 29 75 30 74 31 74 32 74 33 73 34 73 35 73 36 73 37 73 38 72 39 72 40 72 41 72 42 72 43 72 44 73 45 73 46 73 47 74 48 75 49 76 50 77 51 78 52 79 53 80 53 81 54 82 54 83 55 84 55 85 56 86 56 87 57 88 57 89 57 90 58 91 58 92 58 93 58 94 59 95 59 96 59 97 59 98 59 99 59 100 59 101 59 102 59 103 59 104 59 105 59 106 59 107 59 108 59 109 59 110 59 111 59 112 58 113 58 114 58 115 58 116 57 117 57 118 57 119 56 120 56 121 56 122 55 123 55 124 54 125 53 126 53 127 52 128 51 129 51 130 50 131 49 132 48 132 47 133 46 133 45 133 44 133 43 133 42 133 41 133 40 133 39 133 38 132 37 132 36 132 35 131 34 131 33 131 32 131 31 130 30 130 29 130 28 130 27 129 26 129 25 128 24 128 23 127 22 127 21 127 20 127 19 126 18 126 17 126 16 126 15 126 14 126 13 126 12 126 11 126 10 126 9 127 8 128 7 129 6 130 5 131 4 132 3 133 3 134 2 135 2 136 2 137 2 138 2 139 2 140 2 141 2 142 2 143 2 144 2 145 2 146 2 147 2 148 2 149 2 150 2 151 2 152 2 153 2 154 2 155 2 156 2 157 2 158 2 159 2 160 2 161 2 162 2 163 2 164 2 165 2 166 2 167 2 168 1 169 1 170 1 171 1 172 1 Matrix 2: 173 3 172 3 171 3 170 2 169 2 168 2 167 2 166 2 165 2 164 2 163 2 162 2 161 2 160 2 159 2 158 2 157 2 156 2 155 2 154 2 153 2 152 2 151 2 150 2 149 2 148 2 147 2 146 2 145 2 144 2 143 2 142 2 141 2 140 2 139 2 138 2 137 2 136 2 135 3 134 3 133 3 132 3 131 4 130 4 129 4 128 5 127 6 127 7 127 8 126 9 127 10 127 11 127 12 127 13 127 14 126 15 127 16 127 17 127 18 127 19 127 20 127 21 128 22 128 23 128 24 128 25 129 26 129 27 129 28 130 29 130 30 130 31 131 32 131 33 131 34 132 35 132 36 132 37 132 38 133 39 133 40 133 41 133 42 133 43 132 44 132 45 132 46 131 47 130 48 129 49 128 50 127 51 126 52 125 53 124 54 123 54 122 55 121 55 120 55 119 56 118 56 117 57 116 58 115 58 114 59 113 59 112 59 111 59 110 60 109 60 108 60 107 60 106 60 105 60 104 60 103 60 102 60 101 60 100 60 99 60 98 60 97 60 96 60 95 59 94 59 93 59 92 59 91 59 90 58 89 58 88 57 87 57 86 56 85 56 84 55 83 55 82 54 81 54 80 53 79 52 78 51 77 50 76 49 75 48 74 47 73 46 73 45 73 44 73 43 73 42 73 41 73 40 73 39 73 38 73 37 73 36 74 35 74 34 74 33 75 32 75 31 75 30 76 29 76 28 76 27 77 26 77 25 77 24 78 23 78 22 78 21 79 20 79 19 80 18 80 17 80 16 81 15 81 14 81 13 81 12 81 11 81 10 80 10 79 9 79 8 78 7 77 6 76 5 75 4 74 4 73 3 72 3 71 2 70 2 69 2 68 1 67 2 66 2 65 2 64 2 63 2 62 2 61 2 60 2 59 2 58 2 57 2 56 2 55 2 54 2 53 2 52 2 51 2 50 2 49 2 48 2 47 2 46 2 45 2 44 2 43 2 42 2 41 2 40 2 39 2 38 2 37 2 36 2 35 2 34 2 33 2 32 2 31 2 30 2 29 2 28 2 27 2 26 2 25 2 24 2 23 2 22 2 21 2 20 2 19 2 18 2 17 2 16 2 15 2 14 2 13 2 12 2 11 2 10 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 3
Mark everything above one curve and mark everything below the other curve. Then you can get the area between the curves by finding where there are two marks. You should take a look at this question Similarity measures between curves?