Loading...
Searching...
No Matches
gpr::capi::Model Class Reference

#include <gpr/capi/gpridge.hpp>

Public Member Functions

 Model ()=default
 Model (gpr_model_t h, adopt_t) noexcept
 Model (gpr_model_t h, borrow_t) noexcept
 ~Model ()
 Model (const Model &)=delete
Model & operator= (const Model &)=delete
 Model (Model &&other) noexcept
Model & operator= (Model &&other) noexcept
void reset () noexcept
gpr_model_t release () noexcept
bool owns () const noexcept
gpr_model_t handle () const noexcept
 operator bool () const noexcept
ModelType type () const
void init (const ModelConfig &config, const Atoms &atoms)
void train (const double *R, std::size_t R_len, const double *E, std::size_t E_len, const double *G, std::size_t G_len, int n_obs, int n_coords)
void train (const std::vector< double > &R, const std::vector< double > &E, const std::vector< double > &G, int n_obs, int n_coords)
void train_unchecked (const double *R, const double *E, const double *G, int n_obs, int n_coords)
std::pair< MarginalLikelihoodReport, std::vector< double > > train_marginal_likelihood (const double *R, std::size_t R_len, const double *E, std::size_t E_len, const double *G, std::size_t G_len, int n_obs, int n_coords)
std::pair< MarginalLikelihoodReport, std::vector< double > > train_marginal_likelihood (const std::vector< double > &R, const std::vector< double > &E, const std::vector< double > &G, int n_obs, int n_coords)
void update (const double *R_new, std::size_t R_len, const double *E_new, std::size_t E_len, const double *G_new, std::size_t G_len, int n_new, int n_coords)
void update (const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, int n_new, int n_coords)
void update_unchecked (const double *R_new, const double *E_new, const double *G_new, int n_new, int n_coords)
void append_fixed (const double *R_new, std::size_t R_len, const double *E_new, std::size_t E_len, const double *G_new, std::size_t G_len, int n_new, int n_coords)
void append_fixed (const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, int n_new, int n_coords)
CalibrationReport calibrate_forces (const double *R_holdout, std::size_t R_len, const double *G_true, std::size_t G_len, int n_holdout, int n_coords, double nominal_probability) const
CalibrationReport calibrate_forces (const std::vector< double > &R_holdout, const std::vector< double > &G_true, int n_holdout, int n_coords, double nominal_probability) const
CalibrationReport calibrate_loo (double nominal_probability) const
void predict (const double *R_query, std::size_t R_len, double *E_out, double *G_out, std::size_t G_len, int n_coords) const
std::pair< double, std::vector< double > > predict (const std::vector< double > &R_query) const
void predict_unchecked (const double *R_query, double *E_out, double *G_out, int n_coords) const
void predict_variance (const double *R_query, std::size_t R_len, double *var_E_out, double *var_G_out, std::size_t var_G_len, int n_coords) const
std::pair< double, std::vector< double > > predict_variance (const std::vector< double > &R_query) const
void predict_variance_unchecked (const double *R_query, double *var_E_out, double *var_G_out, int n_coords) const
void predict_full (const double *R_query, std::size_t R_len, double *E_out, double *G_out, std::size_t G_len, double *var_E_out, double *var_G_out, std::size_t var_G_len, int n_coords) const
void predict_full_unchecked (const double *R_query, double *E_out, double *G_out, double *var_E_out, double *var_G_out, int n_coords) const
void predict_batch (const double *R_queries, std::size_t R_len, double *E_out, std::size_t E_len, double *G_out, std::size_t G_len, double *var_E_out, std::size_t var_E_len, double *var_G_out, std::size_t var_G_len, int n_queries, int n_coords) const
void predict_batch_unchecked (const double *R_queries, double *E_out, double *G_out, double *var_E_out, double *var_G_out, int n_queries, int n_coords) const
void predict_hessian (const double *R_query, std::size_t R_len, double *H_out, std::size_t H_len, int n_coords) const
std::vector< double > predict_hessian (const std::vector< double > &R_query) const
void predict_hessian_unchecked (const double *R_query, double *H_out, int n_coords) const
void predict_hessian_action (const double *R_query, std::size_t R_len, const double *v, std::size_t v_len, double *Hv_out, std::size_t Hv_len, int n_coords) const
std::vector< double > predict_hessian_action (const std::vector< double > &R_query, const std::vector< double > &v) const
void predict_hessian_action_unchecked (const double *R_query, const double *v, double *Hv_out, int n_coords) const
void predict_energy_variance_interval (const double *R_queries, std::size_t R_len, double *lower, std::size_t lower_len, double *upper, std::size_t upper_len, int n_queries, int n_coords) const
std::pair< std::vector< double >, std::vector< double > > predict_energy_variance_interval (const std::vector< double > &R_queries, int n_coords) const
void predict_energy_variance_interval_unchecked (const double *R_queries, double *lower, double *upper, int n_queries, int n_coords) const
NoiseFloorReport noise_floor_report () const
bool prediction_supported (const std::vector< double > &R_query) const
bool prediction_supported_unchecked (const double *R_query, int n_coords) const
int prediction_factors (const double *R_query, int n_coords, double *energy, double *scale, double *mean, double *kstar, double *weights, int capacity) const
int fit_iterations () const
int fit_restarts () const
std::string fit_stop_reason () const
int n_lengthscales () const
std::vector< double > lengthscales () const
void set_lengthscales (const std::vector< double > &values)
double magn_sigma2 () const
void set_magn_sigma2 (double value)
double sigma2 () const
void set_sigma2 (double value)
void set_rff_features (int n_features, double force_tol_fraction=0.0)
RffSelection rff_selection () const
void set_rigid_null_deflation (bool enabled)
bool rigid_null_deflation () const
double jitter () const
void set_hssvd_backend (bool enabled)
bool hssvd_backend () const
int n_observations () const
std::vector< double > alpha (int capacity) const
double tp_prefactor () const
std::vector< double > mean_hessian_batch (const std::vector< double > &R, int n_coords, const DerivativeOptions *options=nullptr, std::vector< double > *residuals_out=nullptr, DerivativeReport *report=nullptr) const
void mean_hessian_batch_unchecked (const DerivativeOptions *options, const double *R, int n_points, int n_coords, double *H_out, double *residuals_out, DerivativeReport *report) const
std::vector< double > mean_hessian_action_batch (const std::vector< double > &R, int n_coords, const std::vector< double > &V, int n_vectors, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr) const
 H(x_b) v for the n_vectors rows of V at each point.
void mean_hessian_action_batch_unchecked (const DerivativeOptions *options, const double *R, int n_points, int n_coords, const double *V, int n_vectors, double *Hv_out, DerivativeReport *report) const
std::vector< double > hessian_bilinear_covariance (const std::vector< double > &R, int n_coords, const std::vector< double > &V, int n_left, const std::vector< double > &W, int n_right, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr) const
void hessian_bilinear_covariance_unchecked (const DerivativeOptions *options, const double *R, int n_points, int n_coords, const double *V, int n_left, const double *W, int n_right, double *cov_out, DerivativeReport *report) const
std::vector< double > hessian_trace_variance (const std::vector< double > &R, int n_coords, const std::vector< double > &A, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr) const
 Posterior variance of tr(A dH), one symmetric A per point.
void hessian_trace_variance_unchecked (const DerivativeOptions *options, const double *R, int n_points, int n_coords, const double *A, double *var_out, DerivativeReport *report) const
std::pair< std::vector< double >, std::vector< double > > posterior_variance_batch (const std::vector< double > &R, int n_coords, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr) const
 Posterior energy variances and gradient component variances.
