Python API

This section provides the auto-generated API for the Python modules pymatrixid and pymatrixid.backend. The functions in pymatrixid.backend are wrappers for the routines of the same name in the Fortran ID software package; for details, please consult the Fortran source code (in external/id_dist/src).

pymatrixid

Python module for interfacing with id_dist.

pymatrixid.estimate_rank(A, eps)

Estimate matrix rank to a specified relative precision using randomized methods.

The matrix A can be given as either a numpy.ndarray or a scipy.sparse.linalg.LinearOperator, with different algorithms used for each case. If A is of type numpy.ndarray, then the output rank is typically about 8 higher than the actual numerical rank.

This function automatically detects the form of the input parameters and passes them to the appropriate backend. For details, see backend.idd_estrank(), backend.idd_findrank(), backend.idz_estrank(), and backend.idz_findrank().

Parameters:
Returns:

Estimated matrix rank.

Return type:

int

pymatrixid.estimate_spectral_norm(A, its=20)

Estimate spectral norm of a matrix by the randomized power method.

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_snorm() and backend.idz_snorm().

Parameters:
Returns:

Spectral norm estimate.

Return type:

float

pymatrixid.estimate_spectral_norm_diff(A, B, its=20)

Estimate spectral norm of the difference of two matrices by the randomized power method.

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_diffsnorm() and backend.idz_diffsnorm().

Parameters:
Returns:

Spectral norm estimate of matrix difference.

Return type:

float

pymatrixid.id_to_svd(B, idx, proj)

Convert ID to SVD.

The SVD reconstruction of a matrix with skeleton matrix B and ID indices and coefficients idx and proj, respectively, is:

U, S, V = id_to_svd(B, idx, proj)
A = numpy.dot(U, numpy.dot(numpy.diag(S), V.conj().T))

See also svd().

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_id2svd() and backend.idz_id2svd().

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

pymatrixid.interp_decomp(A, eps_or_k, rand=True)

Compute ID of a matrix.

An ID of a matrix A is a factorization defined by a rank k, a column index array idx, and interpolation coefficients proj such that:

numpy.dot(A[:,idx[:k]], proj) = A[:,idx[k:]]

The original matrix can then be reconstructed as:

numpy.hstack([A[:,idx[:k]],
              numpy.dot(A[:,idx[:k]], proj)]
            )[:,numpy.argsort(idx)]

or via the routine reconstruct_matrix_from_id(). This can equivalently be written as:

numpy.dot(A[:,idx[:k]],
          numpy.hstack([numpy.eye(k), proj])
         )[:,np.argsort(idx)]

in terms of the skeleton and interpolation matrices:

B = A[:,idx[:k]]

and:

P = numpy.hstack([numpy.eye(k), proj])[:,np.argsort(idx)]

respectively. See also reconstruct_interp_matrix() and reconstruct_skel_matrix().

The ID can be computed to any relative precision or rank (depending on the value of eps_or_k). If a precision is specified (eps_or_k < 1), then this function has the output signature:

k, idx, proj = interp_decomp(A, eps_or_k)

Otherwise, if a rank is specified (eps_or_k >= 1), then the output signature is:

idx, proj = interp_decomp(A, eps_or_k)

This function automatically detects the form of the input parameters and passes them to the appropriate backend. For details, see backend.iddp_id(), backend.iddp_aid(), backend.iddp_rid(), backend.iddr_id(), backend.iddr_aid(), backend.iddr_rid(), backend.idzp_id(), backend.idzp_aid(), backend.idzp_rid(), backend.idzr_id(), backend.idzr_aid(), and backend.idzr_rid().

Parameters:
Returns:

Rank required to achieve specified relative precision if eps_or_k < 1.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.rand(*args)

Generate standard uniform pseudorandom numbers via a very efficient lagged Fibonacci method.

This routine is used for all random number generation in this package and can affect ID and SVD results.

Several call signatures are available:

  • If no arguments are given, then the seed values are reset to their original values.
  • If an integer n is given as input, then an array of n pseudorandom numbers are returned.
  • If an array s of 55 values is given as input, then the seed values are set to s.

For details, see backend.id_srand(), backend.id_srandi(), and backend.id_srando().

pymatrixid.reconstruct_interp_matrix(idx, proj)

Reconstruct interpolation matrix from ID.

The interpolation matrix can be reconstructed from the ID indices and coefficients idx and proj, respectively, as:

P = numpy.hstack([numpy.eye(proj.shape[0]), proj])[:,numpy.argsort(idx)]

The original matrix can then be reconstructed from its skeleton matrix B via:

numpy.dot(B, P)

See also reconstruct_matrix_from_id() and reconstruct_skel_matrix().

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_reconint() and backend.idz_reconint().

Parameters:
Returns:

Interpolation matrix.

Return type:

