.. index:: pair: namespace; gpr::linalg::linop .. _doxid-namespacegpr_1_1linalg_1_1linop: namespace gpr::linalg::linop ============================ .. toctree:: :hidden: struct_gpr_linalg_linop_BatchSolve.rst struct_gpr_linalg_linop_BatchSolveSettings.rst struct_gpr_linalg_linop_KrylovObjectiveInputs.rst struct_gpr_linalg_linop_KrylovPlan.rst struct_gpr_linalg_linop_KrylovTolerances.rst struct_gpr_linalg_linop_PartialCholesky.rst class_gpr_linalg_linop_CallbackOperator.rst class_gpr_linalg_linop_CovarianceSolver.rst class_gpr_linalg_linop_DenseCholeskySolver.rst class_gpr_linalg_linop_DenseOperator.rst class_gpr_linalg_linop_DenseResultCache.rst class_gpr_linalg_linop_KrylovCovarianceSolver.rst class_gpr_linalg_linop_LanczosVarianceCache.rst class_gpr_linalg_linop_PivotedCholeskyPreconditioner.rst class_gpr_linalg_linop_ShiftedOperator.rst class_gpr_linalg_linop_SymmetricOperator.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace linop { // structs struct :ref:`BatchSolve`; struct :ref:`BatchSolveSettings`; struct :ref:`KrylovObjectiveInputs`; struct :ref:`KrylovPlan`; struct :ref:`KrylovTolerances`; struct :ref:`PartialCholesky`; // classes class :ref:`CallbackOperator`; class :ref:`CovarianceSolver`; class :ref:`DenseCholeskySolver`; class :ref:`DenseOperator`; class :ref:`DenseResultCache`; class :ref:`KrylovCovarianceSolver`; class :ref:`LanczosVarianceCache`; class :ref:`PivotedCholeskyPreconditioner`; class :ref:`ShiftedOperator`; class :ref:`SymmetricOperator`; // global functions double :ref:`denseObjectiveFlops`(Eigen::Index order, Eigen::Index hyperparameters); double :ref:`krylovObjectiveFlops`(const :ref:`KrylovObjectiveInputs`& in, Eigen::Index rank); :ref:`KrylovPlan` :ref:`planKrylovObjective`(const :ref:`KrylovObjectiveInputs`& in); :ref:`BatchSolve` :ref:`batchConjugateGradients`(const :ref:`SymmetricOperator`& K, const :ref:`PivotedCholeskyPreconditioner`& P, const Eigen::MatrixXd& B, const :ref:`BatchSolveSettings`& settings); double :ref:`lanczosLogQuadrature`(const :ref:`BatchSolve`& solve, Eigen::Index column); double :ref:`lanczosSquaredLogQuadrature`(const :ref:`BatchSolve`& solve, Eigen::Index column); Eigen::MatrixXd :ref:`standardNormalProbes`(Eigen::Index rows, Eigen::Index cols, std::uint64_t seed); Eigen::Index :ref:`probesForStandardError`(double sample_variance, double target, Eigen::Index taken); double :target:`sampleVariance`(const Eigen::VectorXd& draws); double :ref:`conjugateGradientIterations`(double kappa, double tolerance); double :ref:`pivotFlops`(double column_flops, Eigen::Index order, Eigen::Index rank); :ref:`PartialCholesky` :ref:`partialPivotedCholesky`(const :ref:`SymmetricOperator`& kernel, const std::function& keep_going); std::vector :ref:`schurResidualTraces`(const Eigen::MatrixXd& L); } // namespace linop .. _details-namespacegpr_1_1linalg_1_1linop: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Global Functions ---------------- .. index:: pair: function; denseObjectiveFlops .. _doxid-namespacegpr_1_1linalg_1_1linop_1a8248e7096e19e6539079db812a9f357c: .. ref-code-block:: cpp :class: doxyrest-title-code-block 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. .. index:: pair: function; krylovObjectiveFlops .. _doxid-namespacegpr_1_1linalg_1_1linop_1a7e02bf17e2a8a19eb2aa3caab1a363c4: .. ref-code-block:: cpp :class: doxyrest-title-code-block double krylovObjectiveFlops(const :ref:`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. .. index:: pair: function; planKrylovObjective .. _doxid-namespacegpr_1_1linalg_1_1linop_1a38d0f036390df01c6abc8df3da465a8a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`KrylovPlan` planKrylovObjective(const :ref:`KrylovObjectiveInputs`& in) The cheapest rank on the residual curve, among ranks whose pivots cost less than a full Cholesky. .. index:: pair: function; batchConjugateGradients .. _doxid-namespacegpr_1_1linalg_1_1linop_1a1fd93fc1142e75374d7d86a813688f40: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`BatchSolve` batchConjugateGradients(const :ref:`SymmetricOperator`& K, const :ref:`PivotedCholeskyPreconditioner`& P, const Eigen::MatrixXd& B, const :ref:`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. .. index:: pair: function; lanczosLogQuadrature .. _doxid-namespacegpr_1_1linalg_1_1linop_1a6ffee983e2c614905e22433cdccdd1bf: .. ref-code-block:: cpp :class: doxyrest-title-code-block double lanczosLogQuadrature(const :ref:`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. .. index:: pair: function; lanczosSquaredLogQuadrature .. _doxid-namespacegpr_1_1linalg_1_1linop_1acaa790c7a796ad381a1102962005f7ee: .. ref-code-block:: cpp :class: doxyrest-title-code-block double lanczosSquaredLogQuadrature(const :ref:`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. .. index:: pair: function; standardNormalProbes .. _doxid-namespacegpr_1_1linalg_1_1linop_1ad19554dafbcef55ae5c842ed4570c5a2: .. ref-code-block:: cpp :class: doxyrest-title-code-block 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. .. index:: pair: function; probesForStandardError .. _doxid-namespacegpr_1_1linalg_1_1linop_1a8f723cea60d8892b1e553b33984f524d: .. ref-code-block:: cpp :class: doxyrest-title-code-block 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. .. index:: pair: function; conjugateGradientIterations .. _doxid-namespacegpr_1_1linalg_1_1linop_1a4dbd729934159067b142ff7610aaa8d2: .. ref-code-block:: cpp :class: doxyrest-title-code-block 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). .. index:: pair: function; pivotFlops .. _doxid-namespacegpr_1_1linalg_1_1linop_1ad28b47ae70a779e40718037c040de4fd: .. ref-code-block:: cpp :class: doxyrest-title-code-block double pivotFlops(double column_flops, Eigen::Index order, Eigen::Index rank) Pivot cost: one column read and the update against the previous pivots. .. index:: pair: function; partialPivotedCholesky .. _doxid-namespacegpr_1_1linalg_1_1linop_1adb9c5e4538b0b0fe5de388c47de109f5: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`PartialCholesky` partialPivotedCholesky(const :ref:`SymmetricOperator`& kernel, const std::function& keep_going) Greedy pivoted Cholesky. After each pivot .. code-block:: none keep_going(rank, trace, flops) decides whether to take another; pivoting also stops on a zero residual or at full rank. .. index:: pair: function; schurResidualTraces .. _doxid-namespacegpr_1_1linalg_1_1linop_1a2745f4eb8f874b5396e8bab9db9c2255: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector 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.