use of com.tencent.angel.ml.math2.storage.IntDoubleDenseVectorStorage in project angel by Tencent.
the class DotMatrixExecutor method apply.
private static Vector apply(BlasDoubleMatrix mat, boolean trans, IntDummyVector v) {
int m = mat.getNumRows(), n = mat.getNumCols();
double[] resArr;
if (trans) {
assert m == v.getDim();
resArr = new double[n];
} else {
assert n == v.getDim();
resArr = new double[m];
}
int r = mat.getNumRows(), c = mat.getNumCols();
double[] data = mat.getData();
if (trans) {
for (int j = 0; j < c; j++) {
int[] idxs = v.getIndices();
for (int i : idxs) {
resArr[j] += data[i * c + j];
}
}
} else {
for (int i = 0; i < r; i++) {
int[] idxs = v.getIndices();
for (int j : idxs) {
resArr[i] += data[i * c + j];
}
}
}
IntDoubleDenseVectorStorage storage = new IntDoubleDenseVectorStorage(resArr);
return new IntDoubleVector(v.getMatrixId(), v.getClock(), 0, resArr.length, storage);
}
use of com.tencent.angel.ml.math2.storage.IntDoubleDenseVectorStorage 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.IntDoubleDenseVectorStorage in project angel by Tencent.
the class RBCompLongDoubleMatrix 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.IntDoubleDenseVectorStorage in project angel by Tencent.
the class RBIntDoubleMatrix 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.IntDoubleDenseVectorStorage 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