use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class BlasDoubleMatrix method getCol.
@Override
public Vector getCol(int j) {
double[] col = new double[numRows];
for (int i = 0; i < numRows; i++) {
col[i] = data[i * numCols + j];
}
IntDoubleDenseVectorStorage storage = new IntDoubleDenseVectorStorage(col);
return new IntDoubleVector(getMatrixId(), 0, getClock(), numRows, storage);
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class BlasDoubleMatrix method diag.
@Override
public Vector diag() {
int numDiag = Math.min(numRows, numCols);
double[] resArr = new double[numDiag];
for (int i = 0; i < numDiag; i++) {
resArr[i] = data[i * numRows + i];
}
IntDoubleDenseVectorStorage storage = new IntDoubleDenseVectorStorage(resArr);
return new IntDoubleVector(getMatrixId(), 0, getClock(), resArr.length, storage);
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class CooIntFloatMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
for (int i = 0; i < rowIndices.length; i++) {
if (rowIndices[i] == idx) {
cols.add(colIndices[i]);
data.add(values[i]);
}
}
IntFloatSparseVectorStorage storage = new IntFloatSparseVectorStorage(shape[1], cols.toIntArray(), data.toFloatArray());
return new IntFloatVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class BlasFloatMatrix method getRow.
@Override
public Vector getRow(int i) {
float[] row = new float[numCols];
System.arraycopy(data, i * numCols, row, 0, numCols);
IntFloatDenseVectorStorage storage = new IntFloatDenseVectorStorage(row);
return new IntFloatVector(getMatrixId(), i, getClock(), numCols, storage);
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class RBCompIntFloatMatrix method dot.
@Override
public Vector dot(Vector other) {
float[] resArr = new float[rows.length];
for (int i = 0; i < rows.length; i++) {
resArr[i] = (float) rows[i].dot(other);
}
IntFloatDenseVectorStorage storage = new IntFloatDenseVectorStorage(resArr);
return new IntFloatVector(matrixId, 0, clock, rows.length, storage);
}
Aggregations