void posterior_variance_batch_unchecked (const DerivativeOptions *options, const double *R, int n_points, int n_coords, double *var_E_out, double *var_G_out, DerivativeReport *report) const
ConditionedPrediction condition_fixed (const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, const std::vector< double > &R_query, int n_coords, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr)
void condition_fixed_unchecked (const DerivativeOptions *options, const double *R_new, const double *E_new, const double *G_new, int n_new, const double *R_query, int n_query, int n_coords, double *E_out, double *G_out, double *var_E_out, double *var_G_out, DerivativeReport *report)
ConditionedPrediction condition_fixed_hessian (const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, const std::vector< double > *H_new, HvpFn hvp, void *user_data, const std::vector< double > &R_query, int n_coords, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr)
ConditionedPrediction condition_fixed (const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, const std::vector< double > &H_new, const std::vector< double > &R_query, int n_coords, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr)
void condition_fixed_hessian_unchecked (const DerivativeOptions *options, const double *R_new, const double *E_new, const double *G_new, int n_new, const double *H_new, HvpFn hvp, void *user_data, const double *R_query, int n_query, int n_coords, double *E_out, double *G_out, double *var_E_out, double *var_G_out, DerivativeReport *report)

Static Public Member Functions

static Model create (ModelType type=ModelType::Gp)

Detailed Description

Definition at line 1473 of file gpridge.hpp.

Constructor & Destructor Documentation

◆ Model() [1/5]

gpr::capi::Model::Model ( )
default

◆ Model() [2/5]

gpr::capi::Model::Model ( gpr_model_t h,
adopt_t  )
inlinenoexcept

Definition at line 1476 of file gpridge.hpp.

1476: handle_(h), owns_(true) { }

◆ Model() [3/5]

gpr::capi::Model::Model ( gpr_model_t h,
borrow_t  )
inlinenoexcept

Definition at line 1477 of file gpridge.hpp.

1477: handle_(h), owns_(false) { }

◆ ~Model()

gpr::capi::Model::~Model ( )
inline

Definition at line 1478 of file gpridge.hpp.

1479 {
1480 reset();
1481 }
void reset() noexcept
Definition gpridge.hpp:1509

◆ Model() [4/5]

gpr::capi::Model::Model ( const Model & )
delete

◆ Model() [5/5]

gpr::capi::Model::Model ( Model && other)
inlinenoexcept

Definition at line 1485 of file gpridge.hpp.

1485 : handle_(other.handle_), owns_(other.owns_)
1486 {
1487 other.handle_ = nullptr;
1488 other.owns_ = false;
1489 }

Member Function Documentation

◆ alpha()

std::vector< double > gpr::capi::Model::alpha ( int capacity) const
inlinenodiscard

Definition at line 2003 of file gpridge.hpp.

2004 {
2005 std::vector<double> out(static_cast<std::size_t>(capacity));
2006 check(gpr_model_get_alpha(handle_, out.data(), capacity));
2007 return out;
2008 }
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
int gpr_model_get_alpha(gpr_model_t model, double *out, int n)
Get posterior mean weights (alpha vector). Size = n_obs * (1 + n_coords). Returns GPR_ERR_NOT_TRAINED...
void check(int status)
Definition gpridge.hpp:323

◆ append_fixed() [1/2]

void gpr::capi::Model::append_fixed ( const double * R_new,
std::size_t R_len,
const double * E_new,
std::size_t E_len,
const double * G_new,
std::size_t G_len,
int n_new,
int n_coords )
inline

Definition at line 1619 of file gpridge.hpp.

1623 {
1624 check(gpr_model_append_fixed_checked(handle_, R_new, R_len, E_new,
1625 E_len, G_new, G_len, n_new,
1626 n_coords));
1627 }
int gpr_model_append_fixed_checked(gpr_model_t model, const double *R_new, size_t R_len, const double *E_new, size_t E_len, const double *G_new, size_t G_len, int n_new, int n_coords)
Append rows at the fitted hyperparameters by a Cholesky block update (ABI 1.13).

◆ append_fixed() [2/2]

void gpr::capi::Model::append_fixed ( const std::vector< double > & R_new,
const std::vector< double > & E_new,
const std::vector< double > & G_new,
int n_new,
int n_coords )
inline

Definition at line 1629 of file gpridge.hpp.

1632 {
1633 append_fixed(R_new.data(), R_new.size(), E_new.data(), E_new.size(),
1634 G_new.data(), G_new.size(), n_new, n_coords);
1635 }
void append_fixed(const double *R_new, std::size_t R_len, const double *E_new, std::size_t E_len, const double *G_new, std::size_t G_len, int n_new, int n_coords)
Definition gpridge.hpp:1619

◆ calibrate_forces() [1/2]

CalibrationReport gpr::capi::Model::calibrate_forces ( const double * R_holdout,
std::size_t R_len,
const double * G_true,
std::size_t G_len,
int n_holdout,
int n_coords,
double nominal_probability ) const
inlinenodiscard

Definition at line 1637 of file gpridge.hpp.

1641 {
1642 CalibrationReport report{};
1644 handle_, R_holdout, R_len, G_true, G_len, n_holdout, n_coords,
1645 nominal_probability, &report));
1646 return report;
1647 }
int gpr_model_calibrate_forces_checked(gpr_model_t model, const double *R_holdout, size_t R_len, const double *G_true, size_t G_len, int n_holdout, int n_coords, double nominal_probability, gpr_calibration_report_t *report)
Evaluate true-force calibration on held-out rows (ABI 1.13).
gpr_calibration_report_t CalibrationReport
Definition gpridge.hpp:245

◆ calibrate_forces() [2/2]

CalibrationReport gpr::capi::Model::calibrate_forces ( const std::vector< double > & R_holdout,
const std::vector< double > & G_true,
int n_holdout,
int n_coords,
double nominal_probability ) const
inlinenodiscard

Definition at line 1649 of file gpridge.hpp.

1652 {
1653 return calibrate_forces(R_holdout.data(), R_holdout.size(),
1654 G_true.data(), G_true.size(), n_holdout,
1655 n_coords, nominal_probability);
1656 }
CalibrationReport calibrate_forces(const double *R_holdout, std::size_t R_len, const double *G_true, std::size_t G_len, int n_holdout, int n_coords, double nominal_probability) const
Definition gpridge.hpp:1637

◆ calibrate_loo()

CalibrationReport gpr::capi::Model::calibrate_loo ( double nominal_probability) const
inlinenodiscard

Definition at line 1658 of file gpridge.hpp.

1660 {
1661 CalibrationReport report{};
1662 check(gpr_model_calibrate_loo_checked(handle_, nominal_probability,
1663 &report));
1664 return report;
1665 }
int gpr_model_calibrate_loo_checked(gpr_model_t model, double nominal_probability, gpr_calibration_report_t *report)
Closed-form leave-one-out calibration of all training channels (ABI 1.13).

◆ condition_fixed() [1/2]

ConditionedPrediction gpr::capi::Model::condition_fixed ( const std::vector< double > & R_new,
const std::vector< double > & E_new,
const std::vector< double > & G_new,
const std::vector< double > & H_new,
const std::vector< double > & R_query,
int n_coords,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr )
inlinenodiscard

Definition at line 2228 of file gpridge.hpp.

2234 {
2235 return condition_fixed_hessian(R_new, E_new, G_new, &H_new, nullptr,
2236 nullptr, R_query, n_coords, options,
2237 report);
2238 }
ConditionedPrediction condition_fixed_hessian(const std::vector< double > &R_new, const std::vector< double > &E_new, const std::vector< double > &G_new, const std::vector< double > *H_new, HvpFn hvp, void *user_data, const std::vector< double > &R_query, int n_coords, const DerivativeOptions *options=nullptr, DerivativeReport *report=nullptr)
Definition gpridge.hpp:2202

◆ condition_fixed() [2/2]

ConditionedPrediction gpr::capi::Model::condition_fixed ( const std::vector< double > & R_new,
const std::vector< double > & E_new,
const std::vector< double > & G_new,
const std::vector< double > & R_query,
int n_coords,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr )
inlinenodiscard

Condition on oracle rows (G_new = dE/dR) at the current hyperparameters and predict at the rows of R_query.

Definition at line 2163 of file gpridge.hpp.

