use of com.tencent.angel.ml.math2.vector.IntDoubleVector in project angel by Tencent.
the class CooIntDoubleMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
DoubleArrayList data = new DoubleArrayList();
for (int i = 0; i < rowIndices.length; i++) {
if (rowIndices[i] == idx) {
cols.add(colIndices[i]);
data.add(values[i]);
}
}
IntDoubleSparseVectorStorage storage = new IntDoubleSparseVectorStorage(shape[1], cols.toIntArray(), data.toDoubleArray());
return new IntDoubleVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
use of com.tencent.angel.ml.math2.vector.IntDoubleVector in project angel by Tencent.
the class CooIntDoubleMatrix method getCol.
@Override
public Vector getCol(int idx) {
IntArrayList cols = new IntArrayList();
DoubleArrayList data = new DoubleArrayList();
for (int i = 0; i < colIndices.length; i++) {
if (colIndices[i] == idx) {
cols.add(rowIndices[i]);
data.add(values[i]);
}
}
IntDoubleSparseVectorStorage storage = new IntDoubleSparseVectorStorage(shape[0], cols.toIntArray(), data.toDoubleArray());
return new IntDoubleVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
use of com.tencent.angel.ml.math2.vector.IntDoubleVector in project angel by Tencent.
the class CsrDoubleMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
DoubleArrayList data = new DoubleArrayList();
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]);
}
IntDoubleSparseVectorStorage storage = new IntDoubleSparseVectorStorage(shape[1], cols.toIntArray(), data.toDoubleArray());
return new IntDoubleVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
use of com.tencent.angel.ml.math2.vector.IntDoubleVector in project angel by Tencent.
the class CsrDoubleMatrix method getCol.
@Override
public Vector getCol(int idx) {
IntArrayList cols = new IntArrayList();
DoubleArrayList data = new DoubleArrayList();
int[] rows = new int[indices.length];
int i = 0;
int j = 0;
while (i < indptr.length - 1 && j < indptr.length - 1) {
int r = indptr[i + 1] - indptr[i];
for (int p = j; p < j + r; p++) {
rows[p] = i;
}
if (r != 0) {
j++;
}
i++;
}
for (int id = 0; id < indices.length; id++) {
if (indices[id] == idx) {
cols.add(rows[id]);
data.add(values[id]);
}
}
IntDoubleSparseVectorStorage storage = new IntDoubleSparseVectorStorage(shape[0], cols.toIntArray(), data.toDoubleArray());
return new IntDoubleVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
use of com.tencent.angel.ml.math2.vector.IntDoubleVector in project angel by Tencent.
the class RBLongDoubleMatrix 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);
}
Aggregations