/** * <tt>A[row,col] = A[row,col] < B[row,col] ? 1 : 0</tt>. * @param A the matrix to modify. * @param B the matrix to stay unaffected. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D less(DoubleMatrix2D A, DoubleMatrix2D B) { return A.assign(B,F.less); } /**
/** * <tt>A = A * B <=> A[row,col] = A[row,col] * B[row,col]</tt>. * @param A the matrix to modify. * @param B the matrix to stay unaffected. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D mult(DoubleMatrix2D A, DoubleMatrix2D B) { return A.assign(B,F.mult); } /**
/** * <tt>A = A<sup>B</sup> <=> A[row,col] = Math.pow(A[row,col], B[row,col])</tt>. * @param A the matrix to modify. * @param B the matrix to stay unaffected. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D pow(DoubleMatrix2D A, DoubleMatrix2D B) { return A.assign(B,F.pow); } }
/** * <tt>A[row,col] = Math.abs(A[row,col])</tt>. * @param A the matrix to modify. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D abs(DoubleMatrix2D A) { return A.assign(F.abs); } /**
/** * <tt>A = A / B <=> A[row,col] = A[row,col] / B[row,col]</tt>. * @param A the matrix to modify. * @param B the matrix to stay unaffected. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D div(DoubleMatrix2D A, DoubleMatrix2D B) { return A.assign(B,F.div); } /**
/** * <tt>A = A / s <=> A[row,col] = A[row,col] / s</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D div(DoubleMatrix2D A, double s) { return A.assign(F.div(s)); } /**
/** * <tt>A[row,col] = A[row,col] < s ? 1 : 0</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D less(DoubleMatrix2D A, double s) { return A.assign(F.less(s)); } /**
/** * <tt>A = A - B*s <=> A[row,col] = A[row,col] - B[row,col]*s</tt>. * @param A the matrix to modify. * @param B the matrix to stay unaffected. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D minusMult(DoubleMatrix2D A, DoubleMatrix2D B, double s) { return A.assign(B,F.minusMult(s)); } /**
/** * <tt>A = A * s <=> A[row,col] = A[row,col] * s</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D mult(DoubleMatrix2D A, double s) { return A.assign(F.mult(s)); } /**
/** * <tt>A = A<sup>s</sup> <=> A[row,col] = Math.pow(A[row,col], s)</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D pow(DoubleMatrix2D A, double s) { return A.assign(F.pow(s)); } /**
/** * Sets all cells to the state specified by <tt>value</tt>. * @param value the value to be filled into the cells. * @return <tt>this</tt> (for convenience only). */ public DoubleMatrix2D assign(double value) { // overriden for performance only if (this.isNoView && value==0) this.elements.clear(); else super.assign(value); return this; } /**
/** * Constructs and returns a deep copy of the receiver. * <p> * <b>Note that the returned matrix is an independent deep copy.</b> * The returned matrix is not backed by this matrix, so changes in the returned matrix are not reflected in this matrix, and vice-versa. * * @return a deep copy of the receiver. */ public DoubleMatrix2D copy() { return like().assign(this); } /**
/** * <tt>A[row,col] = A[row,col] == s ? 1 : 0</tt>; ignores tolerance. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D equals(DoubleMatrix2D A, double s) { return A.assign(F.equals(s)); } /**
/** * <tt>A[row,col] = A[row,col] < s ? 1 : 0</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D less(DoubleMatrix2D A, double s) { return A.assign(F.less(s)); } /**
/** * <tt>A = A<sup>s</sup> <=> A[row,col] = Math.pow(A[row,col], s)</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D pow(DoubleMatrix2D A, double s) { return A.assign(F.pow(s)); } /**
/** * <tt>A = A + s <=> A[row,col] = A[row,col] + s</tt>. * @param A the matrix to modify. * @param s the scalar; can have any value. * @return <tt>A</tt> (for convenience only). */ public static DoubleMatrix2D plus(DoubleMatrix2D A, double s) { return A.assign(F.plus(s)); } /**
public void init() { A.assign(0); int seed = 123456; current = 4*seed+1; density = A.cardinality() / (double) A.size(); } public void apply(cern.colt.Timer timer) {
/** * Constructs a matrix with uniformly distributed values in <tt>(0,1)</tt> (exclusive). */ public DoubleMatrix2D random(int rows, int columns) { return make(rows,columns).assign(cern.jet.math.Functions.random()); } /**
/** * Normalizes matrix of p(i|z) such that \sum_{i, z} p(i|z) = 1. * * @param piz normalized matrix of p(i|z) */ protected void normalizePiz(DoubleMatrix2D piz) { piz.assign(mult(1 / piz.aggregate(plus, identity))); }
public Matrix minus(double value) { Matrix result = new ColtDenseDoubleMatrix2D((DenseDoubleMatrix2D) matrix.copy().assign(Functions.minus(value))); MapMatrix<String, Object> a = getMetaData(); if (a != null) { result.setMetaData(a.clone()); } return result; }