2168 {
2169 const int n_new = rows_of(R_new, n_coords);
2170 const int n_query = rows_of(R_query, n_coords);
2171 ConditionedPrediction out;
2172 out.energy.resize(static_cast<std::size_t>(n_query));
2173 out.gradient.resize(R_query.size());
2174 out.energy_variance.resize(static_cast<std::size_t>(n_query));
2175 out.gradient_variance.resize(R_query.size());
2177 handle_, options, R_new.data(), R_new.size(), E_new.data(),
2178 E_new.size(), G_new.data(), G_new.size(), n_new, R_query.data(),
2179 R_query.size(), n_query, n_coords, out.energy.data(),
2180 out.energy.size(), out.gradient.data(), out.gradient.size(),
2181 out.energy_variance.data(), out.energy_variance.size(),
2182 out.gradient_variance.data(), out.gradient_variance.size(),
2183 report));
2184 return out;
2185 }
int gpr_model_condition_fixed_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R_new, size_t R_new_len, const double *E_new, size_t E_new_len, const double *G_new, size_t G_new_len, int n_new, const double *R_query, size_t R_query_len, int n_query, int n_coords, double *E_out, size_t E_len, double *G_out, size_t G_len, double *var_E_out, size_t var_E_len, double *var_G_out, size_t var_G_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_condition_fixed.

◆ condition_fixed_hessian()

ConditionedPrediction gpr::capi::Model::condition_fixed_hessian ( const std::vector< double > & R_new,
const std::vector< double > & E_new,
const std::vector< double > & G_new,
const std::vector< double > * H_new,
HvpFn hvp,
void * user_data,
const std::vector< double > & R_query,
int n_coords,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr )
inlinenodiscard

Condition on a fixed point with an optional exact Hessian or Hessian-vector-product callback and predict at R_query.

Definition at line 2202 of file gpridge.hpp.

2208 {
2209 const int n_new = rows_of(R_new, n_coords);
2210 const int n_query = rows_of(R_query, n_coords);
2211 ConditionedPrediction out;
2212 out.energy.resize(static_cast<std::size_t>(n_query));
2213 out.gradient.resize(R_query.size());
2214 out.energy_variance.resize(static_cast<std::size_t>(n_query));
2215 out.gradient_variance.resize(R_query.size());
2217 handle_, options, R_new.data(), R_new.size(), E_new.data(),
2218 E_new.size(), G_new.data(), G_new.size(), n_new,
2219 H_new ? H_new->data() : nullptr, H_new ? H_new->size() : 0, hvp,
2220 user_data, R_query.data(), R_query.size(), n_query, n_coords,
2221 out.energy.data(), out.energy.size(), out.gradient.data(),
2222 out.gradient.size(), out.energy_variance.data(),
2223 out.energy_variance.size(), out.gradient_variance.data(),
2224 out.gradient_variance.size(), report));
2225 return out;
2226 }
int gpr_model_condition_fixed_hessian_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R_new, size_t R_new_len, const double *E_new, size_t E_new_len, const double *G_new, size_t G_new_len, int n_new, const double *H_new, size_t H_new_len, gpr_hvp_fn hvp, void *user_data, const double *R_query, size_t R_query_len, int n_query, int n_coords, double *E_out, size_t E_len, double *G_out, size_t G_len, double *var_E_out, size_t var_E_len, double *var_G_out, size_t var_G_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_condition_fixed_hessian; H_new_len is ignored when H_new is NULL.

◆ condition_fixed_hessian_unchecked()

void gpr::capi::Model::condition_fixed_hessian_unchecked ( const DerivativeOptions * options,
const double * R_new,
const double * E_new,
const double * G_new,
int n_new,
const double * H_new,
HvpFn hvp,
void * user_data,
const double * R_query,
int n_query,
int n_coords,
double * E_out,
double * G_out,
double * var_E_out,
double * var_G_out,
DerivativeReport * report )
inline

Definition at line 2240 of file gpridge.hpp.

2246 {
2248 handle_, options, R_new, E_new, G_new, n_new, H_new, hvp, user_data,
2249 R_query, n_query, n_coords, E_out, G_out, var_E_out, var_G_out,
2250 report));
2251 }
int gpr_model_condition_fixed_hessian(gpr_model_t model, const gpr_derivative_options_t *options, const double *R_new, const double *E_new, const double *G_new, int n_new, const double *H_new, gpr_hvp_fn hvp, void *user_data, const double *R_query, int n_query, int n_coords, double *E_out, double *G_out, double *var_E_out, double *var_G_out, gpr_derivative_report_t *report)
Condition the posterior on a fixed point with an optional exact Hessian or Hessian-vector-product cal...

◆ condition_fixed_unchecked()

void gpr::capi::Model::condition_fixed_unchecked ( const DerivativeOptions * options,
const double * R_new,
const double * E_new,
const double * G_new,
int n_new,
const double * R_query,
int n_query,
int n_coords,
double * E_out,
double * G_out,
double * var_E_out,
double * var_G_out,
DerivativeReport * report )
inline

Definition at line 2187 of file gpridge.hpp.

2194 {
2196 handle_, options, R_new, E_new, G_new, n_new, R_query, n_query,
2197 n_coords, E_out, G_out, var_E_out, var_G_out, report));
2198 }
int gpr_model_condition_fixed(gpr_model_t model, const gpr_derivative_options_t *options, const double *R_new, const double *E_new, const double *G_new, int n_new, const double *R_query, int n_query, int n_coords, double *E_out, double *G_out, double *var_E_out, double *var_G_out, gpr_derivative_report_t *report)
Condition the posterior on new oracle rows with the hyperparameters held fixed, then predict at query...

◆ create()

Model gpr::capi::Model::create ( ModelType type = ModelType::Gp)
inlinestaticnodiscard

Definition at line 1502 of file gpridge.hpp.

1503 {
1505 if (!h) throw Error(gpr_last_status(), gpr_last_error_message());
1506 return Model(h, adopt);
1507 }
ModelType type() const
Definition gpridge.hpp:1539
gpr_model_type_t
Model type tag.
Definition gpridge_c.h:318
int gpr_last_status(void)
Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns ...
const char * gpr_last_error_message(void)
The same string as gpr_last_error (ABI 1.6). Never NULL. Fortran and the other bindings call this nam...
struct gpr_model_s * gpr_model_t
Type-safe opaque handles. In Fortran, declare as type(c_ptr). The compiler catches type mismatches (u...
Definition gpridge_c.h:384
gpr_model_t gpr_model_create(gpr_model_type_t type)
Create a GP or TP model. Returns NULL on failure.
constexpr adopt_t adopt
Definition gpridge.hpp:37

◆ fit_iterations()

int gpr::capi::Model::fit_iterations ( ) const
inlinenodiscard

Optimizer iterations of the last train: rgmin's SCG steps plus the L-BFGS fallback steps that finish a stalled rgmin SCG fit.

Definition at line 1885 of file gpridge.hpp.

1886 {
1887 return gpr_model_fit_iterations(handle_);
1888 }
int gpr_model_fit_iterations(gpr_model_t model)
Iterations the last train ran, or -1 when the model is missing.

◆ fit_restarts()

int gpr::capi::Model::fit_restarts ( ) const
inlinenodiscard

Definition at line 1890 of file gpridge.hpp.

1891 {
1892 int out = 0;
1893 check(gpr_model_fit_restarts(handle_, &out));
1894 return out;
1895 }
int gpr_model_fit_restarts(gpr_model_t model, int *out)
Restarts the last train needed (ABI 1.15).

◆ fit_stop_reason()

std::string gpr::capi::Model::fit_stop_reason ( ) const
inlinenodiscard

Why the last train stopped: "budget" when an rgmin fit exhausts its iteration budget, "library" when it does not, "restored scg point" when a rejected L-BFGS fallback restores the SCG point, "wall-clock limit" when the wall is already spent, "non-finite marginal likelihood" when a failed fit keeps a non-finite input marginal likelihood, "unset" before any train, and "missing" for a NULL handle.

Definition at line 1903 of file gpridge.hpp.

1904 {
1905 return gpr_model_fit_stop_reason(handle_);
1906 }
const char * gpr_model_fit_stop_reason(gpr_model_t model)
Why the last train stopped, as a static string.

◆ handle()

gpr_model_t gpr::capi::Model::handle ( ) const
inlinenodiscardnoexcept

Definition at line 1530 of file gpridge.hpp.

1531 {
1532 return handle_;
1533 }

◆ hessian_bilinear_covariance()

std::vector< double > gpr::capi::Model::hessian_bilinear_covariance ( const std::vector< double > & R,
int n_coords,
const std::vector< double > & V,
int n_left,
const std::vector< double > & W,
int n_right,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr ) const
inlinenodiscard

Posterior covariance of v_i^T H w_j, one (n_left n_right)^2 matrix per point. A probabilistic estimate, not a bound.

Definition at line 2081 of file gpridge.hpp.

2086 {
2087 const int n = rows_of(R, n_coords);
2088 const std::size_t pairs = static_cast<std::size_t>(n_left) *
2089 static_cast<std::size_t>(n_right);
2090 std::vector<double> cov(static_cast<std::size_t>(n) * pairs * pairs);
2092 handle_, options, R.data(), R.size(), n, n_coords, V.data(),
2093 V.size(), n_left, W.data(), W.size(), n_right, cov.data(),
2094 cov.size(), report));
2095 return cov;
2096 }
int gpr_model_hessian_bilinear_covariance_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, size_t R_len, int n_points, int n_coords, const double *V, size_t V_len, int n_left, const double *W, size_t W_len, int n_right, double *cov_out, size_t cov_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_hessian_bilinear_covariance.

