Method: FastMatrix::Matrix::LUPDecomposition#solve

Defined in:
ext/fast_matrix/LUPDecomposition/lup.c

#solve(mtrx) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'ext/fast_matrix/LUPDecomposition/lup.c', line 97

VALUE lup_solve(VALUE self, VALUE mtrx)
{
    raise_check_rbasic(mtrx, cMatrix, "matrix");
	struct lupdecomposition* lp = get_lup_from_rb_value(self);
	struct matrix* M = get_matrix_from_rb_value(mtrx);
    if(lp->singular)
        rb_raise(fm_eIndexError, "Matrix is singular");
    if(lp->n != M->n)
        rb_raise(fm_eIndexError, "Columns of different size");

    MAKE_MATRIX_AND_RB_VALUE(C, result, M->m, lp->n);
    c_lup_solve(M->m, lp->n, lp->data, M->data, lp->permutation, C->data);
    return result;
}