@ Override public void associate ( FastQueue < D > src , FastQueue < D > dst ) { fitQuality . reset ( ) ; pairs . reset ( ) ; workBuffer . reset ( ) ; pairs . resize ( src . size ) ; fitQuality . resize ( src . size ) ; workBuffer . resize ( src . size * dst . size ) ; //CONCURRENT_BELOW BoofConcurrency.loopFor(0, src.size, i -> { for ( int i = 0 ; i < src . size ; i ++ ) { D a = src . data [ i ] ; double bestScore = maxFitError ; int bestIndex = - 1 ; int workIdx = i * dst . size ; for ( int j = 0 ; j < dst . size ; j ++ ) { D b = dst . data [ j ] ; double fit = score . score ( a , b ) ; workBuffer . set ( workIdx + j , fit ) ; if ( fit <= bestScore ) { bestIndex = j ; bestScore = fit ; } } pairs . set ( i , bestIndex ) ; fitQuality . set ( i , bestScore ) ; } //CONCURRENT_ABOVE }); if ( backwardsValidation ) { //CONCURRENT_BELOW BoofConcurrency.loopFor(0, src.size, i -> { for ( int i = 0 ; i < src . size ; i ++ ) { int match = pairs . data [ i ] ; if ( match == - 1 ) //CONCURRENT_BELOW return; continue ; double scoreToBeat = workBuffer . data [ i * dst . size + match ] ; for ( int j = 0 ; j < src . size ; j ++ , match += dst . size ) { if ( workBuffer . data [ match ] <= scoreToBeat && j != i ) { pairs . data [ i ] = - 1 ; fitQuality . data [ i ] = Double . MAX_VALUE ; break ; } } } //CONCURRENT_ABOVE }); } }
Associates the two sets objects against each other by minimizing fit score .