◆ hessian_bilinear_covariance_unchecked()

void gpr::capi::Model::hessian_bilinear_covariance_unchecked ( const DerivativeOptions * options,
const double * R,
int n_points,
int n_coords,
const double * V,
int n_left,
const double * W,
int n_right,
double * cov_out,
DerivativeReport * report ) const
inline

Definition at line 2098 of file gpridge.hpp.

2104 {
2106 handle_, options, R, n_points, n_coords, V, n_left, W, n_right,
2107 cov_out, report));
2108 }
int gpr_model_hessian_bilinear_covariance(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, int n_points, int n_coords, const double *V, int n_left, const double *W, int n_right, double *cov_out, gpr_derivative_report_t *report)
Posterior covariance of the bilinear forms v_i^T H w_j.

◆ hessian_trace_variance()

std::vector< double > gpr::capi::Model::hessian_trace_variance ( const std::vector< double > & R,
int n_coords,
const std::vector< double > & A,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr ) const
inlinenodiscard

Posterior variance of tr(A dH), one symmetric A per point.

Definition at line 2111 of file gpridge.hpp.

2116 {
2117 const int n = rows_of(R, n_coords);
2118 std::vector<double> var(static_cast<std::size_t>(n));
2120 handle_, options, R.data(), R.size(), n, n_coords, A.data(),
2121 A.size(), var.data(), var.size(), report));
2122 return var;
2123 }
int gpr_model_hessian_trace_variance_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, size_t R_len, int n_points, int n_coords, const double *A, size_t A_len, double *var_out, size_t var_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_hessian_trace_variance.

◆ hessian_trace_variance_unchecked()

void gpr::capi::Model::hessian_trace_variance_unchecked ( const DerivativeOptions * options,
const double * R,
int n_points,
int n_coords,
const double * A,
double * var_out,
DerivativeReport * report ) const
inline

Definition at line 2125 of file gpridge.hpp.

2130 {
2131 check(gpr_model_hessian_trace_variance(handle_, options, R, n_points,
2132 n_coords, A, var_out, report));
2133 }
int gpr_model_hessian_trace_variance(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, int n_points, int n_coords, const double *A, double *var_out, gpr_derivative_report_t *report)
Posterior variance of tr(A dH) for one symmetric A per point.

◆ hssvd_backend()

bool gpr::capi::Model::hssvd_backend ( ) const
inlinenodiscard

Definition at line 1991 of file gpridge.hpp.

1992 {
1993 int out = 0;
1996 }
@ GPR_HSSVD_BACKEND_CHOLESKY
Definition gpridge_c.h:273
int gpr_model_get_hssvd_backend(gpr_model_t model, int *out)
Get the selected solver, a gpr_hssvd_backend_t (ABI 1.19).

◆ init()

void gpr::capi::Model::init ( const ModelConfig & config,
const Atoms & atoms )
inline

Definition at line 1544 of file gpridge.hpp.

1545 {
1546 check(gpr_model_init(handle_, &config, atoms.handle()));
1547 }
int gpr_model_init(gpr_model_t model, const gpr_model_config_t *config, gpr_atoms_t atoms)
Initialize model with configuration and atom setup. Must be called before train()....

◆ jitter()

double gpr::capi::Model::jitter ( ) const
inlinenodiscard

Definition at line 1977 of file gpridge.hpp.

1978 {
1979 double out = 0.0;
1980 check(gpr_model_get_jitter(handle_, &out));
1981 return out;
1982 }
int gpr_model_get_jitter(gpr_model_t model, double *out)
Get the initialized model's numerical diagonal jitter variance.

◆ lengthscales()

std::vector< double > gpr::capi::Model::lengthscales ( ) const
inlinenodiscard

Definition at line 1913 of file gpridge.hpp.

1914 {
1915 const int n = n_lengthscales();
1916 if (n < 0) throw Error(gpr_last_status(), gpr_last_error_message());
1917 std::vector<double> out(static_cast<std::size_t>(n));
1918 if (n > 0) check(gpr_model_get_lengthscales(handle_, out.data()));
1919 return out;
1920 }
int n_lengthscales() const
Definition gpridge.hpp:1908
int gpr_model_get_lengthscales(gpr_model_t model, double *out)
Get lengthscale values into caller-allocated array.

◆ magn_sigma2()

double gpr::capi::Model::magn_sigma2 ( ) const
inlinenodiscard

Definition at line 1928 of file gpridge.hpp.

1929 {
1930 double out = 0.0;
1932 return out;
1933 }
int gpr_model_get_magn_sigma2(gpr_model_t model, double *out)
Get signal variance (magnSigma2).

◆ mean_hessian_action_batch()

std::vector< double > gpr::capi::Model::mean_hessian_action_batch ( const std::vector< double > & R,
int n_coords,
const std::vector< double > & V,
int n_vectors,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr ) const
inlinenodiscard

H(x_b) v for the n_vectors rows of V at each point.

Definition at line 2054 of file gpridge.hpp.

2059 {
2060 const int n = rows_of(R, n_coords);
2061 std::vector<double> Hv(V.size());
2063 handle_, options, R.data(), R.size(), n, n_coords, V.data(),
2064 V.size(), n_vectors, Hv.data(), Hv.size(), report));
2065 return Hv;
2066 }
int gpr_model_mean_hessian_action_batch_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, size_t R_len, int n_points, int n_coords, const double *V, size_t V_len, int n_vectors, double *Hv_out, size_t Hv_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_mean_hessian_action_batch.

◆ mean_hessian_action_batch_unchecked()

void gpr::capi::Model::mean_hessian_action_batch_unchecked ( const DerivativeOptions * options,
const double * R,
int n_points,
int n_coords,
const double * V,
int n_vectors,
double * Hv_out,
DerivativeReport * report ) const
inline

Definition at line 2068 of file gpridge.hpp.

2073 {
2074 check(gpr_model_mean_hessian_action_batch(handle_, options, R, n_points,
2075 n_coords, V, n_vectors,
2076 Hv_out, report));
2077 }
int gpr_model_mean_hessian_action_batch(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, int n_points, int n_coords, const double *V, int n_vectors, double *Hv_out, gpr_derivative_report_t *report)
Posterior-mean Hessian-vector products at n_points points.

◆ mean_hessian_batch()

std::vector< double > gpr::capi::Model::mean_hessian_batch ( const std::vector< double > & R,
int n_coords,
const DerivativeOptions * options = nullptr,
std::vector< double > * residuals_out = nullptr,
DerivativeReport * report = nullptr ) const
inlinenodiscard

