Module linalg

Module linalg 

Source
Expand description

Dense linear solves and general complex eigensystems with analytic derivatives, and restarted GMRES. treams-rs extension.

Two libraries share the linear algebra, by one rule:

  • nalgebra’s DMatrix stores every dense matrix.
  • faer factors and multiplies dense complex matrices of any size, through this module: LU solves (solve, Lu), singular values (svdvals), eigensystems (eig) and products (product and its variants). view and view_mut lend a DMatrix to faer without a copy.
  • Real symmetric eigenproblems use nalgebra’s SymmetricEigen: special::wigner diagonalizes the tridiagonal generator of the small-d matrix, of size 2l + 1.
  • Fixed-size matrices of at most 4 x 4 stay in nalgebra: the 3 x 3 inverse of lattice::reciprocal, the closed-form 2 x 2 inverse of coeffs::mie, the 4 x 4 and 2 x 2 inverses of coeffs::mie_cyl and the 4 x 4 inverse of smatrix::interface.

ModulesΒ§

gmres πŸ”’
Restarted GMRES (generalized minimal residual method) for complex linear systems given only through matrix-vector products. treams-rs extension.
saved πŸ”’
Fixed numerical layouts for invocation-owned JAX state. Dimensions are stored as u64; all other data are IEEE f64 components in column-major order. treams-rs extension.

StructsΒ§

Convergence
Proof of convergence for one right-hand side: the residual b - A x recomputed from the returned answer x, not the estimate of the Arnoldi iteration.
EigResidual
What eig saves for its derivatives: the right eigensystem, with unit vectors whose largest component is real and positive.
Equilibration πŸ”’
Positive diagonal scales for the equivalent operator R A C.
GmresOptions
Accuracy and memory budget of restarted GMRES.
Lu πŸ”’
Packed pivoted LU: overwrite the operator and share its triangular storage.
SolveGradient
Cotangents of the inputs of solve and solve_owned, in the order of their arguments.
SolveResidual
What solve saves for its derivatives: the LU factors and the solution. Both derivative directions solve with the same factors.
SvdvalsResidual
What svdvals saves for its derivatives: the thin singular vectors and the singular values.
ThinSvd πŸ”’
Thin singular vectors and values. faer’s Svd reads faer’s global parallelism, so the decomposition is called with DECOMPOSITION instead.

ConstantsΒ§

BALANCE_SWEEPS πŸ”’
The most sweeps of balance; dense operators take at most three.
DECOMPOSITION πŸ”’
Eigen- and singular-value decompositions run on the calling thread. faer’s parallel Hessenberg and bidiagonal reductions split inner products by worker count, so their last bits, and the order of eigenvalues, would follow the budget. On four workers they gained at most 1.3Γ— (eigenvalues) and 1.7Γ— (singular values) at n = 768, and nothing below n = 384.

FunctionsΒ§

balance πŸ”’
Even out the row and column sums of a max-equilibrated operator in place with power-of-two factors, folded into row and column.
eig
General complex eigendecomposition. Repeated eigenvalues are allowed in the primal.
eigen πŸ”’
Eigenvalues and right eigenvectors, called with an explicit Par as thin_svd.
eigvals
Eigenvalues ordered by real part, then imaginary part. The same eigensystem residual supplies derivatives without imposing an eigenvector phase constraint.
equilibrate πŸ”’
Equilibrate severely unbalanced finite square operators in place.
faer_zeros πŸ”’
Reserve decomposition vectors before initializing their entries.
lu_threads πŸ”’
The faer workers of an LU factorization or solve with rows rows and columns right-hand sides, on a pool of budget threads.
lu_workers πŸ”’
The faer workers of an LU call on the treams-rs budget.
product πŸ”’
left right.
product_adjoint_right πŸ”’
left rightα΄΄.
product_adjoint_right_into πŸ”’
out = left rightα΄΄, reusing the allocation of out.
product_into πŸ”’
out = left right on the treams-rs pool (crate::threads::product). Pass .adjoint() views for conjugate-transposed factors; faer conjugates them inside the product kernel.
product_views πŸ”’
left right in a new matrix; see product_into.
scale_rows πŸ”’
matrix[(i, j)] scales[i] 2^shifts[j], rounded once unless subnormal. A shifted column splits each scale into a mantissa and a power of two, and applies the power first when it scales up, so no intermediate product overflows or flushes a subnormal entry.
scratch πŸ”’
A faer workspace of req, or Error::OutOfMemory when the system refuses it or the requirement overflowed.
solve
Solve A X = B with pivoted LU; B is a matrix of right-hand sides.
solve_owned
Solve while reusing the owned operator buffer for its LU factors.
svdvals
Singular values of a finite nonempty rectangular complex matrix.
thin_svd πŸ”’
view πŸ”’
Column-major faer view of a nalgebra matrix.
view_mut πŸ”’
Mutable column-major faer view of a nalgebra matrix.