|
libqe 0.2.6-dev.9001
QE C++ library
|
Functions | |
Eigendecomposition | |
| void | eig_sym (arma::vec &eigval, arma::mat &eigvec, const arma::mat &S) |
| Eigendecomposition of a real symmetric matrix. | |
QR Factorization | |
| void | qr_full (arma::mat &Q, arma::mat &R, const arma::mat &A) |
| Full (square) QR factorization of an n×p matrix. | |
Singular Value Decomposition | |
| void | svd (arma::mat &U, arma::vec &s, arma::mat &V, const arma::mat &A) |
Full SVD: A ≈ U * diag(s) * V', singular values descending. | |
| void | svd_right (arma::vec &s, arma::mat &V, const arma::mat &A) |
| Singular values and right singular vectors only (left vectors skipped). | |
Linear System Solve | |
| arma::mat | solve_spd (const arma::mat &A, const arma::mat &b, double tol=1e-12) |
Solve A*x = b for symmetric positive (semi-)definite A. | |
| arma::mat | inv_sym (const arma::mat &A, double tol=1e-12) |
| Inverse of a symmetric positive (semi-)definite matrix, falling back to the pseudo-inverse when it is singular. | |
|
inline |
Eigendecomposition of a real symmetric matrix.
Computes eigenvalues and eigenvectors of the symmetric p×p matrix S and returns them sorted in ascending eigenvalue order.
| [out] | eigval | p×1 vector of eigenvalues, ascending. |
| [out] | eigvec | p×p matrix whose columns are the corresponding orthonormal eigenvectors. |
| [in] | S | Real symmetric p×p input matrix (not modified). |
ARMA_USE_LAPACK defined this calls arma::eig_sym directly. Without LAPACK the fallback runs up to 50*p cyclic Jacobi sweeps; convergence is guaranteed for well-conditioned matrices but may be slow for p > 200.< working copy of S
< accumulate rotations; starts as identity
|
inline |
Inverse of a symmetric positive (semi-)definite matrix, falling back to the pseudo-inverse when it is singular.
| [in] | A | Real symmetric positive (semi-)definite n×n matrix. |
| [in] | tol | Without LAPACK: relative eigenvalue threshold, as in solve_spd. Default: 1e-12. |
A^-1, or the pseudo-inverse when A is singular.ARMA_USE_LAPACK defined this calls arma::inv and, when that reports a singular matrix, arma::pinv. Without LAPACK it is the eigendecomposition-based pseudo-inverse (solve_spd with the identity), which equals the inverse for a non-singular A.
|
inline |
Full (square) QR factorization of an n×p matrix.
Produces a square n×n orthogonal factor Q and an n×p upper-trapezoidal factor R such that A = Q*R. This matches the convention of arma::qr(), which returns the full (non-economy) Q.
| [out] | Q | n×n orthogonal matrix. |
| [out] | R | n×p upper-trapezoidal matrix. |
| [in] | A | n×p input matrix (not modified). |
ARMA_USE_LAPACK defined this calls arma::qr directly. Without LAPACK the fallback constructs the full ONB by seeding columns beyond A.n_cols with standard basis vectors and then applying modified Gram-Schmidt; numerical quality degrades for nearly rank-deficient inputs.orthogonal_svd) depends on Q being n×n so that Q.cols(k, n-1) spans the null space of A^T. < standard basis vector e_j used as seed
|
inline |
Solve A*x = b for symmetric positive (semi-)definite A.
Returns the n×k solution matrix x given the n×n system matrix A and the n×k right-hand side b. Near-zero eigenvalues are handled gracefully, making this a pseudo-inverse solve safe for rank-deficient Gram matrices.
| [in] | A | Real symmetric positive (semi-)definite n×n matrix. |
| [in] | b | n×k right-hand side matrix. |
| [in] | tol | Relative threshold below which eigenvalues are treated as zero. Eigenvalues with |λ| < tol * max(|λ|) are inverted as zero (i.e. those directions are projected out). Default: 1e-12. |
x satisfying A*x ≈ b.ARMA_USE_LAPACK defined this delegates to arma::solve(A, b, arma::solve_opts::fast), which uses a Cholesky factorization and does not handle rank deficiency. Without LAPACK the eigendecomposition-based pseudo-inverse is used, which is safe for rank-deficient inputs but slower.A = V * diag(λ) * V^T is computed via eig_sym; the solution is x = V * diag(1/λ) * V^T * b with small λ skipped. < A = eigvec * diag(eigval) * eigvec^T
|
inline |
Full SVD: A ≈ U * diag(s) * V', singular values descending.
Decomposes the n×p matrix A into left singular vectors U, singular values s, and right singular vectors V.
| [out] | U | n×min(n,p) matrix of left singular vectors. |
| [out] | s | min(n,p)×1 vector of singular values, descending. |
| [out] | V | p×p matrix of right singular vectors (all p columns). |
| [in] | A | n×p input matrix (not modified). |
ARMA_USE_LAPACK defined this calls arma::svd directly. Without LAPACK the fallback computes A^T*A, calls eig_sym, and derives U via U[:,j] = A*V[:,j]/s_j. Columns with s_j < 1e-14 are zeroed. Accuracy is governed by the conditioning of A^T*A (squares the condition number of A).
via cyclic Jacobi (Demmel & Veselić 1992). Suitable for the small, moderately conditioned matrices typical in ENA (p ≤ ~100). < p×p symmetric Gram matrix
|
inline |
Singular values and right singular vectors only (left vectors skipped).
A lighter-weight variant of svd() for callers that only need s and V. Under LAPACK the full arma::svd is still called internally; the savings come in WASM builds where computing U is avoided.
| [out] | s | min(n,p)×1 vector of singular values, descending. |
| [out] | V | p×p matrix of right singular vectors. |
| [in] | A | n×p input matrix (not modified). |
ARMA_USE_LAPACK defined this still invokes the full arma::svd; the left-vector output is discarded.