/** * Returns the number of elements in this matrix, which is equal to * the number of rows times the number of columns. * * @return The number of elements in the matrix. */ public int getNumElements() { return mat.getNumElements(); }
/** * Returns the number of elements in this matrix, which is equal to * the number of rows times the number of columns. * * @return The number of elements in the matrix. */ public int getNumElements() { return mat.getNumElements(); }
/** * Returns the number of elements in this matrix, which is equal to * the number of rows times the number of columns. * * @return The number of elements in the matrix. */ public int getNumElements() { return mat.getNumElements(); }
/** * Creates a new matrix which is equivalent to the provided matrix. Note that * the length of the data will be determined by the shape of the matrix. * * @param orig The matrix which is to be copied. This is not modified or saved. */ public DenseMatrix64F( DenseMatrix64F orig ) { this(orig.numRows,orig.numCols); System.arraycopy(orig.data, 0, this.data, 0, orig.getNumElements()); }
public static void copyVectorIntoArray( DenseMatrix64F vec, double[] array ) { System.arraycopy( vec.data, 0, array, 0, vec.getNumElements() ); }
/** * Creates a new matrix which is equivalent to the provided matrix. Note that * the length of the data will be determined by the shape of the matrix. * * @param orig The matrix which is to be copied. This is not modified or saved. */ public DenseMatrix64F( DenseMatrix64F orig ) { this(orig.numRows,orig.numCols); System.arraycopy(orig.data, 0, this.data, 0, orig.getNumElements()); }
/** * @inheritDoc */ @Override public void reshape(int numRows, int numCols, boolean saveValues) { if( data.length < numRows * numCols ) { double []d = new double[ numRows*numCols ]; if( saveValues ) { System.arraycopy(data,0,d,0,getNumElements()); } this.data = d; } this.numRows = numRows; this.numCols = numCols; }
/** * @inheritDoc */ @Override public void reshape(int numRows, int numCols, boolean saveValues) { if( data.length < numRows * numCols ) { double []d = new double[ numRows*numCols ]; if( saveValues ) { System.arraycopy(data,0,d,0,getNumElements()); } this.data = d; } this.numRows = numRows; this.numCols = numCols; }
@Override public void process() { DenseMatrix64F a = ((VariableMatrix)A).matrix; output.matrix.reshape(a.numRows,a.numCols); int N = a.getNumElements(); for (int i = 0; i < N; i++) { output.matrix.data[i] = Math.abs(a.data[i]); } } };
public void update(DenseMatrix64F value) { for(int i = 0; i < value.getNumElements(); i++) { update(value.get(i)); } } }
public void update(DenseMatrix64F value) { for(int i = 0; i < value.getNumElements(); i++) { update(value.get(i)); } } }
/** * Normalizes the matrix such that the Frobenius norm is equal to one. * * @param A The matrix that is to be normalized. */ public static void normalizeF( DenseMatrix64F A ) { double val = normF(A); if( val == 0 ) return; int size = A.getNumElements(); for( int i = 0; i < size; i++) { A.div(i , val); } }
/** * Normalizes the matrix such that the Frobenius norm is equal to one. * * @param A The matrix that is to be normalized. */ public static void normalizeF( DenseMatrix64F A ) { double val = normF(A); if( val == 0 ) return; int size = A.getNumElements(); for( int i = 0; i < size; i++) { A.div(i , val); } }
/** * Normalizes the matrix such that the Frobenius norm is equal to one. * * @param A The matrix that is to be normalized. */ public static void normalizeF( DenseMatrix64F A ) { double val = normF(A); if( val == 0 ) return; int size = A.getNumElements(); for( int i = 0; i < size; i++) { A.div(i , val); } }
/** * Extracts the row from a matrix. * @param a Input matrix * @param row Which row is to be extracted * @param out output. Storage for the extracted row. If null then a new vector will be returned. * @return The extracted row. */ public static DenseMatrix64F extractRow( DenseMatrix64F a , int row , DenseMatrix64F out ) { if( out == null) out = new DenseMatrix64F(1,a.numCols); else if( !MatrixFeatures.isVector(out) || out.getNumElements() != a.numCols ) throw new IllegalArgumentException("Output must be a vector of length "+a.numCols); System.arraycopy(a.data,a.getIndex(row,0),out.data,0,a.numCols); return out; }
public static void inv( DenseMatrix64F mat , DenseMatrix64F inv ) { double max = Math.abs(mat.data[0]); int N = mat.getNumElements(); for( int i = 1; i < N; i++ ) { double a = Math.abs(mat.data[i]); if( a > max ) max = a; } switch( mat.numRows ) { case 2: inv2(mat,inv,1.0/max); break; case 3: inv3(mat,inv,1.0/max); break; case 4: inv4(mat,inv,1.0/max); break; case 5: inv5(mat,inv,1.0/max); break; default: throw new IllegalArgumentException("Not supported"); } }
public static void inv( DenseMatrix64F mat , DenseMatrix64F inv ) { double max = Math.abs(mat.data[0]); int N = mat.getNumElements(); for( int i = 1; i < N; i++ ) { double a = Math.abs(mat.data[i]); if( a > max ) max = a; } switch( mat.numRows ) { case 2: inv2(mat,inv,1.0/max); break; case 3: inv3(mat,inv,1.0/max); break; case 4: inv4(mat,inv,1.0/max); break; case 5: inv5(mat,inv,1.0/max); break; default: throw new IllegalArgumentException("Not supported"); } }
/** * Computes the inner product of a, assuming a is an upper diagonal matrix */ public static void matrixEquals(DenseMatrix64F expected, DenseMatrix64F actual, double epsilon) { for (int i = 0; i < expected.getNumElements(); i++) assertEquals(expected.get(i), actual.get(i), epsilon); }
@Override protected void updateAPosterioriState(DenseMatrix64F x, DenseMatrix64F y, DenseMatrix64F K) { DenseMatrix64F residual = measurementModel.computeResidual(); //int outputMatrixSize = measurementModel.getOutputMatrixSize(); if (K.getNumElements() != 0) { MatrixVectorMult.mult(K, residual, correction); processModel.correctState(correction); } runPostStateChangeRunnables(); } }
public void updateIntermediateVariables() { if (articulatedBodyRecursionStep.isRoot()) return; if (isUpToDate) return; CommonOps.multTransB(articulatedBodyRecursionStep.U_Dinv, articulatedBodyRecursionStep.S, U_Dinv_ST); for (int index = 0; index < U_Dinv_ST.getNumElements(); index++) one_minus_U_Dinv_ST.set(index, -U_Dinv_ST.get(index)); for (int diagIndex = 0; diagIndex < SpatialVectorReadOnly.SIZE; diagIndex++) one_minus_U_Dinv_ST.add(diagIndex, diagIndex, 1.0); CommonOps.multTransB(articulatedBodyRecursionStep.Dinv, articulatedBodyRecursionStep.U, Dinv_UT); CommonOps.multTransB(articulatedBodyRecursionStep.Dinv, articulatedBodyRecursionStep.S, Dinv_ST); isUpToDate = true; }