pyamg.util#

Utility functions. linalg.py provides some linear algebra functionality not yet found in scipy.

utils.py provides some utility functions for use with pyamg

bsr_utils.py provides utility functions for accessing and writing individual rows of BSR matrices

pyamg.util.make_system(A, M, x0, b)[source]#

Make a linear system Ax=b

Parameters:
ALinearOperator

sparse or dense matrix (or any valid input to aslinearoperator)

M{LinearOperator, Nones}

preconditioner sparse or dense matrix (or any valid input to aslinearoperator)

x0{array_like, str, None}

initial guess to iterative method. x0 = 'Mb' means using the nonzero initial guess M @ b. Default is None, which means using the zero initial guess.

barray_like

right hand side

Returns:
(A, M, x, b, postprocess)
ALinearOperator

matrix of the linear system

MLinearOperator

preconditioner

xrank 1 ndarray

initial guess

brank 1 ndarray

right hand side

postprocessfunction

converts the solution vector to the appropriate type and dimensions (e.g. (N,1) matrix)

pyamg.util.upcast(*args)[source]#

Returns the nearest supported sparse dtype for the combination of one or more types.

upcast(t0, t1, …, tn) -> T where T is a supported dtype

Examples

>>> from scipy.sparse._sputils import upcast
>>> upcast('int32')
<type 'numpy.int32'>
>>> upcast('bool')
<type 'numpy.bool_'>
>>> upcast('int32','float32')
<type 'numpy.float64'>
>>> upcast('bool',complex,float)
<type 'numpy.complex128'>