graphdot.linalg.low_rank module¶
Low-rank approximation of square matrices.
-
class
graphdot.linalg.low_rank.
LATR
(lhs, rhs)[source]¶ Bases:
graphdot.linalg.low_rank.LowRankBase
Represents an N-by-N square matrix A as :py:math:`L \cdot R`, where L and R are N-by-k and k-by-N (:py:math:`k << N`) rectangular matrices.
-
T
¶
-
lhs
¶
-
rhs
¶
-
-
class
graphdot.linalg.low_rank.
LLT
(X, rcond=0, mode='truncate')[source]¶ Bases:
graphdot.linalg.low_rank.LATR
A special case of factor approximation where the matrix is symmetric and positive-semidefinite. In this case, the matrix can be represented as :py:math:`L \cdot L^\mathsf{T}` from a spectral decomposition.
-
lhs
¶
-
rhs
¶
-
-
class
graphdot.linalg.low_rank.
Sum
(factors)[source]¶ Bases:
graphdot.linalg.low_rank.LowRankBase
Represents summations of factor approximations. Due to the bilinear nature of matrix inner product, it is best to store the summation as-is so as to preserve the low-rank structure of the matrices.
-
T
¶
-
-
graphdot.linalg.low_rank.
dot
(X, Y=None, method='auto', rcond=0, mode='truncate')[source]¶ A utility method that creates low-rank matrices :py:math:`A \doteq X \cdot Y`.
Parameters: - X (ndarray) – Left hand side of the product.
- Y (ndarray) – Right hand side of the product. If None, Y will be assumed to be the transposition of X.
- method ('auto' or 'direct' or 'spectral') – If ‘direct’, store the matrix as the product of X and Y. If ‘spectral’ and Y is None, store the matrix as the product of the singular vectors and singular values of X. ‘auto’ is equivalent to ‘spectral’ when Y is None and ‘direct’ otherwise.
- rcond (float) – Threshold for small singular values when method is ‘spectral’.
- mode ('truncate' or 'clamp') – Determines how small singular values of the original matrix are handled. For ‘truncate’, small values are discarded; for ‘clamp’, they are fixed to be the product of the largest singular value and rcond.
-
graphdot.linalg.low_rank.
pinvh
(A: graphdot.linalg.low_rank.LATR, d, k='auto', rcond=1e-10, mode='truncate')[source]¶ Calculate the low-rank approximated pseudoinverse of a low-rank symmetric matrix with optional diagonal regularization.
Parameters: - A (
LATR
.) – A low-rank symmetric positive semidefinite matrix. - d (array) – An optional regularization vector that will be added elementwise to the
diagonal of
A
. - k (int or 'auto') – Number of eigenvalues to resolve. If ‘auto’, k will be set to be the
sum of the rank of
A
plus the number of nonzeros ind
. - rcond (float) – Cutoff for small eigenvalues. Eigenvalues less than or equal to rcond * largest_eigenvalue and associated eigenvators are discarded in forming the pseudoinverse.
- mode (str) – Determines how small eigenvalues of the original matrix are handled. For ‘truncate’, small eigenvalues are discarded; for ‘clamp’, they are fixed to be the product of the largest eigenvalue and rcond.
Returns: Ainv – A low-rank representation of the pseudoinverse of
A
.Return type: LLT
.- A (