Posterior-mean Hessians at the n_points rows of R, point-major and row-major. residuals_out, when non-null, receives six rigid residual norms per point. report is written on success and on GPR_ERR_OUT_OF_SUPPORT.

Definition at line 2021 of file gpridge.hpp.

2026 {
2027 const int n = rows_of(R, n_coords);
2028 std::vector<double> H(R.size() * static_cast<std::size_t>(n_coords));
2029 double* res = nullptr;
2030 std::size_t res_len = 0;
2031 if (residuals_out) {
2032 residuals_out->assign(static_cast<std::size_t>(n) * 6, 0.0);
2033 res = residuals_out->data();
2034 res_len = residuals_out->size();
2035 }
2037 handle_, options, R.data(), R.size(), n, n_coords, H.data(),
2038 H.size(), res, res_len, report));
2039 return H;
2040 }
int gpr_model_mean_hessian_batch_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, size_t R_len, int n_points, int n_coords, double *H_out, size_t H_len, double *residuals_out, size_t residuals_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_mean_hessian_batch; residuals_len is ignored when residuals_out is NULL.

◆ mean_hessian_batch_unchecked()

void gpr::capi::Model::mean_hessian_batch_unchecked ( const DerivativeOptions * options,
const double * R,
int n_points,
int n_coords,
double * H_out,
double * residuals_out,
DerivativeReport * report ) const
inline

Definition at line 2042 of file gpridge.hpp.

2047 {
2048 check(gpr_model_mean_hessian_batch(handle_, options, R, n_points,
2049 n_coords, H_out, residuals_out,
2050 report));
2051 }
int gpr_model_mean_hessian_batch(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, int n_points, int n_coords, double *H_out, double *residuals_out, gpr_derivative_report_t *report)
Posterior-mean Hessians at n_points points.

◆ n_lengthscales()

int gpr::capi::Model::n_lengthscales ( ) const
inlinenodiscard

Definition at line 1908 of file gpridge.hpp.

1909 {
1910 return gpr_model_n_lengthscales(handle_);
1911 }
int gpr_model_n_lengthscales(gpr_model_t model)
Number of kernel lengthscale parameters.

◆ n_observations()

int gpr::capi::Model::n_observations ( ) const
inlinenodiscard

Definition at line 1998 of file gpridge.hpp.

1999 {
2000 return gpr_model_n_observations(handle_);
2001 }
int gpr_model_n_observations(gpr_model_t model)
Number of training observations currently stored.

◆ noise_floor_report()

NoiseFloorReport gpr::capi::Model::noise_floor_report ( ) const
inlinenodiscard

Definition at line 1846 of file gpridge.hpp.

1847 {
1850 return out;
1851 }
int gpr_model_get_noise_floor_report(gpr_model_t model, gpr_noise_floor_report_t *out)
Report the condition-floored noise and certificate gap of a trained model (ABI 1.14).
gpr_noise_floor_report_t NoiseFloorReport
Definition gpridge.hpp:246

◆ operator bool()

gpr::capi::Model::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Definition at line 1534 of file gpridge.hpp.

1535 {
1536 return handle_ != nullptr;
1537 }

◆ operator=() [1/2]

Model & gpr::capi::Model::operator= ( const Model & )
delete

◆ operator=() [2/2]

Model & gpr::capi::Model::operator= ( Model && other)
inlinenoexcept

Definition at line 1490 of file gpridge.hpp.

1491 {
1492 if (this != &other) {
1493 reset();
1494 handle_ = other.handle_;
1495 owns_ = other.owns_;
1496 other.handle_ = nullptr;
1497 other.owns_ = false;
1498 }
1499 return *this;
1500 }

◆ owns()

bool gpr::capi::Model::owns ( ) const
inlinenodiscardnoexcept

Definition at line 1526 of file gpridge.hpp.

1527 {
1528 return owns_;
1529 }

◆ posterior_variance_batch()

std::pair< std::vector< double >, std::vector< double > > gpr::capi::Model::posterior_variance_batch ( const std::vector< double > & R,
int n_coords,
const DerivativeOptions * options = nullptr,
DerivativeReport * report = nullptr ) const
inlinenodiscard

Posterior energy variances and gradient component variances.

Definition at line 2137 of file gpridge.hpp.

2140 {
2141 const int n = rows_of(R, n_coords);
2142 std::vector<double> var_E(static_cast<std::size_t>(n));
2143 std::vector<double> var_G(R.size());
2145 handle_, options, R.data(), R.size(), n, n_coords, var_E.data(),
2146 var_E.size(), var_G.data(), var_G.size(), report));
2147 return {std::move(var_E), std::move(var_G)};
2148 }
int gpr_model_posterior_variance_batch_checked(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, size_t R_len, int n_points, int n_coords, double *var_E_out, size_t var_E_len, double *var_G_out, size_t var_G_len, gpr_derivative_report_t *report)
Extent-checked gpr_model_posterior_variance_batch.

◆ posterior_variance_batch_unchecked()

void gpr::capi::Model::posterior_variance_batch_unchecked ( const DerivativeOptions * options,
const double * R,
int n_points,
int n_coords,
double * var_E_out,
double * var_G_out,
DerivativeReport * report ) const
inline

Definition at line 2150 of file gpridge.hpp.

2155 {
2156 check(gpr_model_posterior_variance_batch(handle_, options, R, n_points,
2157 n_coords, var_E_out, var_G_out,
2158 report));
2159 }
int gpr_model_posterior_variance_batch(gpr_model_t model, const gpr_derivative_options_t *options, const double *R, int n_points, int n_coords, double *var_E_out, double *var_G_out, gpr_derivative_report_t *report)
Posterior variance of the energy and of each gradient component.

◆ predict() [1/2]

void gpr::capi::Model::predict ( const double * R_query,
std::size_t R_len,
double * E_out,
double * G_out,
std::size_t G_len,
int n_coords ) const
inline

Definition at line 1667 of file gpridge.hpp.

1669 {
1670 check(gpr_model_predict_checked(handle_, R_query, R_len, E_out, G_out,
1671 G_len, n_coords));
1672 }
int gpr_model_predict_checked(gpr_model_t model, const double *R_query, size_t R_len, double *E_out, double *G_out, size_t G_len, int n_coords)
Extent-checked gpr_model_predict (ABI 1.11).

◆ predict() [2/2]

std::pair< double, std::vector< double > > gpr::capi::Model::predict ( const std::vector< double > & R_query) const
inline

Definition at line 1674 of file gpridge.hpp.

1676 {
1677 const int n_coords = static_cast<int>(R_query.size());
1678 double e = 0.0;
1679 std::vector<double> g(static_cast<std::size_t>(n_coords));
1680 predict(R_query.data(), R_query.size(), &e, g.data(), g.size(),
1681 n_coords);
1682 return {e, std::move(g)};
1683 }
void predict(const double *R_query, std::size_t R_len, double *E_out, double *G_out, std::size_t G_len, int n_coords) const
Definition gpridge.hpp:1667

◆ predict_batch()

void gpr::capi::Model::predict_batch ( const double * R_queries,
std::size_t R_len,
double * E_out,
std::size_t E_len,
double * G_out,
std::size_t G_len,
double * var_E_out,
std::size_t var_E_len,
double * var_G_out,
std::size_t var_G_len,
int n_queries,
int n_coords ) const
inline

Definition at line 1736 of file gpridge.hpp.

1741 {
1743 handle_, R_queries, R_len, E_out, E_len, G_out, G_len, var_E_out,
1744 var_E_len, var_G_out, var_G_len, n_queries, n_coords));
1745 }
int gpr_model_predict_batch_checked(gpr_model_t model, const double *R_queries, size_t R_len, double *E_out, size_t E_len, double *G_out, size_t G_len, double *var_E_out, size_t var_E_len, double *var_G_out, size_t var_G_len, int n_queries, int n_coords)
Extent-checked gpr_model_predict_batch (ABI 1.11).

◆ predict_batch_unchecked()

