.. index:: pair: class; gpr::laplace::ScopedKernelState .. _doxid-classgpr_1_1laplace_1_1_scoped_kernel_state: class gpr::laplace::ScopedKernelState ===================================== .. toctree:: :hidden: Overview ~~~~~~~~ RAII guard: snapshots (magnSigma2, lengthScales, sigma2) at construction and restores them at destruction. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class ScopedKernelState { public: // construction :ref:`ScopedKernelState`(:ref:`SexpatCF`& kernel, double& sigma2, :ref:`LikGaussian`* likelihood = nullptr); :target:`ScopedKernelState`(const ScopedKernelState&); :target:`ScopedKernelState`(ScopedKernelState&&); :target:`~ScopedKernelState`(); // methods void :ref:`restore`(); :ref:`ScopedKernelState`& :target:`operator=`(const :ref:`ScopedKernelState`&); :ref:`ScopedKernelState`& :target:`operator=`(:ref:`ScopedKernelState`&&); void :ref:`applyTheta`(const Eigen::VectorXd& theta); }; .. _details-classgpr_1_1laplace_1_1_scoped_kernel_state: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ RAII guard: snapshots (magnSigma2, lengthScales, sigma2) at construction and restores them at destruction. Used by Laplace and SVGD grid/particle loops to mutate hyperparameters without leaking rank-local state across early returns. Non-copyable, non-movable: the guard owns a fixed scope. Construction ------------ .. index:: pair: function; ScopedKernelState .. _doxid-classgpr_1_1laplace_1_1_scoped_kernel_state_1a70091d50f57ea31f1e9be554aa2c3463: .. ref-code-block:: cpp :class: doxyrest-title-code-block ScopedKernelState(:ref:`SexpatCF`& kernel, double& sigma2, :ref:`LikGaussian`* likelihood = nullptr) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - kernel - SexpAt covariance function whose magn + ls to snapshot * - sigma2 - reference to the noise variance member in the GPR * - likelihood - optional Gaussian likelihood whose noise is theta-owned Methods ------- .. index:: pair: function; restore .. _doxid-classgpr_1_1laplace_1_1_scoped_kernel_state_1aabd9edc5a504ba5f0ee48c720e0d64f8: .. ref-code-block:: cpp :class: doxyrest-title-code-block void restore() Restore the snapshot mid-scope. Called automatically by the dtor; exposed publicly so callers that need the snapshot's state side-effects (e.g. re-decomposing the covariance matrix at theta_star while still owning the guard) don't have to drop the guard. Idempotent. .. index:: pair: function; applyTheta .. _doxid-classgpr_1_1laplace_1_1_scoped_kernel_state_1a1f47df9a3842606b473bb6ee6ed9b846: .. ref-code-block:: cpp :class: doxyrest-title-code-block void applyTheta(const Eigen::VectorXd& theta) Apply a theta vector to the kernel state. theta = (log magn, log ls_1, ..., log ls_nls, log noise).