Search in sources :

Example 11 with IdentityValueMapper

use of org.apache.ignite.ml.math.IdentityValueMapper in project ignite by apache.

the class CacheVectorTest method testAssign.

/**
 */
public void testAssign() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    IdentityValueMapper valMapper = new IdentityValueMapper();
    CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
    initVector(cacheVector);
    cacheVector.assign(1d);
    for (int i = 0; i < size; i++) assertEquals("Unexpected value.", cacheVector.get(i), 1d, 0d);
}
Also used : IdentityValueMapper(org.apache.ignite.ml.math.IdentityValueMapper)

Example 12 with IdentityValueMapper

use of org.apache.ignite.ml.math.IdentityValueMapper in project ignite by apache.

the class CacheVectorTest method testAssignVector.

/**
 */
public void testAssignVector() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    IdentityValueMapper valMapper = new IdentityValueMapper();
    CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
    Vector testVec = new DenseLocalOnHeapVector(IntStream.range(0, size).asDoubleStream().toArray());
    cacheVector.assign(testVec);
    for (int i = 0; i < size; i++) assertEquals("Unexpected value.", cacheVector.get(i), testVec.get(i), 0d);
}
Also used : IdentityValueMapper(org.apache.ignite.ml.math.IdentityValueMapper) Vector(org.apache.ignite.ml.math.Vector)

Example 13 with IdentityValueMapper

use of org.apache.ignite.ml.math.IdentityValueMapper in project ignite by apache.

the class CacheVectorTest method testLikeMatrix.

/**
 */
public void testLikeMatrix() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    IdentityValueMapper valMapper = new IdentityValueMapper();
    CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
    try {
        cacheVector.likeMatrix(size, size);
        TestCase.fail("Unsupported case");
    } catch (UnsupportedOperationException ignored) {
    }
}
Also used : IdentityValueMapper(org.apache.ignite.ml.math.IdentityValueMapper) UnsupportedOperationException(org.apache.ignite.ml.math.exceptions.UnsupportedOperationException)

Example 14 with IdentityValueMapper

use of org.apache.ignite.ml.math.IdentityValueMapper in project ignite by apache.

the class CacheVectorTest method testSumEmptyVector.

/**
 */
public void testSumEmptyVector() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    IdentityValueMapper valMapper = new IdentityValueMapper();
    CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
    cacheVector.sum();
}
Also used : IdentityValueMapper(org.apache.ignite.ml.math.IdentityValueMapper)

Example 15 with IdentityValueMapper

use of org.apache.ignite.ml.math.IdentityValueMapper in project ignite by apache.

the class CacheVectorTest method testDivide.

/**
 */
public void testDivide() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    final int size = MathTestConstants.STORAGE_SIZE;
    IdentityValueMapper valMapper = new IdentityValueMapper();
    CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
    initVector(cacheVector);
    cacheVector.assign(1d);
    cacheVector.divide(2d);
    for (int i = 0; i < size; i++) assertEquals("Unexpected value.", cacheVector.get(i), 1d / 2d, 0d);
}
Also used : IdentityValueMapper(org.apache.ignite.ml.math.IdentityValueMapper)

Aggregations

IdentityValueMapper (org.apache.ignite.ml.math.IdentityValueMapper)37 UnsupportedOperationException (org.apache.ignite.ml.math.exceptions.UnsupportedOperationException)8 Vector (org.apache.ignite.ml.math.Vector)5 Ignite (org.apache.ignite.Ignite)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 ValueMapper (org.apache.ignite.ml.math.distributed.ValueMapper)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ExternalizeTest (org.apache.ignite.ml.math.ExternalizeTest)1 MatrixKeyMapper (org.apache.ignite.ml.math.distributed.MatrixKeyMapper)1 VectorKeyMapper (org.apache.ignite.ml.math.distributed.VectorKeyMapper)1 CacheMatrix (org.apache.ignite.ml.math.impls.matrix.CacheMatrix)1 CacheVector (org.apache.ignite.ml.math.impls.vector.CacheVector)1