@Override public void process() { output.value= NormOps.normF(((VariableMatrix)A).matrix); } };
public double getErrorScalar() { return NormOps.normF(spatialError); }
/** * <p> * Computes the Frobenius normal of the matrix:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * * @see org.ejml.ops.NormOps#normF(org.ejml.data.D1Matrix64F) * * @return The matrix's Frobenius normal. */ public double normF() { return NormOps.normF(mat); }
public double getErrorScalar() { return NormOps.normF(spatialError); }
/** * <p> * Computes the Frobenius normal of the matrix:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * * @see org.ejml.ops.NormOps#normF(org.ejml.data.D1Matrix64F) * * @return The matrix's Frobenius normal. */ public double normF() { return NormOps.normF(mat); }
/** * <p> * Computes the Frobenius normal of the matrix:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * * @see org.ejml.ops.NormOps#normF(org.ejml.data.D1Matrix64F) * * @return The matrix's Frobenius normal. */ public double normF() { return NormOps.normF(mat); }
/** * Computes the p=2 norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normP2( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return normF(A); } else { return inducedP2(A); } }
/** * Computes the p=2 norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normP2( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return normF(A); } else { return inducedP2(A); } }
/** * Computes the p=2 norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normP2( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return normF(A); } else { return inducedP2(A); } }
/** * 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); } }
/** * Computes the dot product of each basis vector against the sample. Can be used as a measure * for membership in the training sample set. High values correspond to a better fit. * * @param sample Sample of original data. * @return Higher value indicates it is more likely to be a member of input dataset. */ public double response( double[] sample ) { if( sample.length != A.numCols ) throw new IllegalArgumentException("Expected input vector to be in sample space"); DenseMatrix64F dots = new DenseMatrix64F(numComponents,1); DenseMatrix64F s = DenseMatrix64F.wrap(A.numCols,1,sample); CommonOps.mult(V_t,s,dots); return NormOps.normF(dots); }
/** * Computes the dot product of each basis vector against the sample. Can be used as a measure * for membership in the training sample set. High values correspond to a better fit. * * @param sample Sample of original data. * @return Higher value indicates it is more likely to be a member of input dataset. */ public double response(double[] sample) { if (sample.length != sampleSize) throw new IllegalArgumentException("Expected input vector to be in sample space"); DenseMatrix64F dots = new DenseMatrix64F(numComponents, 1); DenseMatrix64F s = DenseMatrix64F.wrap(sampleSize, 1, sample); CommonOps.mult(V_t, s, dots); return NormOps.normF(dots); } }
return CommonOps.elementSumAbs(A); } if( p == 2 ) { return normF(A); } else { double max = CommonOps.elementMaxAbs(A);
return CommonOps.elementSumAbs(A); } if( p == 2 ) { return normF(A); } else { double max = CommonOps.elementMaxAbs(A);
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { // foundA = U*W*Vt DenseMatrix64F UW = new DenseMatrix64F(U.numRows,W.numCols); CommonOps.mult(U,W,UW); DenseMatrix64F foundA = new DenseMatrix64F(UW.numRows,Vt.numCols); CommonOps.mult(UW,Vt,foundA); double normA = NormOps.normF(foundA); return SpecializedOps.diffNormF(orig,foundA)/normA; }
/** * <p> * Computes the F norm of the difference between the two Matrices:<br> * <br> * Sqrt{∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> ( a<sub>ij</sub> - b<sub>ij</sub>)<sup>2</sup>} * </p> * <p> * This is often used as a cost function. * </p> * * @see NormOps#fastNormF * * @param a m by n matrix. Not modified. * @param b m by n matrix. Not modified. * * @return The F normal of the difference matrix. */ public static double diffNormF( D1Matrix64F a , D1Matrix64F b ) { if( a.numRows != b.numRows || a.numCols != b.numCols ) { throw new IllegalArgumentException("Both matrices must have the same shape."); } final int size = a.getNumElements(); DenseMatrix64F diff = new DenseMatrix64F(size,1); for( int i = 0; i < size; i++ ) { diff.set(i , b.get(i) - a.get(i)); } return NormOps.normF(diff); }
/** * <p> * Computes the F norm of the difference between the two Matrices:<br> * <br> * Sqrt{∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> ( a<sub>ij</sub> - b<sub>ij</sub>)<sup>2</sup>} * </p> * <p> * This is often used as a cost function. * </p> * * @see NormOps#fastNormF * * @param a m by n matrix. Not modified. * @param b m by n matrix. Not modified. * * @return The F normal of the difference matrix. */ public static double diffNormF( D1Matrix64F a , D1Matrix64F b ) { if( a.numRows != b.numRows || a.numCols != b.numCols ) { throw new IllegalArgumentException("Both matrices must have the same shape."); } final int size = a.getNumElements(); DenseMatrix64F diff = new DenseMatrix64F(size,1); for( int i = 0; i < size; i++ ) { diff.set(i , b.get(i) - a.get(i)); } return NormOps.normF(diff); }
/** * <p> * Computes the F norm of the difference between the two Matrices:<br> * <br> * Sqrt{∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> ( a<sub>ij</sub> - b<sub>ij</sub>)<sup>2</sup>} * </p> * <p> * This is often used as a cost function. * </p> * * @see NormOps#fastNormF * * @param a m by n matrix. Not modified. * @param b m by n matrix. Not modified. * * @return The F normal of the difference matrix. */ public static double diffNormF( D1Matrix64F a , D1Matrix64F b ) { if( a.numRows != b.numRows || a.numCols != b.numCols ) { throw new IllegalArgumentException("Both matrices must have the same shape."); } final int size = a.getNumElements(); DenseMatrix64F diff = new DenseMatrix64F(size,1); for( int i = 0; i < size; i++ ) { diff.set(i , b.get(i) - a.get(i)); } return NormOps.normF(diff); }