numpy.ndarray

pymatrixid.reconstruct_matrix_from_id(B, idx, proj)

Reconstruct matrix from its ID.

A matrix A with skeleton matrix B and ID indices and coefficients idx and proj, respectively, can be reconstructed as:

numpy.hstack([B, numpy.dot(B, proj)])[:,numpy.argsort(idx)]

See also reconstruct_interp_matrix() and reconstruct_skel_matrix().

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_reconid() and backend.idz_reconid().

Parameters:
Returns:

Reconstructed matrix.

Return type:

numpy.ndarray

pymatrixid.reconstruct_skel_matrix(A, k, idx)

Reconstruct skeleton matrix from ID.

The skeleton matrix can be reconstructed from the original matrix A and its ID rank and indices k and idx, respectively, as:

B = A[:,idx[:k]]

The original matrix can then be reconstructed via:

numpy.hstack([B, numpy.dot(B, proj)])[:,numpy.argsort(idx)]

See also reconstruct_matrix_from_id() and reconstruct_interp_matrix().

This function automatically detects the matrix data type and calls the appropriate backend. For details, see backend.idd_copycols() and backend.idz_copycols().

Parameters:
Returns:

Skeleton matrix.

Return type:

numpy.ndarray

pymatrixid.svd(A, eps_or_k, rand=True)

Compute SVD of a matrix via an ID.

An SVD of a matrix A is a factorization:

A = numpy.dot(U, numpy.dot(numpy.diag(S), V.conj().T))

where U and V have orthonormal columns and S is nonnegative.

The SVD can be computed to any relative precision or rank (depending on the value of eps_or_k).

See also interp_decomp() and id_to_svd().

This function automatically detects the form of the input parameters and passes them to the appropriate backend. For details, see backend.iddp_svd(), backend.iddp_asvd(), backend.iddp_rsvd(), backend.iddr_svd(), backend.iddr_asvd(), backend.iddr_rsvd(), backend.idzp_svd(), backend.idzp_asvd(), backend.idzp_rsvd(), backend.idzr_svd(), backend.idzr_asvd(), and backend.idzr_rsvd().

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

pymatrixid.backend

Direct wrappers for Fortran id_dist backend.

pymatrixid.backend.id_srand(n)

Generate standard uniform pseudorandom numbers via a very efficient lagged Fibonacci method.

Parameters:n (int) – Number of pseudorandom numbers to generate.
Returns:Pseudorandom numbers.
Return type:numpy.ndarray
pymatrixid.backend.id_srandi(t)

Initialize seed values for id_srand() (any appropriately random numbers will do).

Parameters:t (numpy.ndarray) – Array of 55 seed values.
pymatrixid.backend.id_srando()

Reset seed values to their original values.

pymatrixid.backend.idd_copycols(A, k, idx)

Reconstruct skeleton matrix from real ID.

Parameters:
Returns:

Skeleton matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idd_diffsnorm(m, n, matvect, matvect2, matvec, matvec2, its=20)