void gpr::capi::Model::predict_batch_unchecked ( const double * R_queries,
double * E_out,
double * G_out,
double * var_E_out,
double * var_G_out,
int n_queries,
int n_coords ) const
inline

Definition at line 1747 of file gpridge.hpp.

1751 {
1752 check(gpr_model_predict_batch(handle_, R_queries, E_out, G_out,
1753 var_E_out, var_G_out, n_queries,
1754 n_coords));
1755 }
int gpr_model_predict_batch(gpr_model_t model, const double *R_queries, double *E_out, double *G_out, double *var_E_out, double *var_G_out, int n_queries, int n_coords)
Batch prediction at multiple query points. var_E_out and var_G_out may be NULL to skip variance.

◆ predict_energy_variance_interval() [1/2]

void gpr::capi::Model::predict_energy_variance_interval ( const double * R_queries,
std::size_t R_len,
double * lower,
std::size_t lower_len,
double * upper,
std::size_t upper_len,
int n_queries,
int n_coords ) const
inline

Definition at line 1807 of file gpridge.hpp.

1812 {
1814 handle_, R_queries, R_len, n_queries, n_coords, lower, lower_len,
1815 upper, upper_len));
1816 }
int gpr_model_predict_energy_variance_interval_checked(gpr_model_t model, const double *R_queries, size_t R_len, int n_queries, int n_coords, double *var_E_lower_out, size_t var_E_lower_len, double *var_E_upper_out, size_t var_E_upper_len)
Extent-checked energy-variance enclosure (ABI 1.14).

◆ predict_energy_variance_interval() [2/2]

std::pair< std::vector< double >, std::vector< double > > gpr::capi::Model::predict_energy_variance_interval ( const std::vector< double > & R_queries,
int n_coords ) const
inlinenodiscard

Certified [lower, upper] energy-variance enclosures, one pair per query row of the contiguous n_queries * n_coords array.

Definition at line 1821 of file gpridge.hpp.

1823 {
1824 const int n_queries =
1825 n_coords > 0 ? static_cast<int>(R_queries.size() /
1826 static_cast<std::size_t>(n_coords))
1827 : 0;
1828 std::vector<double> lower(static_cast<std::size_t>(n_queries));
1829 std::vector<double> upper(static_cast<std::size_t>(n_queries));
1831 R_queries.data(), R_queries.size(), lower.data(), lower.size(),
1832 upper.data(), upper.size(), n_queries, n_coords);
1833 return {std::move(lower), std::move(upper)};
1834 }
void predict_energy_variance_interval(const double *R_queries, std::size_t R_len, double *lower, std::size_t lower_len, double *upper, std::size_t upper_len, int n_queries, int n_coords) const
Definition gpridge.hpp:1807

◆ predict_energy_variance_interval_unchecked()

void gpr::capi::Model::predict_energy_variance_interval_unchecked ( const double * R_queries,
double * lower,
double * upper,
int n_queries,
int n_coords ) const
inline

Definition at line 1836 of file gpridge.hpp.

1841 {
1843 handle_, R_queries, n_queries, n_coords, lower, upper));
1844 }
int gpr_model_predict_energy_variance_interval(gpr_model_t model, const double *R_queries, int n_queries, int n_coords, double *var_E_lower_out, double *var_E_upper_out)
Certified energy-variance enclosure [lower, upper] for each query (ABI 1.14).

◆ predict_full()

void gpr::capi::Model::predict_full ( const double * R_query,
std::size_t R_len,
double * E_out,
double * G_out,
std::size_t G_len,
double * var_E_out,
double * var_G_out,
std::size_t var_G_len,
int n_coords ) const
inline

Definition at line 1718 of file gpridge.hpp.

1722 {
1723 check(gpr_model_predict_full_checked(handle_, R_query, R_len, E_out,
1724 G_out, G_len, var_E_out, var_G_out,
1725 var_G_len, n_coords));
1726 }
int gpr_model_predict_full_checked(gpr_model_t model, const double *R_query, size_t R_len, double *E_out, double *G_out, size_t G_len, double *var_E_out, double *var_G_out, size_t var_G_len, int n_coords)
Extent-checked gpr_model_predict_full (ABI 1.11).

◆ predict_full_unchecked()

void gpr::capi::Model::predict_full_unchecked ( const double * R_query,
double * E_out,
double * G_out,
double * var_E_out,
double * var_G_out,
int n_coords ) const
inline

Definition at line 1728 of file gpridge.hpp.

1731 {
1732 check(gpr_model_predict_full(handle_, R_query, E_out, G_out, var_E_out,
1733 var_G_out, n_coords));
1734 }
int gpr_model_predict_full(gpr_model_t model, const double *R_query, double *E_out, double *G_out, double *var_E_out, double *var_G_out, int n_coords)
Predict energy, gradient, and variance in one call.

◆ predict_hessian() [1/2]

void gpr::capi::Model::predict_hessian ( const double * R_query,
std::size_t R_len,
double * H_out,
std::size_t H_len,
int n_coords ) const
inline

Definition at line 1757 of file gpridge.hpp.

1759 {
1760 check(gpr_model_predict_hessian_checked(handle_, R_query, R_len, H_out,
1761 H_len, n_coords));
1762 }
int gpr_model_predict_hessian_checked(gpr_model_t model, const double *R_query, size_t R_len, double *H_out, size_t H_len, int n_coords)
Extent-checked mean-Hessian prediction (ABI 1.24).

◆ predict_hessian() [2/2]

std::vector< double > gpr::capi::Model::predict_hessian ( const std::vector< double > & R_query) const
inlinenodiscard

Definition at line 1764 of file gpridge.hpp.

1766 {
1767 const int n_coords = static_cast<int>(R_query.size());
1768 std::vector<double> H(static_cast<std::size_t>(n_coords) * n_coords);
1769 predict_hessian(R_query.data(), R_query.size(), H.data(), H.size(),
1770 n_coords);
1771 return H;
1772 }
void predict_hessian(const double *R_query, std::size_t R_len, double *H_out, std::size_t H_len, int n_coords) const
Definition gpridge.hpp:1757

◆ predict_hessian_action() [1/2]

void gpr::capi::Model::predict_hessian_action ( const double * R_query,
std::size_t R_len,
const double * v,
std::size_t v_len,
double * Hv_out,
std::size_t Hv_len,
int n_coords ) const
inline

Definition at line 1780 of file gpridge.hpp.

1784 {
1786 handle_, R_query, R_len, v, v_len, Hv_out, Hv_len, n_coords));
1787 }
int gpr_model_predict_hessian_action_checked(gpr_model_t model, const double *R_query, size_t R_len, const double *v, size_t v_len, double *Hv_out, size_t Hv_len, int n_coords)
Extent-checked mean-Hessian action (ABI 1.12).

◆ predict_hessian_action() [2/2]

std::vector< double > gpr::capi::Model::predict_hessian_action ( const std::vector< double > & R_query,
const std::vector< double > & v ) const
inlinenodiscard

Definition at line 1789 of file gpridge.hpp.

1791 {
1792 const int n_coords = static_cast<int>(R_query.size());
1793 std::vector<double> hv(static_cast<std::size_t>(n_coords));
1794 predict_hessian_action(R_query.data(), R_query.size(), v.data(),
1795 v.size(), hv.data(), hv.size(), n_coords);
1796 return hv;
1797 }
void predict_hessian_action(const double *R_query, std::size_t R_len, const double *v, std::size_t v_len, double *Hv_out, std::size_t Hv_len, int n_coords) const
Definition gpridge.hpp:1780

◆ predict_hessian_action_unchecked()

void gpr::capi::Model::predict_hessian_action_unchecked ( const double * R_query,
const double * v,
double * Hv_out,
int n_coords ) const
inline

Definition at line 1799 of file gpridge.hpp.

1802 {
1803 check(gpr_model_predict_hessian_action(handle_, R_query, v, Hv_out,
1804 n_coords));
1805 }
int gpr_model_predict_hessian_action(gpr_model_t model, const double *R_query, const double *v, double *Hv_out, int n_coords)
One action of the prepared posterior-mean Hessian (ABI 1.8): Hv_out = H(R_query) v.

