factorize#

AnsSolver.factorize(mat, algo=None, inplace=True)#

Factorize a matrix.

Perform the numerical factorization of a linear solver system: (\(A*x=b\)).

Warning

By default, factorization modifies the input matrix mat in place. This behavior can be changed using the inplace parameter.

Parameters:
matAnsMat

AnsMath matrix.

algostr, optional

Factorization algorithm. Options are "LAPACK" and "DSP". The default is "LAPACK" for dense matrices and "DSP" for sparse matrices.

inplacebool, optional

Whether the factorization is performed on the input matrix rather than on a copy of this matrix. Performing factorization on a copy of this matrix would result in no changes to the input matrix. The default is True.

Examples

Factorize a random matrix and solve a linear system.

>>> dim = 1000
>>> m2 = mm.rand(dim, dim)
>>> solver = mm.factorize(m2)
>>> b = mm.ones(dim)
>>> x = solver.solve(b)