Estimate spectral norm of the difference of two real matrices by the randomized power method.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the transpose of the first matrix to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
  • matvect2 (function) – Function to apply the transpose of the second matrix to a vector, with call signature y = matvect2(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the first matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • matvec2 (function) – Function to apply the second matrix to a vector, with call signature y = matvec2(x), where x and y are the input and output vectors, respectively.
  • its (int) – Number of power method iterations.
Returns:

Spectral norm estimate of matrix difference.

Return type:

float

pymatrixid.backend.idd_estrank(eps, A)

Estimate rank of a real matrix to a specified relative precision using random sampling.

The output rank is typically about 8 higher than the actual rank.

Parameters:
Returns:

Rank estimate.

Return type:

int

pymatrixid.backend.idd_findrank(eps, m, n, matvect)

Estimate rank of a real matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
Returns:

Rank estimate.

Return type:

int

pymatrixid.backend.idd_frm(n, w, x)

Transform real vector via a composition of Rokhlin’s random transform, random subselection, and an FFT.

In contrast to idd_sfrm(), this routine works best when the length of the transformed vector is the power-of-two integer output by idd_frmi(), or when the length is not specified but instead determined a posteriori from the output. The returned transformed vector is randomly permuted.

Parameters:
  • n (int) – Greatest power-of-two integer satisfying n <= x.size as obtained from idd_frmi(); n is also the length of the output vector.
  • w (numpy.ndarray) – Initialization array constructed by idd_frmi().
  • x (numpy.ndarray) – Vector to be transformed.
Returns:

Transformed vector.

Return type:

numpy.ndarray

pymatrixid.backend.idd_frmi(m)

Initialize data for idd_frm().

Parameters:m (int) – Length of vector to be transformed.
Returns:Greatest power-of-two integer n satisfying n <= m.
Return type:int
Returns:Initialization array to be used by idd_frm().
Return type:numpy.ndarray
pymatrixid.backend.idd_id2svd(B, idx, proj)

Convert real ID to SVD.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idd_reconid(B, idx, proj)

Reconstruct matrix from real ID.

Parameters:
Returns:

Reconstructed matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idd_reconint(idx, proj)

Reconstruct interpolation matrix from real ID.

Parameters:
Returns:

Interpolation matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idd_sfrm(l, n, w, x)

Transform real vector via a composition of Rokhlin’s random transform, random subselection, and an FFT.

In contrast to idd_frm(), this routine works best when the length of the transformed vector is known a priori.

Parameters:
  • l (int) – Length of transformed vector, satisfying l <= n.
  • n (int) – Greatest power-of-two integer satisfying n <= x.size as obtained from idd_sfrmi().
  • w (numpy.ndarray) – Initialization array constructed by idd_sfrmi().
  • x (numpy.ndarray) – Vector to be transformed.
Returns:

Transformed vector.

Return type:

numpy.ndarray

pymatrixid.backend.idd_sfrmi(l, m)

Initialize data for idd_sfrm().

Parameters:
  • l (int) – Length of output transformed vector.
  • m (int) – Length of the vector to be transformed.
Returns:

Greatest power-of-two integer n satisfying n <= m.

Return type:

int

Returns:

Initialization array to be used by idd_sfrm().

Return type:

numpy.ndarray

pymatrixid.backend.idd_snorm(m, n, matvect, matvec, its=20)

Estimate spectral norm of a real matrix by the randomized power method.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • its (int) – Number of power method iterations.
Returns:

Spectral norm estimate.

Return type:

float

pymatrixid.backend.iddp_aid(eps, A)

Compute ID of a real matrix to a specified relative precision using random sampling.

Parameters:
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddp_asvd(eps, A)

Compute SVD of a real matrix to a specified relative precision using random sampling.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.iddp_id(eps, A)

Compute ID of a real matrix to a specified relative precision.

Parameters:
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddp_rid(eps, m, n, matvect)

Compute ID of a real matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddp_rsvd(eps, m, n, matvect, matvec)

Compute SVD of a real matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.iddp_svd(eps, A)

Compute SVD of a real matrix to a specified relative precision.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_aid(A, k)

Compute ID of a real matrix to a specified rank using random sampling.

Parameters:
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_aidi(m, n, k)

Initialize array for iddr_aid().

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • k (int) – Rank of ID.
Returns:

Initialization array to be used by iddr_aid().

Return type:

numpy.ndarray

pymatrixid.backend.iddr_asvd(A, k)

Compute SVD of a real matrix to a specified rank using random sampling.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_id(A, k)

Compute ID of a real matrix to a specified rank.

Parameters:
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_rid(m, n, matvect, k)

Compute ID of a real matrix to a specified rank using random matrix-vector multiplication.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
  • k (int) – Rank of ID.
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_rsvd(m, n, matvect, matvec, k)

Compute SVD of a real matrix to a specified rank using random matrix-vector multiplication.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matvect (function) – Function to apply the matrix transpose to a vector, with call signature y = matvect(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • k (int) – Rank of SVD.
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.iddr_svd(A, k)

Compute SVD of a real matrix to a specified rank.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idz_copycols(A, k, idx)

Reconstruct skeleton matrix from complex ID.

Parameters:
Returns:

Skeleton matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idz_diffsnorm(m, n, matveca, matveca2, matvec, matvec2, its=20)

Estimate spectral norm of the difference of two complex matrices by the randomized power method.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the adjoint of the first matrix to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
  • matveca2 (function) – Function to apply the adjoint of the second matrix to a vector, with call signature y = matveca2(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the first matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • matvec2 (function) – Function to apply the second matrix to a vector, with call signature y = matvec2(x), where x and y are the input and output vectors, respectively.
  • its (int) – Number of power method iterations.
Returns:

Spectral norm estimate of matrix difference.

Return type:

float

pymatrixid.backend.idz_estrank(eps, A)

Estimate rank of a complex matrix to a specified relative precision using random sampling.

The output rank is typically about 8 higher than the actual rank.

Parameters:
Returns:

Rank estimate.

Return type:

int

pymatrixid.backend.idz_findrank(eps, m, n, matveca)

Estimate rank of a complex matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
Returns:

Rank estimate.

Return type:

int

pymatrixid.backend.idz_frm(n, w, x)

Transform complex vector via a composition of Rokhlin’s random transform, random subselection, and an FFT.

In contrast to idz_sfrm(), this routine works best when the length of the transformed vector is the power-of-two integer output by idz_frmi(), or when the length is not specified but instead determined a posteriori from the output. The returned transformed vector is randomly permuted.

Parameters:
  • n (int) – Greatest power-of-two integer satisfying n <= x.size as obtained from idz_frmi(); n is also the length of the output vector.
  • w (numpy.ndarray) – Initialization array constructed by idz_frmi().
  • x (numpy.ndarray) – Vector to be transformed.
Returns:

Transformed vector.

Return type:

numpy.ndarray

pymatrixid.backend.idz_frmi(m)

Initialize data for idz_frm().

Parameters:m (int) – Length of vector to be transformed.
Returns:Greatest power-of-two integer n satisfying n <= m.
Return type:int
Returns:Initialization array to be used by idz_frm().
Return type:numpy.ndarray
pymatrixid.backend.idz_id2svd(B, idx, proj)

Convert complex ID to SVD.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idz_reconid(B, idx, proj)

Reconstruct matrix from complex ID.

Parameters:
Returns:

Reconstructed matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idz_reconint(idx, proj)

Reconstruct interpolation matrix from complex ID.

Parameters:
Returns:

Interpolation matrix.

Return type:

numpy.ndarray

pymatrixid.backend.idz_sfrm(l, n, w, x)

Transform complex vector via a composition of Rokhlin’s random transform, random subselection, and an FFT.

In contrast to idz_frm(), this routine works best when the length of the transformed vector is known a priori.

Parameters:
  • l (int) – Length of transformed vector, satisfying l <= n.
  • n (int) – Greatest power-of-two integer satisfying n <= x.size as obtained from idz_sfrmi().
  • w (numpy.ndarray) – Initialization array constructed by idd_sfrmi().
  • x (numpy.ndarray) – Vector to be transformed.
Returns:

Transformed vector.

Return type:

numpy.ndarray

pymatrixid.backend.idz_sfrmi(l, m)

Initialize data for idz_sfrm().

Parameters:
  • l (int) – Length of output transformed vector.
  • m (int) – Length of the vector to be transformed.
Returns:

Greatest power-of-two integer n satisfying n <= m.

Return type:

int

Returns:

Initialization array to be used by idz_sfrm().

Return type:

numpy.ndarray

pymatrixid.backend.idz_snorm(m, n, matveca, matvec, its=20)

Estimate spectral norm of a complex matrix by the randomized power method.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • its (int) – Number of power method iterations.
Returns:

Spectral norm estimate.

Return type:

float

pymatrixid.backend.idzp_aid(eps, A)

Compute ID of a complex matrix to a specified relative precision using random sampling.

Parameters:
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzp_asvd(eps, A)

Compute SVD of a complex matrix to a specified relative precision using random sampling.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idzp_id(eps, A)

Compute ID of a complex matrix to a specified relative precision.

Parameters:
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzp_rid(eps, m, n, matveca)

Compute ID of a complex matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
Returns:

Rank of ID.

Return type:

int

Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzp_rsvd(eps, m, n, matveca, matvec)

Compute SVD of a complex matrix to a specified relative precision using random matrix-vector multiplication.

Parameters:
  • eps (float) – Relative precision.
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idzp_svd(eps, A)

Compute SVD of a complex matrix to a specified relative precision.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_aid(A, k)

Compute ID of a complex matrix to a specified rank using random sampling.

Parameters:
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_aidi(m, n, k)

Initialize array for idzr_aid().

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • k (int) – Rank of ID.
Returns:

Initialization array to be used by idzr_aid().

Return type:

numpy.ndarray

pymatrixid.backend.idzr_asvd(A, k)

Compute SVD of a complex matrix to a specified rank using random sampling.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_id(A, k)

Compute ID of a complex matrix to a specified rank.

Parameters:
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_rid(m, n, matveca, k)

Compute ID of a complex matrix to a specified rank using random matrix-vector multiplication.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
  • k (int) – Rank of ID.
Returns:

Column index array.

Return type:

numpy.ndarray

Returns:

Interpolation coefficients.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_rsvd(m, n, matveca, matvec, k)

Compute SVD of a complex matrix to a specified rank using random matrix-vector multiplication.

Parameters:
  • m (int) – Matrix row dimension.
  • n (int) – Matrix column dimension.
  • matveca (function) – Function to apply the matrix adjoint to a vector, with call signature y = matveca(x), where x and y are the input and output vectors, respectively.
  • matvec (function) – Function to apply the matrix to a vector, with call signature y = matvec(x), where x and y are the input and output vectors, respectively.
  • k (int) – Rank of SVD.
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

pymatrixid.backend.idzr_svd(A, k)

Compute SVD of a complex matrix to a specified rank.

Parameters:
Returns:

Left singular vectors.

Return type:

numpy.ndarray

Returns:

Right singular vectors.

Return type:

numpy.ndarray

Returns:

Singular values.

Return type:

numpy.ndarray

Table Of Contents

Previous topic

Tutorial

This Page