Search in sources :

Example 1 with DoubleMatrix2D

use of cern.colt.matrix.tdouble.DoubleMatrix2D in project clusterMaker2 by RBVI.

the class ColtMatrix method create2DMatrix.

private DoubleMatrix2D create2DMatrix(DoubleMatrix1D[] rows) {
    int columns = (int) rows[0].size();
    DoubleMatrix2D C = DoubleFactory2D.sparse.make(rows.length, columns);
    for (int row = 0; row < rows.length; row++) {
        for (int col = 0; col < columns; col++) {
            double value = rows[row].getQuick(col);
            if (value != 0.0)
                C.setQuick(row, col, value);
        }
    }
    return C;
}
Also used : DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Example 2 with DoubleMatrix2D

use of cern.colt.matrix.tdouble.DoubleMatrix2D in project clusterMaker2 by RBVI.

the class ColtOps method invertMatrix.

/**
 * Invert the matrix in place
 */
public void invertMatrix() {
    if (!matrix.isSymmetrical()) {
        logger.warn("clusterMaker2 ColtMatrix: attempt to invert an assymetric network");
    }
    DenseDoubleAlgebra dda = new DenseDoubleAlgebra();
    DoubleMatrix2D inverse = dda.inverse(getData());
    ((ColtMatrix) matrix).data = inverse;
}
Also used : DenseDoubleAlgebra(cern.colt.matrix.tdouble.algo.DenseDoubleAlgebra) DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Example 3 with DoubleMatrix2D

use of cern.colt.matrix.tdouble.DoubleMatrix2D in project clusterMaker2 by RBVI.

the class ColtOps method divideScalar.

/**
 * divide all cells in the matrix by a value
 *
 * @param matrix our matrix
 * @param value to divide each cell by
 */
public void divideScalar(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)

Example 4 with DoubleMatrix2D

use of cern.colt.matrix.tdouble.DoubleMatrix2D in project clusterMaker2 by RBVI.

the class ColtOps method addScalar.

/**
 * add a value to all cells in the matrix
 *
 * @param value to add to each cell
 */
public void addScalar(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)

Example 5 with DoubleMatrix2D

use of cern.colt.matrix.tdouble.DoubleMatrix2D in project clusterMaker2 by RBVI.

the class ColtOps method transpose.

/**
 * Create a new matrix that is the transpose of this matrix
 */
public Matrix transpose() {
    DenseDoubleAlgebra dda = new DenseDoubleAlgebra();
    DoubleMatrix2D trans = dda.transpose(matrix.data);
    ColtMatrix result = new ColtMatrix(matrix, trans);
    result.transposed = true;
    return result;
}
Also used : DenseDoubleAlgebra(cern.colt.matrix.tdouble.algo.DenseDoubleAlgebra) DoubleMatrix2D(cern.colt.matrix.tdouble.DoubleMatrix2D)

Aggregations

DoubleMatrix2D (cern.colt.matrix.tdouble.DoubleMatrix2D)30 IntIntDoubleFunction (cern.colt.function.tdouble.IntIntDoubleFunction)8 DenseDoubleAlgebra (cern.colt.matrix.tdouble.algo.DenseDoubleAlgebra)5 DoubleArrayList (cern.colt.list.tdouble.DoubleArrayList)3 IntArrayList (cern.colt.list.tint.IntArrayList)3 DoubleMatrix1D (cern.colt.matrix.tdouble.DoubleMatrix1D)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CyNode (org.cytoscape.model.CyNode)3 DenseDoubleEigenvalueDecomposition (cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleEigenvalueDecomposition)2 NodeCluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.NodeCluster)2 DenseDoubleSingularValueDecomposition (cern.colt.matrix.tdouble.algo.decomposition.DenseDoubleSingularValueDecomposition)1 SparseDoubleMatrix2D (cern.colt.matrix.tdouble.impl.SparseDoubleMatrix2D)1 Edges (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.costmatrixcreation.dataTypes.Edges)1 IteratorThread (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.iterativeclustering.IteratorThread)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 Semaphore (java.util.concurrent.Semaphore)1 structures._Node (structures._Node)1