Search in sources :

Example 1 with NonSquareMatrixException

use of org.apache.ignite.ml.math.exceptions.math.NonSquareMatrixException in project ignite by apache.

the class Blas method syr.

/**
 * A := alpha * x * x^T + A.
 *
 * @param alpha a real scalar that will be multiplied to x * x^T^.
 * @param x the vector x that contains the n elements.
 * @param a the symmetric matrix A. Size of n x n.
 */
void syr(Double alpha, Vector x, DenseMatrix a) {
    int mA = a.rowSize();
    int nA = a.columnSize();
    if (mA != nA)
        throw new NonSquareMatrixException(mA, nA);
    if (mA != x.size())
        throw new CardinalityException(x.size(), mA);
    // TODO: IGNITE-5535, Process DenseLocalOffHeapVector
    if (x instanceof DenseVector)
        syr(alpha, x, a);
    else if (x instanceof SparseVector)
        syr(alpha, x, a);
    else
        throw new IllegalArgumentException("Operation 'syr' does not support vector [class=" + x.getClass().getName() + "].");
}
Also used : NonSquareMatrixException(org.apache.ignite.ml.math.exceptions.math.NonSquareMatrixException) CardinalityException(org.apache.ignite.ml.math.exceptions.math.CardinalityException) SparseVector(org.apache.ignite.ml.math.primitives.vector.impl.SparseVector) DenseVector(org.apache.ignite.ml.math.primitives.vector.impl.DenseVector) MathIllegalArgumentException(org.apache.ignite.ml.math.exceptions.math.MathIllegalArgumentException)

Aggregations

CardinalityException (org.apache.ignite.ml.math.exceptions.math.CardinalityException)1 MathIllegalArgumentException (org.apache.ignite.ml.math.exceptions.math.MathIllegalArgumentException)1 NonSquareMatrixException (org.apache.ignite.ml.math.exceptions.math.NonSquareMatrixException)1 DenseVector (org.apache.ignite.ml.math.primitives.vector.impl.DenseVector)1 SparseVector (org.apache.ignite.ml.math.primitives.vector.impl.SparseVector)1