Search in sources :

Example 6 with IntIntDoubleFunction

use of cern.colt.function.tdouble.IntIntDoubleFunction in project clusterMaker2 by RBVI.

the class ColtOps method addElement.

/**
 * add two matrices together
 *
 * @param addend the matrix to add to our matrix
 */
public void addElement(Matrix addend) {
    DoubleMatrix2D data = getData();
    data.forEachNonZero(new IntIntDoubleFunction() {

        public double apply(int row, int column, double v) {
            double addendValue = addend.doubleValue(row, column);
            if (!Double.isNaN(addendValue))
                return v + addendValue;
            else
                return v;
        }
    });
}
Also used : IntIntDoubleFunction(cern.colt.function.tdouble.IntIntDoubleFunction) DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Example 7 with IntIntDoubleFunction

use of cern.colt.function.tdouble.IntIntDoubleFunction in project clusterMaker2 by RBVI.

the class ColtOps method powScalar.

/**
 * raise all cells in the matrix by a power
 *
 * @param matrix our matrix
 * @param value power to raise to each cell
 */
public void powScalar(double value) {
    DoubleMatrix2D data = getData();
    data.forEachNonZero(new IntIntDoubleFunction() {

        public double apply(int row, int column, double v) {
            return Math.pow(v, value);
        }
    });
}
Also used : IntIntDoubleFunction(cern.colt.function.tdouble.IntIntDoubleFunction) DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Example 8 with IntIntDoubleFunction

use of cern.colt.function.tdouble.IntIntDoubleFunction in project clusterMaker2 by RBVI.

the class ColtOps method subtractScalar.

/**
 * subtract a value from all cells in the matrix
 *
 * @param value to subtract from each cell
 */
public void subtractScalar(double value) {
    DoubleMatrix2D data = getData();
    data.forEachNonZero(new IntIntDoubleFunction() {

        public double apply(int row, int column, double v) {
            return v - value;
        }
    });
}
Also used : IntIntDoubleFunction(cern.colt.function.tdouble.IntIntDoubleFunction) DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Aggregations

IntIntDoubleFunction (cern.colt.function.tdouble.IntIntDoubleFunction)8 DoubleMatrix2D (cern.colt.matrix.tdouble.DoubleMatrix2D)8 DoubleMatrix1D (cern.colt.matrix.tdouble.DoubleMatrix1D)1 ExecutorService (java.util.concurrent.ExecutorService)1