/** * Clones the input matrix to prevent any later edits to the input from * changing the results of iterative multiplications. * * @param m The matrix to multiply with */ public MatrixVectorMultiplier(Matrix m) { this.m = m.clone(); }
/** * Clones the input matrix to prevent any later edits to the input from * changing the results of iterative multiplications. * * @param m The matrix to multiply with */ public MatrixVectorMultiplier(Matrix m) { this.m = m.clone(); }
/** * Clones the input matrix to prevent any later edits to the input from * changing the results of iterative multiplications. * * @param m The matrix to multiply with */ public MatrixVectorMultiplier(Matrix m) { this.m = m.clone(); }
/** * Copy constructor * @param other MultivariateDiscriminant to copy */ public MultivariateDiscriminant( final MultivariateDiscriminant other ) { this( other.getDiscriminant().clone() ); }
/** * Copy constructor * @param other MultivariateDiscriminant to copy */ public MultivariateDiscriminant( final MultivariateDiscriminant other ) { this( other.getDiscriminant().clone() ); }
/** * Copy constructor * @param other MultivariateDiscriminant to copy */ public MultivariateDiscriminant( final MultivariateDiscriminant other ) { this( other.getDiscriminant().clone() ); }
/** * @param A * @param B * @return A - B, done using {@link #fastminusEquals(Matrix, Matrix)} if * possible */ public static Matrix fastminus(Matrix A, Matrix B) { return fastminusEquals(A.clone(), B); }
/** * Gets the covariance of the Gaussian. * * @return The covariance. */ public Matrix getCovariance() { if (this.count <= 0) { return null; } else if (this.count == 1) { // This allows the default variance to be used. return this.sumSquaredDifferences.clone(); } else { return this.sumSquaredDifferences.scale(1.0 / (this.count - 1.0)); } }
/** * Gets the covariance Inverse of the Gaussian. * * @return The covariance. */ public Matrix getCovarianceInverse() { if (this.count <= 0) { return null; } else if (this.count == 1) { // This allows the default variance to be used. return this.sumSquaredDifferencesInverse.clone(); } else { return this.sumSquaredDifferencesInverse.scale(this.count - 1.0); } }
/** * Gets the covariance Inverse of the Gaussian. * * @return The covariance. */ public Matrix getCovarianceInverse() { if (this.count <= 0) { return null; } else if (this.count == 1) { // This allows the default variance to be used. return this.sumSquaredDifferencesInverse.clone(); } else { return this.sumSquaredDifferencesInverse.scale(this.count - 1.0); } }
/** * Creates a new instance of SimplePatternRecognizer. * * @param other The SimplePatternRecognizer to copy. */ public SimplePatternRecognizer( SimplePatternRecognizer other) { super(); this.setNodes(new ArrayList<SemanticLabel>(other.nodes)); this.setNodeToIDMap( new HashMap<SemanticLabel, Integer>(other.nodeToIDMap)); this.setMatrix(other.matrix.clone()); this.setNodesChangedSinceLastUpdate(other.nodesChangedSinceLastUpdate); }
@Override public MultivariateDiscriminant clone() { MultivariateDiscriminant clone = (MultivariateDiscriminant) super.clone(); clone.setDiscriminant( this.getDiscriminant().clone() ); return clone; }
@Override public MultivariateDiscriminant clone() { MultivariateDiscriminant clone = (MultivariateDiscriminant) super.clone(); clone.setDiscriminant( this.getDiscriminant().clone() ); return clone; }
/** * Creates a new instance of SimplePatternRecognizer. * * @param other The SimplePatternRecognizer to copy. */ public SimplePatternRecognizer( SimplePatternRecognizer other) { super(); this.setNodes(new ArrayList<SemanticLabel>(other.nodes)); this.setNodeToIDMap( new HashMap<SemanticLabel, Integer>(other.nodeToIDMap)); this.setMatrix(other.matrix.clone()); this.setNodesChangedSinceLastUpdate(other.nodesChangedSinceLastUpdate); }
/** * Creates a new instance of SimplePatternRecognizer. * * @param other The SimplePatternRecognizer to copy. */ public SimplePatternRecognizer( SimplePatternRecognizer other) { super(); this.setNodes(new ArrayList<SemanticLabel>(other.nodes)); this.setNodeToIDMap( new HashMap<SemanticLabel, Integer>(other.nodeToIDMap)); this.setMatrix(other.matrix.clone()); this.setNodesChangedSinceLastUpdate(other.nodesChangedSinceLastUpdate); }
@Override public MultivariateDiscriminant clone() { MultivariateDiscriminant clone = (MultivariateDiscriminant) super.clone(); clone.setDiscriminant( this.getDiscriminant().clone() ); return clone; }
/** * Create a new matrix with the absolute values of the input matrix. * * @param mat * input matrix * @return absolute matrix */ public static Matrix abs(Matrix mat) { final Matrix ret = mat.clone(); final int nrows = ret.getNumRows(); final int ncols = ret.getNumColumns(); for (int r = 0; r < nrows; r++) { for (int c = 0; c < ncols; c++) { ret.setElement(r, c, Math.abs(mat.getElement(r, c))); } } return ret; }
public boolean test_backtrack(Matrix W, Matrix grad, Matrix prox, double eta){ Matrix tmp = prox.clone(); tmp.minusEquals(W); Vector tmpvec = tmp.getColumn(0); return ( eval(prox) <= eval(W) + grad.getColumn(0).dotProduct(tmpvec) + 0.5*eta*tmpvec.norm2()); } }
private Matrix softThreshold(Matrix w, double lambda) { Matrix ret = w.clone(); ret.zero(); int nrow = w.getNumRows(); int ncol = w.getNumColumns(); for (int r = 0; r < nrow; r++) { for (int c = 0; c < ncol; c++) { double v = ret.getElement(r, c); if(v < -lambda){ ret.setElement(r, c, v + lambda); } else if(v > lambda){ ret.setElement(r, c, v - lambda); } } } return ret; }