# Matrix¶

The matrix module defines a number of 2D matrix objects, notably the SparseMatrix() and DenseMatrix(). Matrix objects support indexed addition, basic addition and subtraction operations, and provide a consistent insterface for solving linear systems. Matrices can be converted to numpy arrays via asarray.

nutils.matrix.krylov(matvec, b, x0=None, tol=1e-05, restart=None, maxiter=0, precon=None, callback=None)[source]

solve linear system iteratively

restart=None: CG restart=integer: GMRES

nutils.matrix.parsecons(constrain, lconstrain, rconstrain, shape)[source]

parse constraints

class nutils.matrix.Matrix((nrows, ncols))[source]

matrix base class

cond(constrain=None, lconstrain=None, rconstrain=None)[source]

condition number

res(x, b=0, constrain=None, lconstrain=None, rconstrain=None)[source]

residual

class nutils.matrix.DenseSubMatrix(data, indices)[source]

dense but non-contiguous data

class nutils.matrix.SparseMatrix(graph, ncols=None)[source]

sparse matrix

reshape((nrows, ncols))[source]

reshape matrix

clone()[source]

clone matrix

matvec(other)[source]

matrix-vector multiplication

T[source]

transpose

toarray()[source]

convert to numpy array

todense()[source]

convert to dense matrix

rowsupp(tol=0)[source]

return row indices with nonzero/non-small entries

solve(b=0, constrain=None, lconstrain=None, rconstrain=None, tol=0, x0=None, symmetric=False, maxiter=0, restart=999, title='solving system', callback=None, precon=None)[source]
class nutils.matrix.DenseMatrix(shape)[source]

matrix wrapper class

clone()[source]

clone matrix

toarray()[source]

convert to numpy array

matvec(other)[source]

matrix-vector multiplication

T[source]

transpose

solve(b=0, constrain=None, lconstrain=None, rconstrain=None, title='solving system', **dummy)[source]