namespace gpr::linalg::linop¶
Overview¶
namespace linop {
// structs
struct BatchSolve;
struct BatchSolveSettings;
struct KrylovObjectiveInputs;
struct KrylovPlan;
struct KrylovTolerances;
struct PartialCholesky;
// classes
class CallbackOperator;
class CovarianceSolver;
class DenseCholeskySolver;
class DenseOperator;
class DenseResultCache;
class KrylovCovarianceSolver;
class LanczosVarianceCache;
class PivotedCholeskyPreconditioner;
class ShiftedOperator;
class SymmetricOperator;
// global functions
double denseObjectiveFlops(Eigen::Index order, Eigen::Index hyperparameters);
double krylovObjectiveFlops(const KrylovObjectiveInputs& in, Eigen::Index rank);
KrylovPlan planKrylovObjective(const KrylovObjectiveInputs& in);
BatchSolve batchConjugateGradients(const SymmetricOperator& K, const PivotedCholeskyPreconditioner& P, const Eigen::MatrixXd& B, const BatchSolveSettings& settings);
double lanczosLogQuadrature(const BatchSolve& solve, Eigen::Index column);
double lanczosSquaredLogQuadrature(const BatchSolve& solve, Eigen::Index column);
Eigen::MatrixXd standardNormalProbes(Eigen::Index rows, Eigen::Index cols, std::uint64_t seed);
Eigen::Index probesForStandardError(double sample_variance, double target, Eigen::Index taken);
double sampleVariance(const Eigen::VectorXd& draws);
double conjugateGradientIterations(double kappa, double tolerance);
double pivotFlops(double column_flops, Eigen::Index order, Eigen::Index rank);
PartialCholesky partialPivotedCholesky(const SymmetricOperator& kernel, const std::function<bool(Eigen::Index, double, double)>& keep_going);
std::vector<double> schurResidualTraces(const Eigen::MatrixXd& L);
} // namespace linop
Detailed Documentation¶
Global Functions¶
double denseObjectiveFlops(Eigen::Index order, Eigen::Index hyperparameters)
potrf, the explicit inverse as cholesky_inverse forms it (a triangular solve against the identity and the Gram of the result), two substitutions, and one dense contraction per hyperparameter.
double krylovObjectiveFlops(const KrylovObjectiveInputs& in, Eigen::Index rank)
Krylov cost at one preconditioner rank: pivots, the block CG on the data and the probes, and the probe contractions replacing the dense ones.
KrylovPlan planKrylovObjective(const KrylovObjectiveInputs& in)
The cheapest rank on the residual curve, among ranks whose pivots cost less than a full Cholesky.
BatchSolve batchConjugateGradients(const SymmetricOperator& K, const PivotedCholeskyPreconditioner& P, const Eigen::MatrixXd& B, const BatchSolveSettings& settings)
Preconditioned CG on K X = B, all columns advanced by one block apply per iteration until each meets its tolerance or the budget is spent.
double lanczosLogQuadrature(const BatchSolve& solve, Eigen::Index column)
e1^T log(T) e1 scaled by r0^T P^{-1} r0 for column j: the quadrature estimate of z^T P^{-1/2} log(P^{-1/2} K P^{-1/2}) P^{-1/2} z.
double lanczosSquaredLogQuadrature(const BatchSolve& solve, Eigen::Index column)
The same quadrature for log^2: its mean over Gaussian probes estimates the squared Frobenius norm of log(P^{-1/2} K P^{-1/2}), half the variance of one log det draw. Unlike a sample variance of a few draws it is a trace of a positive semi-definite matrix and does not collapse when the draws agree.
Eigen::MatrixXd standardNormalProbes(Eigen::Index rows, Eigen::Index cols, std::uint64_t seed)
Standard normal draws from a fixed-seed counter generator, identical on every platform and thread count.
Eigen::Index probesForStandardError(double sample_variance, double target, Eigen::Index taken)
Probes needed for the sample mean of draws with this sample variance to reach the standard error target; at least the draws already taken.
double conjugateGradientIterations(double kappa, double tolerance)
Iterations CG needs for relative K-norm error tolerance at condition number kappa : ceil(sqrt(kappa) log(2 / tolerance) / 2).
double pivotFlops(double column_flops, Eigen::Index order, Eigen::Index rank)
Pivot cost: one column read and the update against the previous pivots.
PartialCholesky partialPivotedCholesky(const SymmetricOperator& kernel, const std::function<bool(Eigen::Index, double, double)>& keep_going)
Greedy pivoted Cholesky. After each pivot
keep_going(rank, trace,
flops) decides whether to take another; pivoting also stops on a zero residual or at full rank.
std::vector<double> schurResidualTraces(const Eigen::MatrixXd& L)
tr(S_r) for every r, S_r the Schur complement left by the first r rows of the lower factor L. For K = A0 + diag(s) >= A0 it bounds the residual trace of A0 under the same pivot order, at O(n^2) from a factor in hand.