use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class CsrFloatMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
int rowNum = indptr.length - 1;
assert (idx < rowNum);
for (int i = indptr[idx]; i < indptr[idx + 1]; i++) {
cols.add(indices[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 RBCompIntDoubleMatrix method diag.
@Override
public Vector diag() {
double[] resArr = new double[rows.length];
for (int i = 0; i < rows.length; i++) {
if (null == rows[i]) {
resArr[i] = 0;
} else {
resArr[i] = rows[i].get(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 RBCompIntDoubleMatrix method initEmpty.
@Override
public void initEmpty(int idx) {
int numComp = (int) ((getDim() + subDim - 1) / subDim);
if (null == rows[idx]) {
IntDoubleVector[] tmpParts = new IntDoubleVector[numComp];
for (int i = 0; i < numComp; i++) {
IntDoubleSparseVectorStorage storage = new IntDoubleSparseVectorStorage(subDim);
tmpParts[i] = new IntDoubleVector(matrixId, idx, clock, (int) getDim(), storage);
}
CompIntDoubleVector tmpVect = new CompIntDoubleVector(matrixId, idx, clock, (int) getDim(), tmpParts, subDim);
rows[idx] = tmpVect;
}
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class RBCompIntIntMatrix method diag.
@Override
public Vector diag() {
int[] resArr = new int[rows.length];
for (int i = 0; i < rows.length; i++) {
if (null == rows[i]) {
resArr[i] = 0;
} else {
resArr[i] = rows[i].get(i);
}
}
IntIntDenseVectorStorage storage = new IntIntDenseVectorStorage(resArr);
return new IntIntVector(getMatrixId(), 0, getClock(), resArr.length, storage);
}
use of com.tencent.angel.ml.math2.storage.Storage in project angel by Tencent.
the class BlasDoubleMatrix method getRow.
@Override
public Vector getRow(int i) {
double[] row = new double[numCols];
System.arraycopy(data, i * numCols, row, 0, numCols);
IntDoubleDenseVectorStorage storage = new IntDoubleDenseVectorStorage(row);
return new IntDoubleVector(getMatrixId(), i, getClock(), numCols, storage);
}
Aggregations