Search in sources :

Example 96 with Storage

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);
}
Also used : IntDoubleDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleDenseVectorStorage) IntDoubleVector(com.tencent.angel.ml.math2.vector.IntDoubleVector)

Example 97 with 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);
}
Also used : IntDoubleDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleDenseVectorStorage) IntDoubleVector(com.tencent.angel.ml.math2.vector.IntDoubleVector)

Example 98 with 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);
}
Also used : IntFloatSparseVectorStorage(com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage) FloatArrayList(it.unimi.dsi.fastutil.floats.FloatArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 99 with 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);
}
Also used : IntFloatDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntFloatDenseVectorStorage) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 100 with 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);
}
Also used : IntFloatDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntFloatDenseVectorStorage) CompIntFloatVector(com.tencent.angel.ml.math2.vector.CompIntFloatVector) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Aggregations

IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)187 IntFloatVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatVectorStorage)186 LongFloatVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatVectorStorage)185 LongIntVectorStorage (com.tencent.angel.ml.math2.storage.LongIntVectorStorage)183 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)182 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)181 IntIntVectorStorage (com.tencent.angel.ml.math2.storage.IntIntVectorStorage)180 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)180 Storage (com.tencent.angel.ml.math2.storage.Storage)169 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)139 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)123 IntFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage)123 LongFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSparseVectorStorage)121 IntDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)119 LongDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSortedVectorStorage)119 LongDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage)119 LongIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongIntSparseVectorStorage)119 IntFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSortedVectorStorage)118 LongFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSortedVectorStorage)118 IntIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSparseVectorStorage)117