◆ predict_hessian_unchecked()

void gpr::capi::Model::predict_hessian_unchecked ( const double * R_query,
double * H_out,
int n_coords ) const
inline

Definition at line 1774 of file gpridge.hpp.

1776 {
1777 check(gpr_model_predict_hessian(handle_, R_query, H_out, n_coords));
1778 }
int gpr_model_predict_hessian(gpr_model_t model, const double *R_query, double *H_out, int n_coords)
Dense Hessian of the posterior mean at a query point.

◆ predict_unchecked()

void gpr::capi::Model::predict_unchecked ( const double * R_query,
double * E_out,
double * G_out,
int n_coords ) const
inline

Definition at line 1685 of file gpridge.hpp.

1687 {
1688 check(gpr_model_predict(handle_, R_query, E_out, G_out, n_coords));
1689 }
int gpr_model_predict(gpr_model_t model, const double *R_query, double *E_out, double *G_out, int n_coords)
Predict energy and gradient at a query point.

◆ predict_variance() [1/2]

void gpr::capi::Model::predict_variance ( const double * R_query,
std::size_t R_len,
double * var_E_out,
double * var_G_out,
std::size_t var_G_len,
int n_coords ) const
inline

Definition at line 1691 of file gpridge.hpp.

1694 {
1695 check(gpr_model_predict_variance_checked(handle_, R_query, R_len,
1696 var_E_out, var_G_out,
1697 var_G_len, n_coords));
1698 }
int gpr_model_predict_variance_checked(gpr_model_t model, const double *R_query, size_t R_len, double *var_E_out, double *var_G_out, size_t var_G_len, int n_coords)
Extent-checked gpr_model_predict_variance (ABI 1.11).

◆ predict_variance() [2/2]

std::pair< double, std::vector< double > > gpr::capi::Model::predict_variance ( const std::vector< double > & R_query) const
inline

Definition at line 1700 of file gpridge.hpp.

1702 {
1703 const int n_coords = static_cast<int>(R_query.size());
1704 double ve = 0.0;
1705 std::vector<double> vg(static_cast<std::size_t>(n_coords));
1706 predict_variance(R_query.data(), R_query.size(), &ve, vg.data(),
1707 vg.size(), n_coords);
1708 return {ve, std::move(vg)};
1709 }
void predict_variance(const double *R_query, std::size_t R_len, double *var_E_out, double *var_G_out, std::size_t var_G_len, int n_coords) const
Definition gpridge.hpp:1691

◆ predict_variance_unchecked()

void gpr::capi::Model::predict_variance_unchecked ( const double * R_query,
double * var_E_out,
double * var_G_out,
int n_coords ) const
inline

Definition at line 1711 of file gpridge.hpp.

1713 {
1714 check(gpr_model_predict_variance(handle_, R_query, var_E_out, var_G_out,
1715 n_coords));
1716 }
int gpr_model_predict_variance(gpr_model_t model, const double *R_query, double *var_E_out, double *var_G_out, int n_coords)
Predict variance at a query point.

◆ prediction_factors()

int gpr::capi::Model::prediction_factors ( const double * R_query,
int n_coords,
double * energy,
double * scale,
double * mean,
double * kstar,
double * weights,
int capacity ) const
inline

Definition at line 1872 of file gpridge.hpp.

1875 {
1876 int order = 0;
1877 check(gpr_model_prediction_factors(handle_, R_query, n_coords, energy,
1878 scale, mean, kstar, weights,
1879 capacity, &order));
1880 return order;
1881 }
int gpr_model_prediction_factors(gpr_model_t model, const double *R_query, int n_coords, double *energy, double *scale, double *mean, double *kstar, double *weights, int capacity, int *order)
Factors of one trained energy prediction. energy is the library prediction. scale and mean undo the t...

◆ prediction_supported()

bool gpr::capi::Model::prediction_supported ( const std::vector< double > & R_query) const
inlinenodiscard

Definition at line 1853 of file gpridge.hpp.

1855 {
1856 int supported = 0;
1858 handle_, R_query.data(), R_query.size(),
1859 static_cast<int>(R_query.size()), &supported));
1860 return supported != 0;
1861 }
int gpr_model_prediction_supported_checked(gpr_model_t model, const double *R_query, size_t R_len, int n_coords, int *supported)
Extent-checked prediction-support query (ABI 1.12).

◆ prediction_supported_unchecked()

bool gpr::capi::Model::prediction_supported_unchecked ( const double * R_query,
int n_coords ) const
inlinenodiscard

Definition at line 1863 of file gpridge.hpp.

1865 {
1866 int supported = 0;
1867 check(gpr_model_prediction_supported(handle_, R_query, n_coords,
1868 &supported));
1869 return supported != 0;
1870 }
int gpr_model_prediction_supported(gpr_model_t model, const double *R_query, int n_coords, int *supported)
Whether the trained prediction kernel supports a query (ABI 1.12).

◆ release()

gpr_model_t gpr::capi::Model::release ( )
inlinenodiscardnoexcept

Definition at line 1518 of file gpridge.hpp.

1519 {
1520 gpr_model_t h = handle_;
1521 handle_ = nullptr;
1522 owns_ = false;
1523 return h;
1524 }

◆ reset()

void gpr::capi::Model::reset ( )
inlinenoexcept

Definition at line 1509 of file gpridge.hpp.

1510 {
1511 if (handle_ && owns_) {
1512 gpr_model_destroy(handle_);
1513 }
1514 handle_ = nullptr;
1515 owns_ = false;
1516 }
void gpr_model_destroy(gpr_model_t model)
Destroy model. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(),...

◆ rff_selection()

RffSelection gpr::capi::Model::rff_selection ( ) const
inlinenodiscard

Definition at line 1958 of file gpridge.hpp.

1959 {
1960 RffSelection out{};
1962 return out;
1963 }
int gpr_model_get_rff_selection(gpr_model_t model, gpr_rff_selection_t *out)
Copy the stored selection. Before a train this is the empty report.
gpr_rff_selection_t RffSelection
Definition gpridge.hpp:243

◆ rigid_null_deflation()

bool gpr::capi::Model::rigid_null_deflation ( ) const
inlinenodiscard

Definition at line 1970 of file gpridge.hpp.

1971 {
1972 int out = 0;
1974 return out != 0;
1975 }
int gpr_model_get_rigid_null_deflation(gpr_model_t model, int *out)
Query whether rigid-motion nullspace deflation is enabled (ABI 1.22).

◆ set_hssvd_backend()

void gpr::capi::Model::set_hssvd_backend ( bool enabled)
inline

Definition at line 1984 of file gpridge.hpp.

1985 {
1987 handle_,
1989 }
@ GPR_HSSVD_BACKEND_HSSVD
Definition gpridge_c.h:272
int gpr_model_set_hssvd_backend(gpr_model_t model, int selection)
Select the posterior solver for the next train (ABI 1.19). The value is a gpr_hssvd_backend_t,...

◆ set_lengthscales()

void gpr::capi::Model::set_lengthscales ( const std::vector< double > & values)
inline

Definition at line 1922 of file gpridge.hpp.

1923 {
1924 check(gpr_model_set_lengthscales(handle_, values.data(),
1925 static_cast<int>(values.size())));
1926 }
int gpr_model_set_lengthscales(gpr_model_t model, const double *values, int n_values)
Set lengthscale values.

◆ set_magn_sigma2()

void gpr::capi::Model::set_magn_sigma2 ( double value)
inline

Definition at line 1935 of file gpridge.hpp.

1936 {
1937 check(gpr_model_set_magn_sigma2(handle_, value));
1938 }
int gpr_model_set_magn_sigma2(gpr_model_t model, double value)
Set signal variance.

◆ set_rff_features()

void gpr::capi::Model::set_rff_features ( int n_features,
double force_tol_fraction = 0.0 )
inline

Definition at line 1952 of file gpridge.hpp.

