/** * Returns the maximum absolute value of all the elements in this matrix. This is * equivalent the the infinite p-norm of the matrix. * * @return Largest absolute value of any element. */ public double elementMaxAbs() { return CommonOps.elementMaxAbs(mat); }
/** * Returns the maximum absolute value of all the elements in this matrix. This is * equivalent the the infinite p-norm of the matrix. * * @return Largest absolute value of any element. */ public double elementMaxAbs() { return CommonOps.elementMaxAbs(mat); }
/** * Returns the maximum absolute value of all the elements in this matrix. This is * equivalent the the infinite p-norm of the matrix. * * @return Largest absolute value of any element. */ public double elementMaxAbs() { return CommonOps.elementMaxAbs(mat); }
/** * Computes the quality of a triangular matrix, where the quality of a matrix * is defined in {@link org.ejml.interfaces.linsol.LinearSolver#quality()}. In * this situation the quality os the absolute value of the product of * each diagonal element divided by the magnitude of the largest diagonal element. * If all diagonal elements are zero then zero is returned. * * @param upper if it is upper triangular or not. * @param T A matrix. @return product of the diagonal elements. * @return the quality of the system. */ public static double qualityTriangular(boolean upper, D1Matrix64F T) { int N = Math.min(T.numRows,T.numCols); // TODO make faster by just checking the upper triangular portion double max = CommonOps.elementMaxAbs(T); if( max == 0.0d ) return 0.0d; double quality = 1.0; for( int i = 0; i < N; i++ ) { quality *= T.unsafe_get(i,i)/max; } return Math.abs(quality); }
/** * Computes the quality of a triangular matrix, where the quality of a matrix * is defined in {@link org.ejml.interfaces.linsol.LinearSolver#quality()}. In * this situation the quality os the absolute value of the product of * each diagonal element divided by the magnitude of the largest diagonal element. * If all diagonal elements are zero then zero is returned. * * @param upper if it is upper triangular or not. * @param T A matrix. @return product of the diagonal elements. * @return the quality of the system. */ public static double qualityTriangular(boolean upper, D1Matrix64F T) { int N = Math.min(T.numRows,T.numCols); // TODO make faster by just checking the upper triangular portion double max = CommonOps.elementMaxAbs(T); if( max == 0.0d ) return 0.0d; double quality = 1.0; for( int i = 0; i < N; i++ ) { quality *= T.unsafe_get(i,i)/max; } return Math.abs(quality); }
/** * Computes the p=∞ norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normPInf( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return CommonOps.elementMaxAbs(A); } else { return inducedPInf(A); } }
public synchronized void setMatrix( D1Matrix64F A ) { double maxValue = CommonOps.elementMaxAbs(A); renderMatrix(A,image,maxValue); repaint(); }
public synchronized void setMatrix( D1Matrix64F A ) { double maxValue = CommonOps.elementMaxAbs(A); renderMatrix(A,image,maxValue); repaint(); }
public synchronized void setMatrix( D1Matrix64F A ) { double maxValue = CommonOps.elementMaxAbs(A); renderMatrix(A,image,maxValue); repaint(); }
/** * Computes the p=∞ norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normPInf( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return CommonOps.elementMaxAbs(A); } else { return inducedPInf(A); } }
/** * Computes the p=∞ norm. If A is a matrix then the induced norm is computed. * * @param A Matrix or vector. * @return The norm. */ public static double normPInf( DenseMatrix64F A ) { if( MatrixFeatures.isVector(A)) { return CommonOps.elementMaxAbs(A); } else { return inducedPInf(A); } }
/** * <p> * Computes the Frobenius matrix norm:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * <p> * This is equivalent to the element wise p=2 norm. See {@link #fastNormF} for another implementation * that is faster, but more prone to underflow/overflow errors. * </p> * * @param a The matrix whose norm is computed. Not modified. * @return The norm's value. */ public static double normF( D1Matrix64F a ) { double total = 0; double scale = CommonOps.elementMaxAbs(a); if( scale == 0.0 ) return 0.0; final int size = a.getNumElements(); for( int i = 0; i < size; i++ ) { double val = a.get(i)/scale; total += val*val; } return scale*Math.sqrt(total); }
/** * <p> * Computes the Frobenius matrix norm:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * <p> * This is equivalent to the element wise p=2 norm. See {@link #fastNormF} for another implementation * that is faster, but more prone to underflow/overflow errors. * </p> * * @param a The matrix whose norm is computed. Not modified. * @return The norm's value. */ public static double normF( D1Matrix64F a ) { double total = 0; double scale = CommonOps.elementMaxAbs(a); if( scale == 0.0 ) return 0.0; final int size = a.getNumElements(); for( int i = 0; i < size; i++ ) { double val = a.get(i)/scale; total += val*val; } return scale*Math.sqrt(total); }
/** * <p> * Computes the Frobenius matrix norm:<br> * <br> * normF = Sqrt{ ∑<sub>i=1:m</sub> ∑<sub>j=1:n</sub> { a<sub>ij</sub><sup>2</sup>} } * </p> * <p> * This is equivalent to the element wise p=2 norm. See {@link #fastNormF} for another implementation * that is faster, but more prone to underflow/overflow errors. * </p> * * @param a The matrix whose norm is computed. Not modified. * @return The norm's value. */ public static double normF( D1Matrix64F a ) { double total = 0; double scale = CommonOps.elementMaxAbs(a); if( scale == 0.0 ) return 0.0; final int size = a.getNumElements(); for( int i = 0; i < size; i++ ) { double val = a.get(i)/scale; total += val*val; } return scale*Math.sqrt(total); }
/** * <p> * Returns true if the matrix is symmetric within the tolerance. Only square matrices can be * symmetric. * </p> * <p> * A matrix is symmetric if:<br> * |a<sub>ij</sub> - a<sub>ji</sub>| ≤ tol * </p> * * @param m A matrix. Not modified. * @param tol Tolerance for how similar two elements need to be. * @return true if it is symmetric and false if it is not. */ public static boolean isSymmetric( DenseMatrix64F m , double tol ) { if( m.numCols != m.numRows ) return false; double max = CommonOps.elementMaxAbs(m); for( int i = 0; i < m.numRows; i++ ) { for( int j = 0; j < i; j++ ) { double a = m.get(i,j)/max; double b = m.get(j,i)/max; double diff = Math.abs(a-b); if( !(diff <= tol) ) { return false; } } } return true; }
/** * Compute the calibration parameters from the b matrix when the skew is assumed to be zero */ private void computeParam_ZeroSkew() { // reduce overflow/underflow CommonOps.divide(b,CommonOps.elementMaxAbs(b)); double B11 = b.get(0,0); double B22 = b.get(1,0); double B13 = b.get(2,0); double B23 = b.get(3,0); double B33 = b.get(4,0); double temp0 = -B11*B23; double temp1 = B11*B22; double v0 = temp0/temp1; double lambda = B33-(B13*B13 + v0*temp0)/B11; // Using abs() inside is an adhoc modification to make it more stable // If there is any good theoretical reason for it, that's a pure accident. Seems // to work well in practice double a = Math.sqrt(Math.abs(lambda / B11)); double b = Math.sqrt(Math.abs(lambda*B11/temp1)); double u0 = - B13/B11; K.set(0,0,a); K.set(0,1,0); K.set(0,2,u0); K.set(1,1,b); K.set(1,2,v0); K.set(2,2,1); }
double max1 = CommonOps.elementMaxAbs(h1); double max2 = CommonOps.elementMaxAbs(h2); double max = Math.max(max1,max2);
@Override public boolean decompose(DenseMatrix64F orig) { decompQRP.setSingularThreshold(CommonOps.elementMaxAbs(orig)* UtilEjml.EPS); if( !decompQRP.decompose(orig) ) { return false; } m = orig.numRows; n = orig.numCols; min = Math.min(m, n); B.reshape(min, n,false); decompQRP.getR(B,true); // apply the column pivots. // TODO this is horribly inefficient DenseMatrix64F result = new DenseMatrix64F(min,n); DenseMatrix64F P = decompQRP.getPivotMatrix(null); CommonOps.multTransB(B, P, result); B.set(result); return decompBi.decompose(B); }
private double applyTimeUpdate() { timeUpdate.set(timeGradient); CommonOps.scale(-timeGain.getDoubleValue(), timeUpdate); double maxUpdate = CommonOps.elementMaxAbs(timeUpdate); double minIntervalTime = CommonOps.elementMin(intervalTimes); if (maxUpdate > 0.4 * minIntervalTime) { CommonOps.scale(0.4 * minIntervalTime / maxUpdate, timeUpdate); } for (int i = 0; i < intervals.getIntegerValue(); i++) { intervalTimes.add(i, 0, timeUpdate.get(i)); } return solveMinAcceleration(); }
private double applyTimeUpdate() { timeUpdate.set(timeGradient); CommonOps.scale(-timeGain.getDoubleValue(), timeUpdate); double maxUpdate = CommonOps.elementMaxAbs(timeUpdate); double minIntervalTime = CommonOps.elementMin(intervalTimes); if (maxUpdate > 0.4 * minIntervalTime) { CommonOps.scale(0.4 * minIntervalTime / maxUpdate, timeUpdate); } for (int i = 0; i < intervals.getIntegerValue(); i++) { intervalTimes.add(i, 0, timeUpdate.get(i)); } return solveMinAcceleration(); }