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;
}
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;
}
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;
}
});
}
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;
}
});
}
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;
}
Aggregations