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).
Python module for interfacing with id_dist.
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 |
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 |
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 |
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: | |
Returns: | Singular values. |
Return type: | |
Returns: | Right singular vectors. |
Return type: |
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: | |
Returns: | Interpolation coefficients. |
Return type: |
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:
For details, see backend.id_srand(), backend.id_srandi(), and backend.id_srando().
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: |
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: |
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: |
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: | |
Returns: | Singular values. |
Return type: | |
Returns: | Right singular vectors. |
Return type: |
Direct wrappers for Fortran id_dist backend.
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 |
Initialize seed values for id_srand() (any appropriately random numbers will do).
Parameters: | t (numpy.ndarray) – Array of 55 seed values. |
---|
Reset seed values to their original values.
Reconstruct skeleton matrix from real ID.
Parameters: |
|
---|---|
Returns: | Skeleton matrix. |
Return type: |
Estimate spectral norm of the difference of two real matrices by the randomized power method.
Parameters: |
|
---|---|
Returns: | Spectral norm estimate of matrix difference. |
Return type: | float |
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 |
Estimate rank of a real matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Rank estimate. |
Return type: | int |
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: |
|
---|---|
Returns: | Transformed vector. |
Return type: |
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 |
Convert real ID to SVD.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Reconstruct matrix from real ID.
Parameters: |
|
---|---|
Returns: | Reconstructed matrix. |
Return type: |
Reconstruct interpolation matrix from real ID.
Parameters: |
|
---|---|
Returns: | Interpolation matrix. |
Return type: |
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: |
|
---|---|
Returns: | Transformed vector. |
Return type: |
Initialize data for idd_sfrm().
Parameters: | |
---|---|
Returns: | Greatest power-of-two integer n satisfying n <= m. |
Return type: | int |
Returns: | Initialization array to be used by idd_sfrm(). |
Return type: |
Estimate spectral norm of a real matrix by the randomized power method.
Parameters: |
|
---|---|
Returns: | Spectral norm estimate. |
Return type: | float |
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: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a real matrix to a specified relative precision using random sampling.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
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: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute ID of a real matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Rank of ID. |
Return type: | int |
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a real matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute SVD of a real matrix to a specified relative precision.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute ID of a real matrix to a specified rank using random sampling.
Parameters: |
|
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Initialize array for iddr_aid().
Parameters: | |
---|---|
Returns: | Initialization array to be used by iddr_aid(). |
Return type: |
Compute SVD of a real matrix to a specified rank using random sampling.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute ID of a real matrix to a specified rank.
Parameters: |
|
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute ID of a real matrix to a specified rank using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a real matrix to a specified rank using random matrix-vector multiplication.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute SVD of a real matrix to a specified rank.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Reconstruct skeleton matrix from complex ID.
Parameters: |
|
---|---|
Returns: | Skeleton matrix. |
Return type: |
Estimate spectral norm of the difference of two complex matrices by the randomized power method.
Parameters: |
|
---|---|
Returns: | Spectral norm estimate of matrix difference. |
Return type: | float |
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 |
Estimate rank of a complex matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Rank estimate. |
Return type: | int |
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: |
|
---|---|
Returns: | Transformed vector. |
Return type: |
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 |
Convert complex ID to SVD.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Reconstruct matrix from complex ID.
Parameters: |
|
---|---|
Returns: | Reconstructed matrix. |
Return type: |
Reconstruct interpolation matrix from complex ID.
Parameters: |
|
---|---|
Returns: | Interpolation matrix. |
Return type: |
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: |
|
---|---|
Returns: | Transformed vector. |
Return type: |
Initialize data for idz_sfrm().
Parameters: | |
---|---|
Returns: | Greatest power-of-two integer n satisfying n <= m. |
Return type: | int |
Returns: | Initialization array to be used by idz_sfrm(). |
Return type: |
Estimate spectral norm of a complex matrix by the randomized power method.
Parameters: |
|
---|---|
Returns: | Spectral norm estimate. |
Return type: | float |
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: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a complex matrix to a specified relative precision using random sampling.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
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: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute ID of a complex matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Rank of ID. |
Return type: | int |
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a complex matrix to a specified relative precision using random matrix-vector multiplication.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute SVD of a complex matrix to a specified relative precision.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute ID of a complex matrix to a specified rank using random sampling.
Parameters: |
|
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Initialize array for idzr_aid().
Parameters: | |
---|---|
Returns: | Initialization array to be used by idzr_aid(). |
Return type: |
Compute SVD of a complex matrix to a specified rank using random sampling.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute ID of a complex matrix to a specified rank.
Parameters: |
|
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute ID of a complex matrix to a specified rank using random matrix-vector multiplication.
Parameters: | |
---|---|
Returns: | Column index array. |
Return type: | |
Returns: | Interpolation coefficients. |
Return type: |
Compute SVD of a complex matrix to a specified rank using random matrix-vector multiplication.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |
Compute SVD of a complex matrix to a specified rank.
Parameters: |
|
---|---|
Returns: | Left singular vectors. |
Return type: | |
Returns: | Right singular vectors. |
Return type: | |
Returns: | Singular values. |
Return type: |