3636import java .util .ArrayList ;
3737import java .util .Collection ;
3838
39- import org .ejml .data .DenseMatrix64F ;
40- import org .ejml .factory .DecompositionFactory ;
41- import org .ejml .factory .LinearSolverFactory ;
39+ import org .ejml .data .DMatrixRMaj ;
40+ import org .ejml .dense . row . factory .DecompositionFactory_DDRM ;
41+ import org .ejml .dense . row . factory .LinearSolverFactory_DDRM ;
4242import org .ejml .interfaces .decomposition .EigenDecomposition ;
4343import org .ejml .interfaces .linsol .LinearSolver ;
44- import org .ejml .ops .CommonOps ;
44+ import org .ejml .interfaces .linsol .LinearSolverDense ;
45+ import org .ejml .dense .row .CommonOps_DDRM ;
4546
4647import fit .util .TransformUtil ;
4748import ij .ImageJ ;
@@ -213,26 +214,26 @@ public void fitFunction( final Collection< Point > points )
213214 // @author Peter Abeles (released under http://www.apache.org/licenses/LICENSE-2.0)
214215
215216 // qudratic part of design matrix
216- final DenseMatrix64F D1 = new DenseMatrix64F ( 3 , 1 );
217+ final DMatrixRMaj D1 = new DMatrixRMaj ( 3 , 1 );
217218 // linear part of design matrix
218- final DenseMatrix64F D2 = new DenseMatrix64F ( 3 , 1 );
219+ final DMatrixRMaj D2 = new DMatrixRMaj ( 3 , 1 );
219220
220221 // quadratic part of scatter matrix
221- final DenseMatrix64F S1 = new DenseMatrix64F ( 3 , 3 );
222+ final DMatrixRMaj S1 = new DMatrixRMaj ( 3 , 3 );
222223 // combined part of scatter matrix
223- final DenseMatrix64F S2 = new DenseMatrix64F ( 3 , 3 );
224+ final DMatrixRMaj S2 = new DMatrixRMaj ( 3 , 3 );
224225 // linear part of scatter matrix
225- final DenseMatrix64F S3 = new DenseMatrix64F ( 3 , 3 );
226+ final DMatrixRMaj S3 = new DMatrixRMaj ( 3 , 3 );
226227 // Reduced scatter matrix
227- final DenseMatrix64F M = new DenseMatrix64F ( 3 , 3 );
228+ final DMatrixRMaj M = new DMatrixRMaj ( 3 , 3 );
228229
229230 // storage for intermediate steps
230- final DenseMatrix64F T = new DenseMatrix64F ( 3 , 3 );
231- final DenseMatrix64F Ta1 = new DenseMatrix64F ( 3 , 1 );
232- final DenseMatrix64F S2_tran = new DenseMatrix64F ( 3 , 3 );
231+ final DMatrixRMaj T = new DMatrixRMaj ( 3 , 3 );
232+ final DMatrixRMaj Ta1 = new DMatrixRMaj ( 3 , 1 );
233+ final DMatrixRMaj S2_tran = new DMatrixRMaj ( 3 , 3 );
233234
234- final LinearSolver < DenseMatrix64F > solver = LinearSolverFactory .linear ( 3 );
235- final EigenDecomposition < DenseMatrix64F > eigen = DecompositionFactory .eig ( 3 , true , false );
235+ final LinearSolverDense < DMatrixRMaj > solver = LinearSolverFactory_DDRM .linear ( 3 );
236+ final EigenDecomposition < DMatrixRMaj > eigen = DecompositionFactory_DDRM .eig ( 3 , true , false );
236237
237238 final int N = points .size ();
238239
@@ -256,23 +257,23 @@ public void fitFunction( final Collection< Point > points )
256257 }
257258
258259 // Compute scatter matrix
259- CommonOps .multTransA ( D1 , D1 , S1 ); // S1 = D1'*D1
260- CommonOps .multTransA ( D1 , D2 , S2 ); // S2 = D1'*D2
261- CommonOps .multTransA ( D2 , D2 , S3 ); // S3 = D2'*D2
260+ CommonOps_DDRM .multTransA ( D1 , D1 , S1 ); // S1 = D1'*D1
261+ CommonOps_DDRM .multTransA ( D1 , D2 , S2 ); // S2 = D1'*D2
262+ CommonOps_DDRM .multTransA ( D2 , D2 , S3 ); // S3 = D2'*D2
262263
263264 // for getting a2 from a1
264265 // T = -inv(S3)*S2'
265266 if ( !solver .setA ( S3 ) )
266267 throw new IllDefinedDataPointsException ( "Could not fit ellipse, failed at T = -inv(S3)*S2'" );
267268
268- CommonOps .transpose ( S2 , S2_tran );
269- CommonOps .changeSign ( S2_tran );
269+ CommonOps_DDRM .transpose ( S2 , S2_tran );
270+ CommonOps_DDRM .changeSign ( S2_tran );
270271 solver .solve ( S2_tran , T );
271272
272273 // Compute reduced scatter matrix
273274 // M = S1 + S2*T
274- CommonOps .mult ( S2 , T , M );
275- CommonOps .add ( M , S1 , M );
275+ CommonOps_DDRM .mult ( S2 , T , M );
276+ CommonOps_DDRM .add ( M , S1 , M );
276277
277278 // Premultiply by inv(C1). inverse of constraint matrix
278279 for (int col = 0 ; col < 3 ; col ++)
@@ -289,12 +290,12 @@ public void fitFunction( final Collection< Point > points )
289290 if ( !eigen .decompose ( M ) )
290291 throw new IllDefinedDataPointsException ( "Could not fit ellipse, failed at eigen.decompose( M )" );
291292
292- final DenseMatrix64F a1 = selectBestEigenVector ( eigen );
293+ DMatrixRMaj a1 = selectBestEigenVector ( eigen );
293294 if ( a1 == null )
294295 throw new IllDefinedDataPointsException ( "Could not fit ellipse, could not find best eigenvector." );
295296
296297 // ellipse coefficients
297- CommonOps .mult ( T , a1 , Ta1 );
298+ CommonOps_DDRM .mult ( T , a1 , Ta1 );
298299
299300 this .a = a1 .data [ 0 ];
300301 this .b = a1 .data [ 1 ] / 2 ;
@@ -381,14 +382,14 @@ public void intersectsAt( final double[] p, final double[] i )
381382 }
382383 }
383384
384- protected DenseMatrix64F selectBestEigenVector ( final EigenDecomposition < DenseMatrix64F > eigen )
385+ protected DMatrixRMaj selectBestEigenVector ( final EigenDecomposition < DMatrixRMaj > eigen )
385386 {
386387 int bestIndex = -1 ;
387388 double bestCond = Double .MAX_VALUE ;
388389
389390 for (int i = 0 ; i < eigen .getNumberOfEigenvalues (); i ++)
390391 {
391- final DenseMatrix64F v = eigen .getEigenVector ( i );
392+ final DMatrixRMaj v = eigen .getEigenVector ( i );
392393
393394 if ( v == null ) // TODO WTF?!?!
394395 continue ;
0 commit comments