1953 {
1954 check(gpr_model_set_rff_features(handle_, n_features,
1955 force_tol_fraction));
1956 }
int gpr_model_set_rff_features(gpr_model_t model, int n_features, double force_tol_fraction)
Set the random-feature count or turn held-out selection on (ABI 1.9).

◆ set_rigid_null_deflation()

void gpr::capi::Model::set_rigid_null_deflation ( bool enabled)
inline

Definition at line 1965 of file gpridge.hpp.

1966 {
1967 check(gpr_model_set_rigid_null_deflation(handle_, enabled ? 1 : 0));
1968 }
int gpr_model_set_rigid_null_deflation(gpr_model_t model, int enabled)
Enable or disable rigid-motion nullspace deflation on training factorizations (ABI 1....

◆ set_sigma2()

void gpr::capi::Model::set_sigma2 ( double value)
inline

Definition at line 1947 of file gpridge.hpp.

1948 {
1949 check(gpr_model_set_sigma2(handle_, value));
1950 }
int gpr_model_set_sigma2(gpr_model_t model, double value)
Set a positive finite physical output-noise variance and refresh a trained model's noise-dependent po...

◆ sigma2()

double gpr::capi::Model::sigma2 ( ) const
inlinenodiscard

Definition at line 1940 of file gpridge.hpp.

1941 {
1942 double out = 0.0;
1943 check(gpr_model_get_sigma2(handle_, &out));
1944 return out;
1945 }
int gpr_model_get_sigma2(gpr_model_t model, double *out)
Get physical output-noise variance (sigma2).

◆ tp_prefactor()

double gpr::capi::Model::tp_prefactor ( ) const
inlinenodiscard

Definition at line 2010 of file gpridge.hpp.

2011 {
2012 double out = 0.0;
2013 check(gpr_model_tp_prefactor(handle_, &out));
2014 return out;
2015 }
int gpr_model_tp_prefactor(gpr_model_t model, double *out)
TP-specific: get signal variance prefactor (valid after training).

◆ train() [1/2]

void gpr::capi::Model::train ( const double * R,
std::size_t R_len,
const double * E,
std::size_t E_len,
const double * G,
std::size_t G_len,
int n_obs,
int n_coords )
inline

Definition at line 1549 of file gpridge.hpp.

1552 {
1553 check(gpr_model_train_checked(handle_, R, R_len, E, E_len, G, G_len,
1554 n_obs, n_coords));
1555 }
int gpr_model_train_checked(gpr_model_t model, const double *R, size_t R_len, const double *E, size_t E_len, const double *G, size_t G_len, int n_obs, int n_coords)
Extent-checked forms of the training and prediction calls (ABI 1.11).

◆ train() [2/2]

void gpr::capi::Model::train ( const std::vector< double > & R,
const std::vector< double > & E,
const std::vector< double > & G,
int n_obs,
int n_coords )
inline

Definition at line 1557 of file gpridge.hpp.

1559 {
1560 train(R.data(), R.size(), E.data(), E.size(), G.data(), G.size(), n_obs,
1561 n_coords);
1562 }
void train(const double *R, std::size_t R_len, const double *E, std::size_t E_len, const double *G, std::size_t G_len, int n_obs, int n_coords)
Definition gpridge.hpp:1549

◆ train_marginal_likelihood() [1/2]

std::pair< MarginalLikelihoodReport, std::vector< double > > gpr::capi::Model::train_marginal_likelihood ( const double * R,
std::size_t R_len,
const double * E,
std::size_t E_len,
const double * G,
std::size_t G_len,
int n_obs,
int n_coords )
inlinenodiscard

Definition at line 1571 of file gpridge.hpp.

1575 {
1576 const int n_scales = n_lengthscales();
1577 if (n_scales < 0)
1578 throw Error(gpr_last_status(), gpr_last_error_message());
1579 std::vector<double> lengthscales(static_cast<std::size_t>(n_scales));
1580 MarginalLikelihoodReport report{};
1582 handle_, R, R_len, E, E_len, G, G_len, n_obs, n_coords, &report,
1583 lengthscales.data(), lengthscales.size()));
1584 return {report, std::move(lengthscales)};
1585 }
std::vector< double > lengthscales() const
Definition gpridge.hpp:1913
int gpr_model_train_marginal_likelihood_checked(gpr_model_t model, const double *R, size_t R_len, const double *E, size_t E_len, const double *G, size_t G_len, int n_obs, int n_coords, gpr_marginal_likelihood_report_t *report, double *lengthscales, size_t lengthscales_len)
Fit all supplied rows by prior-free Gaussian marginal likelihood (ABI 1.13).
gpr_marginal_likelihood_report_t MarginalLikelihoodReport
Definition gpridge.hpp:244

◆ train_marginal_likelihood() [2/2]

std::pair< MarginalLikelihoodReport, std::vector< double > > gpr::capi::Model::train_marginal_likelihood ( const std::vector< double > & R,
const std::vector< double > & E,
const std::vector< double > & G,
int n_obs,
int n_coords )
inlinenodiscard

Definition at line 1588 of file gpridge.hpp.

1592 {
1593 return train_marginal_likelihood(R.data(), R.size(), E.data(), E.size(),
1594 G.data(), G.size(), n_obs, n_coords);
1595 }
std::pair< MarginalLikelihoodReport, std::vector< double > > train_marginal_likelihood(const double *R, std::size_t R_len, const double *E, std::size_t E_len, const double *G, std::size_t G_len, int n_obs, int n_coords)
Definition gpridge.hpp:1571

◆ train_unchecked()

void gpr::capi::Model::train_unchecked ( const double * R,
const double * E,
const double * G,
int n_obs,
int n_coords )
inline

Definition at line 1564 of file gpridge.hpp.

1566 {
1567 check(gpr_model_train(handle_, R, E, G, n_obs, n_coords));
1568 }
int gpr_model_train(gpr_model_t model, const double *R, const double *E, const double *G, int n_obs, int n_coords)
Train the model on observations.

◆ type()

ModelType gpr::capi::Model::type ( ) const
inlinenodiscard

Definition at line 1539 of file gpridge.hpp.

1540 {
1541 return static_cast<ModelType>(gpr_model_type(handle_));
1542 }
gpr_model_type_t gpr_model_type(gpr_model_t model)
Query model type.

◆ update() [1/2]

void gpr::capi::Model::update ( const double * R_new,
std::size_t R_len,
const double * E_new,
std::size_t E_len,
const double * G_new,
std::size_t G_len,
int n_new,
int n_coords )
inline

Definition at line 1597 of file gpridge.hpp.

1600 {
1601 check(gpr_model_update_checked(handle_, R_new, R_len, E_new, E_len,
1602 G_new, G_len, n_new, n_coords));
1603 }
int gpr_model_update_checked(gpr_model_t model, const double *R_new, size_t R_len, const double *E_new, size_t E_len, const double *G_new, size_t G_len, int n_new, int n_coords)
Extent-checked gpr_model_update (ABI 1.11).

◆ update() [2/2]

void gpr::capi::Model::update ( const std::vector< double > & R_new,
const std::vector< double > & E_new,
const std::vector< double > & G_new,
int n_new,
int n_coords )
inline

Definition at line 1605 of file gpridge.hpp.

1608 {
1609 update(R_new.data(), R_new.size(), E_new.data(), E_new.size(),
1610 G_new.data(), G_new.size(), n_new, n_coords);
1611 }
void update(const double *R_new, std::size_t R_len, const double *E_new, std::size_t E_len, const double *G_new, std::size_t G_len, int n_new, int n_coords)
Definition gpridge.hpp:1597

◆ update_unchecked()

void gpr::capi::Model::update_unchecked ( const double * R_new,
const double * E_new,
const double * G_new,
int n_new,
int n_coords )
inline

Definition at line 1613 of file gpridge.hpp.

1615 {
1616 check(gpr_model_update(handle_, R_new, E_new, G_new, n_new, n_coords));
1617 }
int gpr_model_update(gpr_model_t model, const double *R_new, const double *E_new, const double *G_new, int n_new, int n_coords)
Incremental update: append observations and retrain.

The documentation for this class was generated from the following file: