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);
}
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);
}
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) {
}
}
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();
}
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);
}
Aggregations