use of org.apache.ignite.ml.math.exceptions.math.CardinalityException in project ignite by apache.
the class VectorImplementationsTest method assignVectorWrongCardinality.
/**
*/
private void assignVectorWrongCardinality(Vector v, String desc) {
boolean expECaught = false;
try {
v.assign(new DenseVector(v.size() + 1));
} catch (CardinalityException ce) {
expECaught = true;
}
assertTrue("Expect exception at too large size in " + desc, expECaught);
if (v.size() < 2)
return;
expECaught = false;
try {
v.assign(new DenseVector(v.size() - 1));
} catch (CardinalityException ce) {
expECaught = true;
}
assertTrue("Expect exception at too small size in " + desc, expECaught);
}
use of org.apache.ignite.ml.math.exceptions.math.CardinalityException in project ignite by apache.
the class VectorImplementationsTest method assertWrongCardinality.
/**
*/
private void assertWrongCardinality(Vector v, String desc, BiFunction<Vector, Vector, Vector> vecOperation) {
boolean expECaught = false;
try {
vecOperation.apply(v, new DenseVector(v.size() + 1));
} catch (CardinalityException ce) {
expECaught = true;
}
assertTrue("Expect exception at too large size in " + desc, expECaught);
if (v.size() < 2)
return;
expECaught = false;
try {
vecOperation.apply(v, new DenseVector(v.size() - 1));
} catch (CardinalityException ce) {
expECaught = true;
}
assertTrue("Expect exception at too small size in " + desc, expECaught);
}
use of org.apache.ignite.ml.math.exceptions.math.CardinalityException in project ignite by apache.
the class AbstractMatrix method times.
/**
* {@inheritDoc}
*/
@Override
public Vector times(Vector vec) {
int cols = columnSize();
if (cols != vec.size())
throw new CardinalityException(cols, vec.size());
int rows = rowSize();
Vector res = likeVector(rows);
Blas.gemv(1, this, vec, 0, res);
return res;
}
use of org.apache.ignite.ml.math.exceptions.math.CardinalityException in project ignite by apache.
the class AbstractMatrix method setRow.
/**
* {@inheritDoc}
*/
@Override
public Matrix setRow(int row, double[] data) {
checkRowIndex(row);
int cols = columnSize();
if (cols != data.length)
throw new CardinalityException(cols, data.length);
// TODO: IGNITE-5777, use Blas for this.
for (int y = 0; y < cols; y++) setX(row, y, data[y]);
return this;
}
use of org.apache.ignite.ml.math.exceptions.math.CardinalityException in project ignite by apache.
the class AbstractMatrix method assignRow.
/**
* {@inheritDoc}
*/
@Override
public Matrix assignRow(int row, Vector vec) {
checkRowIndex(row);
int cols = columnSize();
if (cols != vec.size())
throw new CardinalityException(cols, vec.size());
// TODO: IGNITE-5777, use Blas for this.
for (int y = 0; y < cols; y++) storageSet(row, y, vec.getX(y));
return this;
}
Aggregations