Search in sources :

Example 1 with NonSquareMatrixException

use of org.apache.ignite.ml.math.exceptions.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, DenseLocalOnHeapMatrix 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 DenseLocalOnHeapVector)
        syr(alpha, x, a);
    else if (x instanceof SparseLocalVector)
        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.NonSquareMatrixException) DenseLocalOnHeapVector(org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector) CardinalityException(org.apache.ignite.ml.math.exceptions.CardinalityException) SparseLocalVector(org.apache.ignite.ml.math.impls.vector.SparseLocalVector) MathIllegalArgumentException(org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException)

Aggregations

CardinalityException (org.apache.ignite.ml.math.exceptions.CardinalityException)1 MathIllegalArgumentException (org.apache.ignite.ml.math.exceptions.MathIllegalArgumentException)1 NonSquareMatrixException (org.apache.ignite.ml.math.exceptions.NonSquareMatrixException)1 DenseLocalOnHeapVector (org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector)1 SparseLocalVector (org.apache.ignite.ml.math.impls.vector.SparseLocalVector)1