quimb.linalg.numpy_linalg

Numpy base linear algebra.

Attributes

Functions

eig_numpy(A[, sort, isherm, return_vecs, autoblock])

Numpy based dense eigensolve.

sort_inds(a, method[, sigma])

Return the sorting inds of a list

eigs_numpy(A, k[, B, which, return_vecs, sigma, ...])

Partial eigen-decomposition using numpy's dense linear algebra.

svds_numpy(a, k[, return_vecs])

Partial singular value decomposition using numpys (full) singular value

Module Contents

quimb.linalg.numpy_linalg._NUMPY_EIG_FUNCS
quimb.linalg.numpy_linalg.eig_numpy(A, sort=True, isherm=True, return_vecs=True, autoblock=False)[source]

Numpy based dense eigensolve.

Parameters:
  • A (array_like) – The operator to decompose.

  • sort (bool, optional) – Whether to sort into ascending order.

  • isherm (bool, optional) – Whether A is hermitian.

  • return_vecs (bool, optional) – Whether to return the eigenvectors.

  • autoblock (bool, optional) – If true, automatically identify and exploit symmetries appearing in the current basis as block diagonals formed via permutation of rows and columns.

Returns:

  • evals (1D-array) – The eigenvalues.

  • evecs (qarray) – If return_vecs=True, the eigenvectors.

quimb.linalg.numpy_linalg.sort_inds(a, method, sigma=None)[source]

Return the sorting inds of a list

Parameters:
  • a (array_like) – List to base sort on.

  • method (str) –

    Method of sorting list, one of
    • ”LM” - Largest magnitude first

    • ”SM” - Smallest magnitude first

    • ”SA” - Smallest algebraic first

    • ”SR” - Smallest real part first

    • ”SI” - Smallest imaginary part first

    • ”LA” - Largest algebraic first

    • ”LR” - Largest real part first

    • ”LI” - Largest imaginary part first

    • ”TM” - Magnitude closest to target sigma first

    • ”TR” - Real part closest to target sigma first

    • ”TI” - Imaginary part closest to target sigma first

  • sigma (float, optional) – The target if method={“TM”, “TR”, or “TI”}.

Returns:

inds – Indices that would sort a based on method

Return type:

array of int

quimb.linalg.numpy_linalg._DENSE_EIG_METHODS
quimb.linalg.numpy_linalg.eigs_numpy(A, k, B=None, which=None, return_vecs=True, sigma=None, isherm=True, P=None, sort=True, **eig_opts)[source]

Partial eigen-decomposition using numpy’s dense linear algebra.

Parameters:
  • A (array_like or quimb.Lazy) – Operator to partially eigen-decompose.

  • k (int) – Number of eigenpairs to return.

  • B (array_like or quimb.Lazy) – If given, the RHS operator defining a generalized eigen problem.

  • which (str, optional) – Which part of the spectrum to target.

  • return_vecs (bool, optional) – Whether to return eigenvectors.

  • sigma (None or float, optional) – Target eigenvalue.

  • isherm (bool, optional) – Whether a is hermitian.

  • P (array_like or quimb.Lazy) – Perform the eigensolve in the subspace defined by this projector.

  • sort (bool, optional) – Whether to sort reduced list of eigenpairs into ascending order.

  • eig_opts – Settings to pass to numpy.eig… functions.

Returns:

lk, (vk)

Return type:

k eigenvalues (and eigenvectors) sorted according to which

quimb.linalg.numpy_linalg.svds_numpy(a, k, return_vecs=True, **_)[source]

Partial singular value decomposition using numpys (full) singular value decomposition.

Parameters:
  • a (array_like) – Operator to decompose.

  • k (int, optional) – Number of singular value triplets to retrieve.

  • return_vecs (bool, optional) – whether to return the computed vecs or values only

Returns:

Singlar value triplets.

Return type:

(uk,) sk (, vkt)