Search in sources :

Example 6 with SparseBlockDistributedVector

use of org.apache.ignite.ml.math.impls.vector.SparseBlockDistributedVector in project ignite by apache.

the class SparseDistributedBlockMatrixTest method testMatrixVectorTimes.

/**
 */
public void testMatrixVectorTimes() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    SparseBlockDistributedMatrix a = new SparseBlockDistributedMatrix(new double[][] { { 2.0, 4.0, 0.0 }, { -2.0, 1.0, 3.0 }, { -1.0, 0.0, 1.0 } });
    SparseBlockDistributedVector b = new SparseBlockDistributedVector(new double[] { 1.0, 2.0, -1.0 });
    SparseBlockDistributedVector res = new SparseBlockDistributedVector(new double[] { 10, -3.0, -2.0 });
    Vector calculatedRes = a.times(b);
    for (int i = 0; i < calculatedRes.size(); i++) assertEquals(UNEXPECTED_VAL + " for " + i, res.get(i), calculatedRes.get(i), PRECISION);
}
Also used : SparseBlockDistributedVector(org.apache.ignite.ml.math.impls.vector.SparseBlockDistributedVector) Vector(org.apache.ignite.ml.math.Vector) SparseBlockDistributedVector(org.apache.ignite.ml.math.impls.vector.SparseBlockDistributedVector)

Aggregations

SparseBlockDistributedVector (org.apache.ignite.ml.math.impls.vector.SparseBlockDistributedVector)6 Vector (org.apache.ignite.ml.math.Vector)5 Collection (java.util.Collection)1 Ignite (org.apache.ignite.Ignite)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgnitePair (org.apache.ignite.internal.util.lang.IgnitePair)1 KNNMultipleLinearRegression (org.apache.ignite.ml.knn.regression.KNNMultipleLinearRegression)1 EuclideanDistance (org.apache.ignite.ml.math.distances.EuclideanDistance)1 VectorBlockKey (org.apache.ignite.ml.math.distributed.keys.impl.VectorBlockKey)1 CardinalityException (org.apache.ignite.ml.math.exceptions.CardinalityException)1 BlockVectorStorage (org.apache.ignite.ml.math.impls.storage.matrix.BlockVectorStorage)1 DenseLocalOnHeapVector (org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector)1 VectorBlockEntry (org.apache.ignite.ml.math.impls.vector.VectorBlockEntry)1 LabeledDataset (org.apache.ignite.ml.structures.LabeledDataset)1