SuiteSparseMatrix

class probnum.problems.zoo.linalg.SuiteSparseMatrix(matid, group, name, nnz, is2d3d, isspd, psym, nsym, kind)

Bases: probnum.linops.MatrixMult

SuiteSparse Matrix.

Sparse matrix from the SuiteSparse Matrix Collection. 1 2

Parameters
  • matid (str) – Unique identifier for the matrix in the database.

  • group (str) – Group this matrix belongs to.

  • name (str) – Name of this matrix.

  • nnz (int) – Number of non-zero elements.

  • is2d3d (bool) – Does this matrix come from a 2D or 3D discretization?

  • isspd (bool) – Is this matrix symmetric, positive definite?

  • psym (float) – Degree of symmetry of the matrix pattern.

  • nsym (float) – Degree of numerical symmetry of the matrix.

  • kind (str) – Information of the problem domain this matrix arises from.

References

1

Davis, TA and Hu, Y. The University of Florida sparse matrix collection. ACM Transactions on Mathematical Software (TOMS) 38.1 ( 2011): 1-25.

2

Kolodziej, Scott P., et al. The SuiteSparse matrix collection website interface. Journal of Open Source Software 4.35 (2019): 1244.

Attributes Summary

H

Hermitian adjoint.

T

Transpose this linear operator.

ndim

Methods Summary

__call__(x)

Call self as a function.

adjoint()

Hermitian adjoint.

cond([p])

Compute the condition number of the linear operator.

det()

Determinant of the linear operator.

dot(x)

Matrix-matrix or matrix-vector multiplication.

eigvals()

Eigenvalue spectrum of the linear operator.

from_database_entry(database_entry)

Create a SuiteSparseMatrix object from an entry of the database index.

inv()

Inverse of the linear operator.

logabsdet()

Log absolute determinant of the linear operator.

matmat(X)

Matrix-matrix multiplication.

matvec(x)

Matrix-vector multiplication.

rank()

Rank of the linear operator.

rmatmat(X)

Adjoint matrix-matrix multiplication.

rmatvec(x)

Adjoint matrix-vector multiplication.

todense()

Dense matrix representation of the linear operator.

trace()

Trace of the linear operator.

transpose()

Transpose this linear operator.

Attributes Documentation

H

Hermitian adjoint.

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Can be abbreviated self.H instead of self.adjoint().

Returns

A_H – Hermitian adjoint of self.

Return type

LinearOperator

T
ndim = 2

Methods Documentation

__call__(x)

Call self as a function.

adjoint()

Hermitian adjoint.

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Can be abbreviated self.H instead of self.adjoint().

Returns

A_H – Hermitian adjoint of self.

Return type

LinearOperator

cond(p=None)

Compute the condition number of the linear operator.

The condition number of the linear operator with respect to the p norm. It measures how much the solution \(x\) of the linear system \(Ax=b\) changes with respect to small changes in \(b\).

Parameters

p ({None, 1, , 2, , inf, 'fro'}, optional) –

Order of the norm:

p

norm for matrices

None

2-norm, computed directly via singular value decomposition

’fro’

Frobenius norm

np.inf

max(sum(abs(x), axis=1))

1

max(sum(abs(x), axis=0))

2

2-norm (largest sing. value)

Returns

cond – The condition number of the linear operator. May be infinite.

Return type

{float, inf}

det()

Determinant of the linear operator.

dot(x)

Matrix-matrix or matrix-vector multiplication.

Parameters

x (array_like) – 1-d or 2-d array, representing a vector or matrix.

Returns

Ax – 1-d or 2-d array (depending on the shape of x) that represents the result of applying this linear operator on x.

Return type

array

eigvals()

Eigenvalue spectrum of the linear operator.

classmethod from_database_entry(database_entry)[source]

Create a SuiteSparseMatrix object from an entry of the database index.

Parameters

database_entry (Dict) – Dictionary representing one entry from the SuiteSparse database index.

Return type

SuiteSparseMatrix

inv()

Inverse of the linear operator.

logabsdet()

Log absolute determinant of the linear operator.

matmat(X)

Matrix-matrix multiplication.

Performs the operation y=A*X where A is an MxN linear operator and X dense N*K matrix or ndarray.

Parameters

X ({matrix, ndarray}) – An array with shape (N,K).

Returns

Y – A matrix or ndarray with shape (M,K) depending on the type of the X argument.

Return type

{matrix, ndarray}

Notes

This matmat wraps any user-specified matmat routine or overridden _matmat method to ensure that y has the correct type.

matvec(x)

Matrix-vector multiplication. Performs the operation y=A*x where A is an MxN linear operator and x is a 1-d array or random variable.

Parameters

x ({matrix, ndarray, RandomVariable}) – An array or RandomVariable with shape (N,) or (N,1).

Returns

y – A matrix or ndarray or RandomVariable with shape (M,) or (M,1) depending on the type and shape of the x argument.

Return type

{matrix, ndarray}

Notes

This matvec wraps the user-specified matvec routine or overridden _matvec method to ensure that y has the correct shape and type.

rank()

Rank of the linear operator.

rmatmat(X)

Adjoint matrix-matrix multiplication.

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array, or 2-d array. The default implementation defers to the adjoint.

Parameters

X ({matrix, ndarray}) – A matrix or 2D array.

Returns

Y – A matrix or 2D array depending on the type of the input.

Return type

{matrix, ndarray}

Notes

This rmatmat wraps the user-specified rmatmat routine.

rmatvec(x)

Adjoint matrix-vector multiplication.

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array.

Parameters

x ({matrix, ndarray}) – An array with shape (M,) or (M,1).

Returns

y – A matrix or ndarray with shape (N,) or (N,1) depending on the type and shape of the x argument.

Return type

{matrix, ndarray}

Notes

This rmatvec wraps the user-specified rmatvec routine or overridden _rmatvec method to ensure that y has the correct shape and type.

todense()

Dense matrix representation of the linear operator.

This method can be computationally very costly depending on the shape of the linear operator. Use with caution.

Returns

matrix – Matrix representation of the linear operator.

Return type

np.ndarray

trace()

Trace of the linear operator.

Computes the trace of a square linear operator \(\text{tr}(A) = \sum_{i-1}^n A_ii\).

Returns

trace – Trace of the linear operator.

Return type

float

:raises ValueError : If trace() is called on a non-square matrix.:

transpose()

Transpose this linear operator.

Can be abbreviated self.T instead of self.transpose().

Return type

LinearOperator