Solvers and FPCA
Functions for solving linear systems and performing functional principal component analysis.
CovIterSolvers.conj_lanczos — Functionconj_lanczos(b0, D, C; ...)Performs the C-Lanczos algorithm for the generalized eigenvalue problem D*C*q = λ*q.
This iterative method generates a C-orthonormal basis Q for the Krylov subspace and a symmetric tridiagonal matrix T that represents the projection of the operator D*C onto that subspace.
Arguments
b0::AbstractBlockVector{T}: The starting vector for the iteration.D::BlockDiagonal{T}: A block-diagonal matrix to factorize.C::AbstractBlockMatrix{T}: A symmetric, positive-definite matrix defining the inner product (C-inner product).
Keyword Arguments
itmax::Int=100: Maximum number of iterations.tol::Float64=1e-8: Tolerance for the C-norm of the residual to determine convergence.history::Bool=false: Iftrue, the history of residual C-norms is stored and returned.reortho_level::Symbol=:full: Level of reorthogonalization. Use:fullfor numerical stability, or:noneto observe loss of orthogonality.
Returns
NamedTuple: A named tuple(T, Q, history)containing:T: ASymTridiagonalmatrix.Q: A matrix whose columns are the C-orthonormal Lanczos basis vectors.history: A vector of residual C-norms, ornothingifhistory=false.
CovIterSolvers.fpca — Functionfpca(k, E, A, myspline)
fpca(k, E, A, K; itmax=50)Performs Functional Principal Component Analysis (FPCA) to find the evaluation of leading k eigenfunctions and their corresponding eigenvalues.
This function solves the generalized eigenvalue problem A*v = λ*G*v or A*v = λ*K*v using one of two methods:
- Direct B-spline Method: When provided with a
BSplineMethod, it solves the problem directly using a Cholesky and eigenvalue decomposition. This is suitable for smaller, well-behaved systems where the Galerkin matrixGcan be formed. - Iterative Krylov Method: When provided with a covariance matrix
K, it uses the Conjugate Lanczos algorithm (conj_lanczos) to iteratively find the eigenvalues. This is suitable for large, sparse, or matrix-free problems.
Arguments
k::Int: The number of principal components to compute.E::BlockMatrix: The evaluation matrix that maps coefficients to function values.A::BlockDiagonal: A block-diagonal matrix representing the prior covariance of the coefficients (theAmatrix in the eigenproblem).myspline::BSplineMethod: A B-spline method object defining the basis.K::BlockMatrix: A Gram matrix representing the inner product for the eigenproblem.
Keyword Arguments
itmax::Int=50: (Iterative method only) The maximum number of iterations for the Lanczos algorithm.
Returns
Tuple{Vector, Matrix}: A tuple containing:- A vector of the
klargest eigenvalues (PC variances). - A matrix whose columns are the corresponding
keigenfunctions (PC vectors).
- A vector of the