Loading...
Searching...
No Matches
gpridge_c.h File Reference

C API of libgpridge: Gaussian process accelerated saddle point searches and minimisation on potential energy surfaces. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  gpr_atoms_config_t
 Atoms configuration descriptor. Describes the atomic system for the GP kernel (pair types, frozen atoms). More...
struct  gpr_model_config_t
 GP/TP model configuration. All fields have sensible defaults via gpr_model_config_defaults(). More...
struct  gpr_marginal_likelihood_report_t
 Prior-free marginal-likelihood fit result (ABI 1.13). More...
struct  gpr_calibration_report_t
 Gaussian residual-calibration report shared by ABI 1.13 workflows. More...
struct  gpr_bq_config_t
 Scalar GP and Bayesian quadrature configuration (ABI 1.17). More...
struct  gpr_bq_integral_report_t
 Posterior decomposition for a Bayesian quadrature integral. More...
struct  gpr_bq_uncertainty_t
 Integral uncertainty split by source. variance is the historical report, including the leave-one-out factor. The other fields are not coverage corrections: loo_predictive_scale may be below one, and numerical_abs_tolerance is a moment bound that is not added into variance. More...
struct  gpr_bq_loo_report_t
 LOO summary plus the number of z-scores written separately. More...
struct  gpr_bq_fit_report_t
 Result of a Bayesian quadrature hyperparameter fit (ABI 1.17). More...
struct  gpr_dimer_config_t
 Dimer search configuration. More...
struct  gpr_neb_config_t
 NEB search configuration. More...
struct  gpr_local_band_config_t
 Local-band knobs (ABI 1.6), the gp_local_* fields of the C++ config. Start from gpr_local_band_config_defaults(). Lengths are Angstrom. force_stop_certificate asks for the band index certificate; certificate_step is the stencil displacement, and 0 keeps the library step. gpr_neb_search_local is the entry point: gpr_neb_search and gpr_neb_search_potential reject GPR_NEB_GP_LOCAL with GPR_ERR_INVALID_ARG (kLocalModeEntry). More...
struct  gpr_periodic_band_config_t
 Periodic local band (ABI 1.7): the choices GPLocalBand makes on top of gpr_local_band_config_t. Start from gpr_periodic_band_config_defaults(). Lengths are Angstrom, fmax is eV/Angstrom. convergence_norm -1 keeps the mode's own norm; otherwise it is a gpr_conv_norm_t. The local knobs and the certificate stay on gpr_local_band_config_t and gpr_neb_request_index_certificate: this struct does not repeat them. More...
struct  gpr_minimize_config_t
 Minimizer configuration. More...
struct  gpr_noise_floor_report
 Noise a trained model conditions on and the interval's certificate margin (ABI 1.14). More...
struct  gpr_derivative_options
 Options of the derivative primitives (ABI 1.20). More...
struct  gpr_derivative_report
 Report of one derivative call (ABI 1.20). More...
struct  gpr_htst_options
 Prefactor options (ABI 1.20). More...
struct  gpr_htst_half
 One half of the prefactor (ABI 1.20). More...
struct  gpr_fes_config_t
 Free-energy surrogate configuration (ABI 1.23). More...
struct  gpr_fes_rate_config_t
 Posterior-sampled Kramers rate configuration (ABI 1.23). More...
struct  gpr_fes_rate_report_t
 Summary of the accepted posterior rate draws (ABI 1.23). More...
struct  gpr_rff_selection
 Report of the held-out random-feature selection (ABI 1.9). More...
struct  gpr_dimer_report_t
 Outcome of gpr_dimer_search_report (ABI 1.1). The caller sets struct_size = sizeof(gpr_dimer_report_t); the library fills only the fields that fit, so a struct extended at the end stays compatible. More...
struct  gpr_neb_report_t
 Outcome of a NEB run (ABI 1.2), read from any result handle with gpr_neb_result_report. The caller sets struct_size = sizeof(gpr_neb_report_t); the library fills only the fields that fit, so a struct extended at the end stays compatible. More...
struct  gpr_ocineb_config_t
 OCINEB controls (ABI 1.2): the minimum-mode dimer bursts that drive the climbing image of a GP band onto the saddle. Start from gpr_ocineb_config_defaults(). More...
struct  gpr_lj_params_t
 Oracle adapters: wrap analytical potentials as gpr_oracle_fn. Pass directly to gpr_neb_search() or gpr_minimize(). More...

Macros

#define GPR_C_ABI_MAJOR   1
 ABI version of this header. See the ABI paragraph above.
#define GPR_C_ABI_MINOR   26
#define GPR_ABI_CHECK()
 Check the loaded library against the header in use. Call once at start.
#define GPR_HTST_OMEGA_EV_ANGSTROM_AMU   9.82269385e13
 sqrt(eV / (Angstrom^2 amu)) in rad/s.

Typedefs

typedef struct gpr_model_s * gpr_model_t
 Type-safe opaque handles. In Fortran, declare as type(c_ptr). The compiler catches type mismatches (unlike void*).
typedef struct gpr_bq_s * gpr_bq_t
typedef struct gpr_fes_s * gpr_fes_t
typedef struct gpr_sgp_s * gpr_sgp_t
typedef struct gpr_psearch_s * gpr_psearch_t
typedef struct gpr_atoms_s * gpr_atoms_t
typedef struct gpr_neb_s * gpr_neb_t
typedef struct gpr_potential_s * gpr_potential_t
typedef void(* gpr_force_fn) (long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, const double *box, void *user_data)
 Full atomistic force callback (used by dimer search).
typedef void(* gpr_force_with_uncertainty_fn) (long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, double *force_noise_rms, const double *box, void *user_data)
 Force callback with separate energy and force uncertainty channels.
typedef void(* gpr_oracle_fn) (int n_coords, const double *positions, double *energy, double *gradient, void *user_data)
 Simple oracle callback (used by NEB and minimizer).
typedef struct gpr_noise_floor_report gpr_noise_floor_report_t
 Noise a trained model conditions on and the interval's certificate margin (ABI 1.14).
typedef struct gpr_derivative_options gpr_derivative_options_t
 Options of the derivative primitives (ABI 1.20).
typedef struct gpr_derivative_report gpr_derivative_report_t
 Report of one derivative call (ABI 1.20).
typedef void(* gpr_hvp_fn) (int n_coords, const double *positions, const double *vector, double *hv_out, void *user_data)
 Hessian-vector-product callback at a fixed point (ABI 1.20).
typedef struct gpr_htst_options gpr_htst_options_t
 Prefactor options (ABI 1.20).
typedef struct gpr_htst_half gpr_htst_half_t
 One half of the prefactor (ABI 1.20).
typedef struct gpr_rff_selection gpr_rff_selection_t
 Report of the held-out random-feature selection (ABI 1.9).

Enumerations

enum  {
  GPR_SUCCESS = 0 , GPR_ERR_NULL_HANDLE = -1 , GPR_ERR_INVALID_ARG = -2 , GPR_ERR_NOT_TRAINED = -3 ,
  GPR_ERR_ALLOC = -4 , GPR_ERR_CHOLESKY = -5 , GPR_ERR_OPTIMIZER = -6 , GPR_ERR_NOT_CONVERGED = -7 ,
  GPR_ERR_SIZE_LIMIT = -8 , GPR_ERR_ORACLE = -9 , GPR_ERR_UNSUPPORTED = -10 , GPR_ERR_ABI = -11 ,
  GPR_ERR_OUT_OF_SUPPORT = -12 , GPR_ERR_UNIT_MISMATCH = -13 , GPR_ERR_INTERNAL = -99
}
 Status codes returned by the functions whose int result is a status. More...
enum  gpridge_alg_t { GPR_OPT_SCG = 0 , GPR_OPT_FACTORIZED = 2 }
 Hyperparameter optimization algorithm. More...
enum  gpr_hssvd_backend_t { GPR_HSSVD_BACKEND_DEFAULT , GPR_HSSVD_BACKEND_HSSVD = 1 , GPR_HSSVD_BACKEND_CHOLESKY = 2 }
 Posterior solver selected by gpr_model_config_t::use_hssvd_backend (ABI 1.19). More...
enum  gpr_neb_mode_t {
  GPR_NEB_STANDARD = 0 , GPR_NEB_AIE = 1 , GPR_NEB_OIE = 2 , GPR_NEB_GP_AIE = 3 ,
  GPR_NEB_GP_OIE = 4 , GPR_NEB_GP_LOCAL = 5
}
 NEB evaluation mode. More...
enum  gpr_acquisition_t {
  GPR_ACQ_MAX_VARIANCE = 0 , GPR_ACQ_MAX_FORCE = 1 , GPR_ACQ_UCB = 2 , GPR_ACQ_THOMPSON = 3 ,
  GPR_ACQ_IMSPE = 4 , GPR_ACQ_EI = 5 , GPR_ACQ_PRIORITY_CASCADE = 6 , GPR_ACQ_TPE = 7 ,
  GPR_ACQ_PSBAX = 8
}
 OIE acquisition strategy for image selection. More...
enum  gpr_conv_norm_t { GPR_NORM_L2 = 0 , GPR_NORM_LINF = 1 , GPR_NORM_MAX_ATOM = 2 }
 Convergence force norm type. More...
enum  gpr_distance_metric_t { GPR_DIST_MAX_1D_LOG = 0 , GPR_DIST_RMSD = 1 , GPR_DIST_EMD = 2 }
 Atomic trust distance metric. Values mirror DistanceMetricType. More...
enum  gpr_model_type_t { GPR_MODEL_GP = 0 , GPR_MODEL_TP = 1 }
 Model type tag. More...
enum  gpr_bq_kernel_t {
  GPR_BQ_KERNEL_SE = 0 , GPR_BQ_KERNEL_MATERN32_PRODUCT = 1 , GPR_BQ_KERNEL_MATERN52_PRODUCT = 2 , GPR_BQ_KERNEL_MATERN32_ISOTROPIC = 3 ,
  GPR_BQ_KERNEL_MATERN52_ISOTROPIC = 4
}
 Kernel family for scalar GP Bayesian quadrature (ABI 1.17). More...
enum  gpr_bq_hyper_mode_t {
  GPR_BQ_HYPER_FIXED = 0 , GPR_BQ_HYPER_ML = 1 , GPR_BQ_HYPER_MAP = 2 , GPR_BQ_HYPER_TP_MARGINAL = 3 ,
  GPR_BQ_HYPER_MARGINALIZED = 4
}
 Hyperparameter treatment for Bayesian quadrature (ABI 1.17). More...
enum  gpr_bq_measure_kind_t { GPR_BQ_MEASURE_LEBESGUE_BOX = 0 , GPR_BQ_MEASURE_UNIFORM_BOX = 1 , GPR_BQ_MEASURE_GAUSSIAN = 2 }
 Integration measure. A uniform box is the Lebesgue integral divided by the volume. More...
enum  gpr_bq_basis_t { GPR_BQ_BASIS_FOLLOW_CONFIG = -1 , GPR_BQ_BASIS_NONE = 0 , GPR_BQ_BASIS_CONSTANT = 1 , GPR_BQ_BASIS_AFFINE = 2 }
 Bayes-Sard basis. GPR_BQ_BASIS_FOLLOW_CONFIG, the state of a new handle and of gpr_bq_set_basis(bq, -1), keeps the historical switch use_prior_mean: the constant basis when it is set, no basis otherwise. More...
enum  gpr_psearch_axis_t { GPR_PSEARCH_AXIS_LINEAR = 0 , GPR_PSEARCH_AXIS_LOG = 1 , GPR_PSEARCH_AXIS_INTEGER = 2 }
 Kind of a continuous parameter-search axis (ABI 1.26). More...
enum  gpr_uncertainty_mode_t {
  GPR_UQ_MAP = 0 , GPR_UQ_BMA = 1 , GPR_UQ_LAPLACE = 2 , GPR_UQ_EB = 3 ,
  GPR_UQ_SVGD = 4 , GPR_UQ_LAPLACE_SLICE = 5
}
enum  gpr_hyperparameter_mode_t { GPR_HOPT_SCG = 0 , GPR_HOPT_INLA = 1 }
enum  gpr_hyperparameter_objective_t { GPR_HOBJ_NLML = 0 , GPR_HOBJ_LOO = 1 }
enum  gpr_periodic_band_initial_t { GPR_PERIODIC_BAND_LINEAR = 0 , GPR_PERIODIC_BAND_IDPP = 1 , GPR_PERIODIC_BAND_SIDPP = 2 }
 How a periodic band builds its initial path (ABI 1.7). GPLocalBand's "linear", "idpp" and "sidpp". More...
enum  gpr_energy_unit_t {
  GPR_ENERGY_UNIT_NATIVE = 0 , GPR_ENERGY_UNIT_EV = 1 , GPR_ENERGY_UNIT_HARTREE = 2 , GPR_ENERGY_UNIT_KCAL_PER_MOL = 3 ,
  GPR_ENERGY_UNIT_KJ_PER_MOL = 4
}
 Energy unit tag (ABI 1.20). Labels only; nothing is converted. More...
enum  gpr_length_unit_t { GPR_LENGTH_UNIT_NATIVE = 0 , GPR_LENGTH_UNIT_ANGSTROM = 1 , GPR_LENGTH_UNIT_BOHR = 2 , GPR_LENGTH_UNIT_NANOMETER = 3 }
 Length unit tag (ABI 1.20). Labels only; nothing is converted. More...
enum  gpr_htst_mode_t { GPR_HTST_REFINED = 0 , GPR_HTST_MEASURED = 1 , GPR_HTST_SURROGATE = 2 }
 Hessian a half is built from (ABI 1.20). More...
enum  gpr_htst_kind_t { GPR_HTST_MINIMUM = 0 , GPR_HTST_SADDLE = 1 }
 Stationary point of a half (ABI 1.20). More...
enum  gpr_htst_status_t { GPR_HTST_OK = 0 , GPR_HTST_NOT_CONVERGED = 1 , GPR_HTST_WRONG_INDEX , GPR_HTST_UNAVAILABLE = 3 }
 Outcome of a half (ABI 1.20). More...
enum  gpr_htst_source_t {
  GPR_HTST_SOURCE_REFINED = 0 , GPR_HTST_SOURCE_MEASURED = 1 , GPR_HTST_SOURCE_STENCIL = 2 , GPR_HTST_SOURCE_SURROGATE = 3 ,
  GPR_HTST_SOURCE_CONDITIONED
}
 Where a half's Hessian came from (ABI 1.20). More...
enum  gpr_htst_point_t { GPR_HTST_REACTANT = 0 , GPR_HTST_TRANSITION = 1 , GPR_HTST_PRODUCT = 2 }
 Which stationary point of a search (ABI 1.20). More...
enum  gpr_dimer_stop_t {
  GPR_DIMER_STOP_UNSPECIFIED = 0 , GPR_DIMER_STOP_FORCE_CONVERGED = 1 , GPR_DIMER_STOP_MEASURED_NON_DESCENT = 2 , GPR_DIMER_STOP_DEGENERATE_PROBE = 3 ,
  GPR_DIMER_STOP_UNINFORMATIVE_ROTATION = 4 , GPR_DIMER_STOP_ALIGNMENT_LOSS = 5 , GPR_DIMER_STOP_ITERATION_BUDGET = 6 , GPR_DIMER_STOP_INTERATOMIC_COLLAPSE = 7 ,
  GPR_DIMER_STOP_INVALID_ATOMS = 8 , GPR_DIMER_STOP_ORACLE_BUDGET = 9 , GPR_DIMER_STOP_INVALID_PARAMETERS = 10 , GPR_DIMER_STOP_MEASURED_INDEX_ZERO = 11 ,
  GPR_DIMER_STOP_UNCERTIFIED_FORCE_STOP = 12
}
 Why a dimer search stopped (ABI 1.1). More...
enum  gpr_neb_status_t { GPR_NEB_NOT_CONVERGED = 0 , GPR_NEB_FORCE_TOLERANCE = 1 , GPR_NEB_MODEL_NOISE_FLOOR = 2 }
 How a NEB result converged (ABI 1.1). More...

Functions

const char * gpr_version (void)
 Library version string ("major.minor.patch"). Never NULL.
void gpr_version_components (int *major, int *minor, int *patch)
 Version components. Any pointer may be NULL.
void gpr_abi_version (int *major, int *minor)
 ABI version of the loaded library. Any pointer may be NULL.
int gpr_abi_check (int header_major, int header_minor)
 GPR_SUCCESS when the loaded library implements the ABI a caller was compiled against (same major, library minor at least header_minor); GPR_ERR_ABI with both versions in gpr_last_error() otherwise.
const char * gpr_last_error (void)
 Thread-local error message from last failing call. Never NULL.
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 name.
size_t gpr_last_error_copy (char *buf, size_t capacity)
 Copy the thread-local error message into buf (capacity bytes, always terminated when capacity > 0). Returns the message length without the terminator, so a return value >= capacity means the copy was truncated. buf may be NULL when capacity is 0.
const char * gpr_status_name (int status)
 Short static name of a status code ("GPR_ERR_ORACLE"). Never NULL.
int gpr_last_status (void)
 Status of the last call on this thread that failed (ABI 1.1), like errno: a constructor that returns NULL leaves its reason here. Status-returning calls, constructors, NULL-handle accessors, and non-oracle destroy calls reset it to GPR_SUCCESS; successful live-handle and parameterless accessors preserve it, and all destroy calls preserve a pending GPR_ERR_ORACLE during cleanup.
gpr_atoms_config_t gpr_atoms_config_defaults (void)
 Default atoms configuration (everything zeroed/NULL).
gpr_atoms_config_t gpr_atoms_simple (int n_atoms)
 Convenience: N identical moving atoms, one pair type.
gpr_atoms_t gpr_atoms_create_simple (int n_atoms)
 Convenience: create an atoms handle for N identical moving atoms. Equivalent to gpr_atoms_create(&gpr_atoms_simple(n_atoms)).
gpr_model_config_t gpr_model_config_defaults (void)
 Library defaults of every gpr_model_config_t field.
gpr_bq_config_t gpr_bq_config_defaults (void)
 Defaults: one dimension, squared-exponential kernel, marginalized hyperparameters, constant mean profile, jitter 1e-12.
gpr_dimer_config_t gpr_dimer_config_defaults (void)
 Library defaults of every gpr_dimer_config_t field.
gpr_neb_config_t gpr_neb_config_defaults (void)
 Library defaults of every gpr_neb_config_t field.
gpr_local_band_config_t gpr_local_band_config_defaults (void)
 Library defaults of every gpr_local_band_config_t field (ABI 1.6).
gpr_periodic_band_config_t gpr_periodic_band_config_defaults (void)
 Library defaults of every gpr_periodic_band_config_t field (ABI 1.7).
int gpr_neb_request_index_certificate (int enable, double step)
 Ask the next NEB search on this thread to certify the stopped band (ABI 1.6). enable 0 is the default. step 0 selects the library stencil step; a negative step is GPR_ERR_INVALID_ARG. The request is consumed by that search. gpr_neb_search_local also honours gpr_local_band_config_t::force_stop_certificate. On gpr_neb_search_periodic and gpr_neb_search_periodic_potential a nonzero step takes precedence over gpr_local_band_config_t::certificate_step, and step 0 leaves that field's step in place.
int gpr_neb_request_sidpp (int enable)
 Select the IDPP initializer for the next NEB search on this thread (ABI 1.16). enable 1 selects SIDPP and enable 0 selects classic IDPP. SIDPP is the library default. The request is consumed by that search, including when validation rejects the search. It has no effect on gpr_neb_search_periodic or gpr_neb_search_periodic_potential: those take the initializer from gpr_periodic_band_config_t::initial alone, and they still consume the request.
int gpr_neb_request_vibrational_stencil (int mode)
 Choose the true-oracle Hessian stencil for the next non-local NEB search on this thread (ABI 1.21). mode 0 is full, every Cartesian coordinate, and mode 1 is vibrational. Any other value is GPR_ERR_INVALID_ARG. The request is consumed by that search. A local or periodic band takes the choice from gpr_local_band_config_t instead, and still consumes the request. gpr_neb_config_t is unchanged: its tail padding stays unread, so a caller built against ABI 1.14 keeps working.
gpr_minimize_config_t gpr_minimize_config_defaults (void)
 Library defaults of every gpr_minimize_config_t field.
int gpr_minimize_request_max_inner_steps (int max_inner_steps)
 Set the inner surrogate L-BFGS step cap for the next gpr_minimize call on this thread (ABI 1.18).
gpr_atoms_t gpr_atoms_create (const gpr_atoms_config_t *config)
 Create an atoms configuration handle from descriptor. Returns NULL on failure (check gpr_last_error()).
void gpr_atoms_destroy (gpr_atoms_t atoms)
 Destroy atoms configuration. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A second call reports GPR_ERR_INVALID_ARG through gpr_last_status() and does not free the handle again.
int gpr_atoms_n_moving (gpr_atoms_t atoms)
 Number of moving (non-frozen) atoms.
int gpr_atoms_n_pairtypes (gpr_atoms_t atoms)
 Number of pair types.
gpr_model_t gpr_model_create (gpr_model_type_t type)
 Create a GP or TP model. Returns NULL on failure.
void gpr_model_destroy (gpr_model_t model)
 Destroy model. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A second call reports GPR_ERR_INVALID_ARG through gpr_last_status() and does not free the handle again.
gpr_model_type_t gpr_model_type (gpr_model_t model)
 Query model type.
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(). Can be called again to reconfigure: the model is rebuilt, so it is untrained and later fits start from the library defaults exactly as on a fresh handle.
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.
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).
void gpr_train_phase_reset (void)
 Zero the train-phase walls. The next train or predict accumulates into a fresh sample. Any pointer passed to gpr_train_phase_read may be NULL.
int gpr_model_fit_iterations (gpr_model_t model)
 Iterations the last train ran, or -1 when the model is missing.
int gpr_model_fit_restarts (gpr_model_t model, int *out)
 Restarts the last train needed (ABI 1.15).
const char * gpr_model_fit_stop_reason (gpr_model_t model)
 Why the last train stopped, as a static string.
void gpr_train_phase_read (double *factor_s, double *solve_s, double *eigen_s, double *kernel_s, double *hessian_s)
 Read the walls accumulated since the last reset. factor is the Cholesky factor, solves are the triangular substitutions, eigen is the stable-basis symmetric eigensolve, kernel is kernel assembly, hessian is the hyperparameter gradient.
void gpr_train_phase_read_leaves (double *setup_s, double *descriptor_s, double *posterior_s, double *subset_s, double *objective_s, double *condition_s, double *cache_s, double *curvature_s, double *energy_s, double *schedule_s)
 Read the leaves that sit beside the five train walls. setup is model preparation, descriptor is the dual-kernel features, posterior is the weight solve after the eigensolve, subset is the optimization sample, objective is the marginal likelihood, and condition is the full-data rebuild. Any pointer may be NULL. objective and condition wrap other leaves. The disjoint coverage sum is factor, solve, eigen, kernel, gradient, curvature, energy, schedule, setup, cache, descriptor, posterior, and subset.
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.
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.
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 training standardization of the kernel contraction. kstar and weights hold that contraction, in the trained factor order, and order receives their length. capacity is the buffer length for both arrays.
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.
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.
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.
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).
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).
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).
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).
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).
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).
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).
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).
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).
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.
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).
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.
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).
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).
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).
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).
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).
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_bq_t gpr_bq_create (const gpr_bq_config_t *config)
 Create a scalar GP / Bayesian quadrature handle.
void gpr_bq_destroy (gpr_bq_t bq)
 Destroy a handle from gpr_bq_create. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A handle that is already destroyed is not touched and sets GPR_ERR_INVALID_ARG in gpr_last_status().
int gpr_bq_reset (gpr_bq_t bq, const gpr_bq_config_t *config)
 Replace the configuration and drop every observation and any stored integration box.
int gpr_bq_dimension (gpr_bq_t bq)
 Input dimension of the configuration; 0 for NULL or a dead handle.
int gpr_bq_n_observations (gpr_bq_t bq)
 Number of stored observations; 0 for NULL or a dead handle.
int gpr_bq_n_lengthscales (gpr_bq_t bq)
 Number of length scales: dimension when the configuration is ARD, otherwise 1; 0 for NULL or a dead handle.
int gpr_bq_train_checked (gpr_bq_t bq, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, int n_obs, int n_dims)
 Train on n_obs points and infer the integration box from the training extrema.
int gpr_bq_train_bounded_checked (gpr_bq_t bq, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_obs, int n_dims)
 Train and store an explicit integration box. Each lower[d] is finite and strictly below upper[d], and every training coordinate lies in the closed interval. Null noise_var with a zero length stores zero noise, as gpr_bq_train_checked does. The box is kept for later refits and for appended rows.
int gpr_bq_append_checked (gpr_bq_t bq, const double *X_new, size_t X_len, const double *y_new, size_t y_len, const double *noise_var_new, size_t noise_var_len, int n_new, int n_dims, int refit)
 Append n_new observations to a trained model.
int gpr_bq_fit_hyperparameters_checked (gpr_bq_t bq, gpr_bq_hyper_mode_t mode, gpr_bq_fit_report_t *report, double *lengthscales_out, size_t lengthscales_len)
 Re-infer the hyperparameters of a trained model with the given treatment, which then becomes the configured treatment.
int gpr_bq_get_lengthscales_checked (gpr_bq_t bq, double *out, size_t out_len)
 Copy the current length scales out.
int gpr_bq_set_lengthscales_checked (gpr_bq_t bq, const double *values, size_t values_len)
 Pin the length scales. A trained model is rebuilt with them held and the signal variance kept at its current value; the observations and the configured hyperparameter treatment stay unchanged.
int gpr_bq_get_magn_sigma2 (gpr_bq_t bq, double *out)
 Signal variance of the posterior (squared output unit). out receives one double.
int gpr_bq_set_magn_sigma2 (gpr_bq_t bq, double value)
 Pin the signal variance. A trained model is rebuilt with it held and the length scales kept (an ARD set stays anisotropic); the configured hyperparameter treatment stays unchanged.
int gpr_bq_get_extra_sigma2 (gpr_bq_t bq, double *out)
 Extra observation-noise variance added to every observation. out receives one double.
int gpr_bq_set_extra_sigma2 (gpr_bq_t bq, double value)
 Set the extra observation-noise variance. A trained model is refit with its configured hyperparameter treatment.
int gpr_bq_predict_batch_checked (gpr_bq_t bq, const double *X_queries, size_t X_len, double *mean_out, size_t mean_len, double *var_out, size_t var_len, int n_queries, int n_dims)
 Posterior mean and variance at n_queries points.
int gpr_bq_kernel_mean_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X, size_t X_len, int n_points, int n_dims, double *z_out, size_t z_len)
 Kernel mean z_i = integral over the box [lower, upper] of k(x, X_i) dx, at the training points or at explicit points.
int gpr_bq_kernel_double_integral_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, double *omega_out)
 Kernel double integral of k over the box, written to *omega_out (output unit squared times volume squared). Same readiness rule as gpr_bq_kernel_mean_checked.
int gpr_bq_integrate_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, double *mean_out, double *var_out)
 Integral mean and variance over a box. Equivalent to gpr_bq_integrate_report_checked keeping only mean and variance.
int gpr_bq_integrate_report_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, int n_dims, gpr_bq_integral_report_t *report)
 Integral over a box with the full decomposition of the variance.
int gpr_bq_integrate_measure_checked (gpr_bq_t bq, int kind, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *mean, size_t mean_len, const double *covariance, size_t covariance_len, int n_dims, double *mean_out, double *var_out, double *mass_out)
 Integrate against a Lebesgue box, the uniform probability on that box, or a Gaussian.
int gpr_bq_integrate_uncertainty_checked (gpr_bq_t bq, int kind, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *mean, size_t mean_len, const double *covariance, size_t covariance_len, int n_dims, gpr_bq_uncertainty_t *report)
 As gpr_bq_integrate_measure_checked, with the uncertainty split by source. Same measure arguments and failures.
int gpr_bq_set_basis (gpr_bq_t bq, int basis)
 Select the Bayes-Sard mean model with a gpr_bq_basis_t value; GPR_BQ_BASIS_FOLLOW_CONFIG (-1) follows the configuration (use_prior_mean: constant when set, none otherwise). A trained model is rebuilt with the new basis.
int gpr_bq_get_basis (gpr_bq_t bq, int *basis_out)
 Active basis selection, a gpr_bq_basis_t value written to *basis_out (GPR_BQ_BASIS_FOLLOW_CONFIG until a basis is set).
int gpr_bq_integrate_cumulative_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper_limits, size_t upper_limits_len, int n_limits, int n_dims, double *mean_out, size_t mean_len, double *covariance_out, size_t covariance_len)
 Joint posterior of the integrals over [lower, upper_limits[j]] for n_limits nested upper limits.
int gpr_bq_sample_cumulative_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper_limits, size_t upper_limits_len, int n_limits, int n_dims, int n_draws, uint64_t seed, double *draws_out, size_t draws_len)
 Draw n_draws joint samples of the cumulative integrals, deterministic in seed.
int gpr_bq_candidate_variance_reduction_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X_candidates, size_t X_cand_len, const double *cand_noise_var, size_t cand_noise_len, int n_candidates, int n_dims, double *delta_var_out, size_t delta_var_len)
 Variance reduction of the integral from one extra observation at each candidate.
int gpr_bq_select_batch_candidates_checked (gpr_bq_t bq, const double *lower, size_t lower_len, const double *upper, size_t upper_len, const double *X_candidates, size_t X_cand_len, const double *cand_noise_var, size_t cand_noise_len, int n_candidates, int n_dims, int batch_size, int *selected_indices_out, size_t selected_indices_len, double *step_reductions_out, size_t step_reductions_len)
 Greedily choose batch_size candidates, each conditioned on the ones chosen before it.
int gpr_bq_calibrate_loo_checked (gpr_bq_t bq, double nominal_probability, gpr_calibration_report_t *report)
 Closed-form leave-one-out calibration summary at the given central probability in (0, 1). It makes no oracle call and does not change the model.
int gpr_bq_calibrate_loo_scores_checked (gpr_bq_t bq, double nominal_probability, gpr_bq_loo_report_t *report, double *z_scores_out, size_t z_scores_len)
 As gpr_bq_calibrate_loo_checked, and also write every standardized leave-one-out score.
gpr_derivative_options_t gpr_derivative_options_defaults (void)
 Defaults of gpr_derivative_options_t with struct_size set.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 points.
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.
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 callback (ABI 1.20).
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.
gpr_htst_options_t gpr_htst_options_defaults (void)
 Defaults of gpr_htst_options_t with struct_size set.
int gpr_htst_half_from_hessian (const gpr_htst_options_t *options, const double *masses, int n_masses, const double *H, const double *x, int n_coords, int kind, double *frequencies_out, gpr_htst_half_t *half)
 The half of a caller's Hessian (no oracle, no model).
int gpr_htst_half_from_hessian_checked (const gpr_htst_options_t *options, const double *masses, size_t masses_len, int n_masses, const double *H, size_t H_len, const double *x, size_t x_len, int n_coords, int kind, double *frequencies_out, size_t frequencies_len, gpr_htst_half_t *half)
 Extent-checked gpr_htst_half_from_hessian.
int gpr_htst_half (gpr_model_t model, gpr_oracle_fn oracle, void *user_data, const gpr_htst_options_t *options, const double *masses, int n_masses, const double *x, int n_coords, int kind, double *frequencies_out, int *measured_out, gpr_htst_half_t *half)
 The half at x from a trained model and an oracle.
int gpr_htst_half_checked (gpr_model_t model, gpr_oracle_fn oracle, void *user_data, const gpr_htst_options_t *options, const double *masses, size_t masses_len, int n_masses, const double *x, size_t x_len, int n_coords, int kind, double *frequencies_out, size_t frequencies_len, int *measured_out, size_t measured_len, gpr_htst_half_t *half)
 Extent-checked gpr_htst_half.
int gpr_htst_ln_prefactor (const gpr_htst_half_t *minimum, const gpr_htst_half_t *saddle, double *ln_nu, double *ln_nu_std)
 ln nu = minimum->ln_sum - saddle->ln_sum and its spread sqrt(std_min^2 + std_saddle^2). GPR_ERR_INVALID_ARG unless the halves are a GPR_HTST_MINIMUM and a GPR_HTST_SADDLE with status OK or NOT_CONVERGED, struct_size covers omega_scale, both have the same n_coords, finite ln_sum and finite non-negative ln_sum_std, the minimum has exactly one more real (positive) mode than the saddle (n_modes), and ln nu and its spread are finite. Outputs are untouched on failure. GPR_ERR_UNIT_MISMATCH when the halves were computed with different omega_scale values: their ln_sum are in different frequency units.
int gpr_request_prefactor (const gpr_htst_options_t *options, const double *masses, int n_masses)
 Opt this thread's later searches into prefactor halves.
int gpr_search_prefactor (int point, gpr_htst_half_t *half, double *frequencies_out, int *measured_out, int n_coords)
 A half of the last search on this thread.
int gpr_search_prefactor_checked (int point, gpr_htst_half_t *half, double *frequencies_out, size_t frequencies_len, int *measured_out, size_t measured_len, int n_coords)
 Extent-checked gpr_search_prefactor.
int gpr_neb_result_prefactor (gpr_neb_t result, int point, gpr_htst_half_t *half, double *frequencies_out, int *measured_out, int n_coords)
 A half of a GP NEB result, as gpr_search_prefactor.
int gpr_neb_result_prefactor_checked (gpr_neb_t result, int point, gpr_htst_half_t *half, double *frequencies_out, size_t frequencies_len, int *measured_out, size_t measured_len, int n_coords)
 Extent-checked gpr_neb_result_prefactor.
int gpr_fes_config_init (gpr_fes_config_t *out, size_t out_size)
 Write the default gpr_fes_config_t (squared exponential, shared length scale) into the first min(out_size, sizeof) bytes of out.
gpr_fes_t gpr_fes_create (int dimension, const gpr_model_config_t *model_config, const gpr_fes_config_t *fes_config, const double *grad_noise_var, size_t grad_noise_var_len)
 Create an untrained free-energy surrogate.
void gpr_fes_destroy (gpr_fes_t fes)
 Destroy a handle from gpr_fes_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG.
int gpr_fes_dimension (gpr_fes_t fes)
 Collective-variable dimension, or 0 for NULL or a dead handle.
int gpr_fes_n_observations (gpr_fes_t fes)
 Number of training points, or 0 before training, for NULL or for a dead handle.
int gpr_fes_noise_from_weights_checked (const double *weights, size_t weights_len, double reference_variance, double min_relative_weight, double *noise_var_out, size_t noise_var_len, int n_obs)
 Noise variances from relative sample weights: noise[i] = reference_variance * max(w) / max(w[i], min_relative_weight * max(w)). The result is unchanged when every weight is scaled by the same factor, and min_relative_weight caps the largest noise at reference_variance / min_relative_weight.
int gpr_fes_train_checked (gpr_fes_t fes, const double *s, size_t s_len, const double *F, size_t F_len, const double *F_noise_var, size_t F_noise_var_len, const double *grad_F, size_t grad_F_len, const double *grad_noise_var, size_t grad_noise_var_len, const uint8_t *grad_present, size_t grad_present_len, int n_obs, int dimension)
 Replace the training data and fit the hyperparameters.
int gpr_fes_predict_batch_checked (gpr_fes_t fes, const double *s_query, size_t s_query_len, double *F_out, size_t F_len, double *grad_F_out, size_t grad_F_len, double *var_F_out, size_t var_F_len, int n_queries, int dimension)
 Posterior mean of F at each query point, with its gradient and the latent posterior variance of F when requested.
int gpr_fes_rate_config_init (gpr_fes_rate_config_t *out, size_t out_size)
 Write the default gpr_fes_rate_config_t into the first min(out_size, sizeof) bytes of out.
int gpr_fes_rate_path_checked (gpr_fes_t fes, const double *path, size_t path_len, int n_path, int dimension, int reactant_index, int product_index, const double *diffusion, size_t diffusion_len, const gpr_fes_rate_config_t *config, gpr_fes_rate_report_t *report)
 Overdamped Kramers-Langer rate from path point reactant_index to product_index, with its uncertainty from joint posterior function draws.
gpr_sgp_t gpr_sgp_create (int dimension, int kernel)
 Create a scalar surrogate with unit length scales, unit signal variance, a noise variance of 1e-8 and a zero mean.
void gpr_sgp_destroy (gpr_sgp_t sgp)
 Destroy a handle from gpr_sgp_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG.
int gpr_sgp_n_observations (gpr_sgp_t sgp)
 Number of observed rows, or 0 for NULL or a dead handle.
int gpr_sgp_set_kernel (gpr_sgp_t sgp, int kernel)
 Select the radial shape. The observations and hyperparameters stay; the surrogate needs a new gpr_sgp_fit_checked before a prediction.
int gpr_sgp_set_mean_basis (gpr_sgp_t sgp, int basis)
 Select the mean with a gpr_bq_basis_t value: GPR_BQ_BASIS_NONE (zero, the default), GPR_BQ_BASIS_CONSTANT or GPR_BQ_BASIS_AFFINE (1 and every coordinate). The coefficients are fitted by generalized least squares together with the process at each fit.
int gpr_sgp_set_hyperparameters_checked (gpr_sgp_t sgp, const double *length_scales, size_t length_scales_len, double signal_variance, double noise_variance)
 Set the hyperparameters.
int gpr_sgp_get_hyperparameters_checked (gpr_sgp_t sgp, double *length_scales_out, size_t length_scales_len, double *signal_variance_out, double *noise_variance_out)
 Read the hyperparameters, as set or as the last fit left them.
int gpr_sgp_observe_checked (gpr_sgp_t sgp, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, int n_obs, int n_dims)
 Append observed rows.
int gpr_sgp_fit_checked (gpr_sgp_t sgp, int optimize, int n_starts, double *log_marginal_likelihood_out)
 Condition the surrogate on the observed rows.
int gpr_sgp_predict_checked (gpr_sgp_t sgp, const double *X_queries, size_t X_len, int n_queries, int n_dims, double query_noise_var, double *mean_out, size_t mean_len, double *std_out, size_t std_len)
 Predict mean and standard deviation at query rows.
gpr_psearch_t gpr_psearch_create (const double *lower, size_t lower_len, const double *upper, size_t upper_len, const int *axis_kind, size_t axis_kind_len, int dimension, int kernel, int noisy)
 Create a parameter search over a box.
void gpr_psearch_destroy (gpr_psearch_t search)
 Destroy a handle from gpr_psearch_create. Destroying NULL or a live handle clears gpr_last_status(); a destroyed handle is not touched and sets GPR_ERR_INVALID_ARG.
int gpr_psearch_set_allowed_values_checked (gpr_psearch_t search, int axis, const double *values, size_t values_len, int categorical)
 Restrict an axis to a list of values, such as the divisors of a core count. The list replaces the bounds and the kind of that axis.
int gpr_psearch_observe_checked (gpr_psearch_t search, const double *X, size_t X_len, const double *y, size_t y_len, const double *noise_var, size_t noise_var_len, const double *constraint, size_t constraint_len, int n_obs, int n_dims)
 Report evaluated rows.
int gpr_psearch_propose_checked (gpr_psearch_t search, int q, double *X_out, size_t X_len, int n_dims, int *n_proposed_out)
 Propose up to q parameter vectors to evaluate next.
int gpr_psearch_best_checked (gpr_psearch_t search, double *x_out, size_t x_len, double *loss_out)
 The incumbent: the feasible evaluated row with the smallest loss, or with the smallest posterior mean for a noisy search.
int gpr_model_n_lengthscales (gpr_model_t model)
 Number of kernel lengthscale parameters.
int gpr_model_get_lengthscales (gpr_model_t model, double *out)
 Get lengthscale values into caller-allocated array.
int gpr_model_set_lengthscales (gpr_model_t model, const double *values, int n_values)
 Set lengthscale values.
int gpr_model_get_magn_sigma2 (gpr_model_t model, double *out)
 Get signal variance (magnSigma2).
int gpr_model_set_magn_sigma2 (gpr_model_t model, double value)
 Set signal variance.
int gpr_model_get_sigma2 (gpr_model_t model, double *out)
 Get physical output-noise variance (sigma2).
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 posterior state.
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).
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.
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.22).
int gpr_model_get_rigid_null_deflation (gpr_model_t model, int *out)
 Query whether rigid-motion nullspace deflation is enabled (ABI 1.22).
int gpr_model_get_jitter (gpr_model_t model, double *out)
 Get the initialized model's numerical diagonal jitter variance.
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, the same encoding as gpr_model_config_t::use_hssvd_backend. DEFAULT (0) keeps the library HS-SVD selection. HSSVD (1) selects it. CHOLESKY (2) selects Cholesky. Any other value is rejected and leaves the model unchanged.
int gpr_model_get_hssvd_backend (gpr_model_t model, int *out)
 Get the selected solver, a gpr_hssvd_backend_t (ABI 1.19).
int gpr_model_n_observations (gpr_model_t model)
 Number of training observations currently stored.
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 if untrained. n is the output buffer capacity in doubles and must be at least Size. Extra capacity is left unchanged. An invalid buffer is not written.
int gpr_model_tp_prefactor (gpr_model_t model, double *out)
 TP-specific: get signal variance prefactor (valid after training).
gpr_potential_t gpr_potential_from_force_with_uncertainty (gpr_force_with_uncertainty_fn fn, void *user_data)
 Wrap a C force-with-uncertainty callback as a PotentialWrapper.
gpr_potential_t gpr_potential_from_force (gpr_force_fn fn, void *user_data)
 Wrap a plain force callback (the gpr_dimer_search signature) as a potential handle (ABI 1.1). The callback's energy_noise_rms slot is the energy-noise RMS channel and may be NULL. Returns NULL on failure.
void gpr_potential_destroy (gpr_potential_t pot)
 Destroy a potential handle. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A second call reports GPR_ERR_INVALID_ARG through gpr_last_status() and does not free the handle again.
int gpr_potential_force (gpr_potential_t pot, long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, const double *box)
 Evaluate energy and forces. energy_noise_rms may be NULL. When non-NULL, it receives the energy-noise RMS channel (a standard deviation in eV, not a variance).
int gpr_potential_force_with_uncertainty (gpr_potential_t pot, long n_atoms, const double *R, const int *atomic_nrs, double *F, double *energy, double *energy_noise_rms, double *force_noise_rms, const double *box)
 Evaluate energy, forces, and both uncertainty channels. energy_noise_rms and force_noise_rms may be NULL.
int gpr_dimer_search (gpr_force_fn force_fn, void *user_data, gpr_atoms_t atoms, const double *R_init, const double *orient_init, const gpr_dimer_config_t *config, const double *R_obs, const double *E_obs, const double *G_obs, int n_init_obs, double *R_saddle, double *E_saddle, double *orient_out, double *curvature, int *n_force_calls, int *n_gp_calls)
 GP-accelerated dimer saddle point search.
int gpr_dimer_search_potential (gpr_potential_t pot, gpr_atoms_t atoms, const double *R_init, const double *orient_init, const gpr_dimer_config_t *config, const double *R_obs, const double *E_obs, const double *G_obs, int n_init_obs, double *R_saddle, double *E_saddle, double *orient_out, double *curvature, int *n_force_calls, int *n_gp_calls)
 Same as gpr_dimer_search, but takes a PotentialWrapper handle.
int gpr_dimer_search_report (gpr_potential_t pot, gpr_atoms_t atoms, const double *R_init, const double *orient_init, const gpr_dimer_config_t *config, const double *R_obs, const double *E_obs, const double *G_obs, int n_init_obs, double *R_saddle, double *E_saddle, double *orient_out, gpr_dimer_report_t *report)
 gpr_dimer_search_potential with a report (ABI 1.1). report must not be NULL and report->struct_size must be set. A search that stops without meeting the force criterion returns GPR_SUCCESS with converged = 0; the stop field says why. Errors return a status code as elsewhere.
gpr_neb_t gpr_neb_search (gpr_oracle_fn oracle, void *user_data, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config)
 NEB path optimization. GPR_NEB_STANDARD, GPR_NEB_AIE and GPR_NEB_OIE run without a surrogate. GPR_NEB_GP_OIE and GPR_NEB_GP_AIE, including the value from gpr_neb_config_defaults, run when n_coords is a multiple of 3: the call builds all-moving atoms with gpr_atoms_create_simple and continues in gpr_neb_search_gp, using the gprn NEB model. A GP mode whose n_coords is not a multiple of 3 returns NULL with GPR_ERR_INVALID_ARG (kGpModeWithoutGp). That is the only GP-mode rejection. GPR_NEB_GP_LOCAL returns NULL with GPR_ERR_INVALID_ARG (kLocalModeEntry) at any length. gpr_neb_search_gp is the entry that takes an atoms handle and a model config.
gpr_neb_t gpr_neb_search_local (gpr_oracle_fn oracle, void *user_data, gpr_atoms_t atoms, const double *box, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config, const gpr_local_band_config_t *local)
 Local band (ABI 1.6). The result is the same opaque handle as the other NEB entries; destroy it with gpr_neb_result_destroy. A failure returns NULL and leaves the reason in gpr_last_error_message().
gpr_neb_t gpr_neb_search_local_potential (gpr_potential_t pot, const int *atomic_nrs, const double *box, gpr_atoms_t atoms, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config, const gpr_local_band_config_t *local)
 gpr_neb_search_local over a PotentialWrapper (ABI 1.6). With atoms NULL, atomic_nrs has length n_coords/3 and names the moving atoms. With atoms set, the descriptor's atomic numbers are used and atomic_nrs may be NULL.
gpr_neb_t gpr_neb_search_periodic (gpr_oracle_fn oracle, void *user_data, gpr_atoms_t atoms, const double *box, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_periodic_band_config_t *periodic, const gpr_local_band_config_t *local)
 Periodic local band (ABI 1.7), the C binding of GPLocalBand.
gpr_neb_t gpr_neb_search_periodic_potential (gpr_potential_t pot, const int *atomic_nrs, const double *box, gpr_atoms_t atoms, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_periodic_band_config_t *periodic, const gpr_local_band_config_t *local)
 gpr_neb_search_periodic over a PotentialWrapper (ABI 1.7).
gpr_neb_t gpr_neb_search_potential (gpr_potential_t pot, const int *atomic_nrs, const double *box, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config)
 gpr_neb_search over a PotentialWrapper. n_coords must be a positive multiple of 3, and atomic_nrs, box, both endpoints and config must be non-NULL. A GP mode then builds atoms from atomic_nrs (gpr_atoms_simple with those numbers, every atom moving) with one atom type per element in order of first appearance, as the gprn NEB reader types a frame, and continues in gpr_neb_search_gp_potential; being a GP mode is not an error. A length that is not a multiple of 3 fails that check for every mode, including GPR_NEB_GP_LOCAL. A local mode that passes the length check returns NULL with GPR_ERR_INVALID_ARG (kLocalModeEntry). A NULL potential is GPR_ERR_INVALID_ARG; a potential that is not live is GPR_ERR_NULL_HANDLE.
int gpr_neb_result_converged (gpr_neb_t result)
 1 if converged, 0 otherwise.
int gpr_neb_result_convergence_status (gpr_neb_t result)
 gpr_neb_status_t of the result; GPR_NEB_NOT_CONVERGED for NULL.
int gpr_neb_result_oracle_calls (gpr_neb_t result)
 Total oracle evaluations.
int gpr_neb_result_outer_iterations (gpr_neb_t result)
 Number of outer iterations performed.
double gpr_neb_result_barrier (gpr_neb_t result)
 Forward barrier (reported saddle image energy minus reactant energy).
int gpr_neb_result_max_energy_image (gpr_neb_t result)
 Index of highest-energy image.
int gpr_neb_result_n_images (gpr_neb_t result)
 Total number of images (including endpoints = n_images + 2).
int gpr_neb_result_image_positions (gpr_neb_t result, int image_idx, double *out, int n_coords)
 Get positions for image i (0-based). n_coords must equal the full image length, frozen atoms included. Any other count is GPR_ERR_INVALID_ARG and out is not written.
int gpr_neb_result_image_energy (gpr_neb_t result, int image_idx, double *out)
 Get energy for image i.
int gpr_neb_result_all_energies (gpr_neb_t result, double *out, int n_total)
 Get all image energies into an array of size n_images_total. n_total must equal gpr_neb_result_n_images(). Any other count is GPR_ERR_INVALID_ARG and out is not written.
void gpr_neb_result_destroy (gpr_neb_t result)
 Destroy NEB result. Destroying NULL or a live handle clears gpr_last_status() and gpr_last_error(), while preserving a pending GPR_ERR_ORACLE during cleanup. A second call reports GPR_ERR_INVALID_ARG through gpr_last_status() and does not free the handle again.
int gpr_neb_result_report (gpr_neb_t result, gpr_neb_report_t *report)
 Fill report from a result of any NEB entry point (ABI 1.2). report must not be NULL and report->struct_size must be set; GPR_ERR_NULL_HANDLE for a NULL result.
gpr_neb_t gpr_neb_search_gp (gpr_oracle_fn oracle, void *user_data, gpr_atoms_t atoms, const gpr_model_config_t *model, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config)
 GP-accelerated NEB (ABI 1.2): the band relaxes on a GP surrogate of the oracle and the oracle evaluates the images the acquisition selects.
gpr_neb_t gpr_neb_search_gp_potential (gpr_potential_t pot, gpr_atoms_t atoms, const double *box, const gpr_model_config_t *model, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config)
 gpr_neb_search_gp over a PotentialWrapper handle (ABI 1.2). The atomic numbers passed to the potential are those of the atoms descriptor (1 when it gave none). box is 9 doubles, row-major 3x3, or NULL for an isolated system; a periodic box also sets the band's and the kernel's minimum-image lattice.
gpr_ocineb_config_t gpr_ocineb_config_defaults (void)
 Library defaults of every gpr_ocineb_config_t field (ABI 1.2).
gpr_neb_t gpr_ocineb_search (gpr_oracle_fn oracle, void *user_data, gpr_atoms_t atoms, const gpr_model_config_t *model, const double *R_initial, const double *R_final, int n_coords, int n_images, const gpr_neb_config_t *config, const gpr_ocineb_config_t *oci)
 GP-NEB with interleaved dimer bursts on the climbing image (ABI 1.2), the band-to-dimer handover of gprn. Arguments as gpr_neb_search_gp, plus the OCINEB controls; oci NULL selects gpr_ocineb_config_defaults(). gpr_neb_result_report gives the dimer accounting.
int gpr_minimize (gpr_oracle_fn oracle, void *user_data, const double *R_init, int n_coords, gpr_atoms_t atoms, const gpr_minimize_config_t *config, double *R_final, double *E_final, double *G_final, int *converged, int *n_oracle_calls)
 GP-accelerated geometry minimization.
int gpr_potential_lj (const double *x, int n_atoms, double epsilon, double sigma, double *E_out, double *G_out)
 Lennard-Jones energy and gradient.
int gpr_potential_muller_brown (const double *xy, double *E_out, double *G_out)
 Muller-Brown 2D potential. xy=[x,y], G_out=[dE/dx,dE/dy].
int gpr_potential_leps (const double *r, double *E_out, double *G_out)
 LEPS collinear potential. r=[r_AB,r_BC], G_out=[dE/dr_AB,dE/dr_BC].
void gpr_oracle_lj (int n_coords, const double *positions, double *energy, double *gradient, void *user_data)
 Oracle adapter for LJ. user_data must point to gpr_lj_params_t.
void gpr_oracle_muller_brown (int n_coords, const double *positions, double *energy, double *gradient, void *user_data)
 Oracle adapter for Muller-Brown. user_data ignored (pass NULL).
void gpr_oracle_leps (int n_coords, const double *positions, double *energy, double *gradient, void *user_data)
 Oracle adapter for LEPS. user_data ignored (pass NULL).
int gpr_set_linalg_mode (const char *mode)
 Select the distributed factorization: "reproducible" (tile-ordered kernels, the same bits at every rank and thread count; the default) or "library" (ScaLAPACK or SLATE routines with threaded BLAS). The mode also selects the symmetric eigensolver of the HS-SVD kernel factorization. Both modes run Eigen's self-adjoint solver on the host (driver eigen_selfadjoint). "library" uses cuSOLVER at one rank when a GPU is present, and ScaLAPACK pdsyev from order 1 across ranks when unconstrained reductions are enabled. The Cholesky routines of single-process backends do not depend on the mode. GPR_ERR_INVALID_ARG for any other name.
const char * gpr_linalg_mode (void)
 "reproducible" or "library". Never NULL.
int gpr_set_linalg_threads (int threads)
 Dense linear-algebra thread count (>= 1).
int gpr_set_library_serial (int enabled)
 Nonzero selects Eigen's factor and triangular solves for the next train. Zero selects the OpenMP panel kernels. The two one-thread timings are the serial baselines a scaling note reports together.
int gpr_set_training_product (const char *spec)
 Select the product the training matrices use. NULL or "" selects the native backend; "scheme2:fp64[...]" or "scheme2:int8[...]" an in-process Scheme II engine (options :moduli=N :bits=B :provider=mkl|onednn|builtin :library=PATH, :provider=cuda for the device engine); any other string is the path of a library implementing gpr_training_product_*_v1. GPR_ERR_INVALID_ARG for a malformed specification, GPR_ERR_UNSUPPORTED when a library or provider cannot be loaded. On failure the previous selection stays.
int gpr_training_product_configured (void)
 1 when a Scheme II engine or a product library is selected, else 0.
int gpr_check_model_package (const char *path)
 Check that the AOTInductor model package at path (a .pt2) runs on this host's CPU before anything loads it. GPR_SUCCESS when it does or when the file names no instruction set; GPR_ERR_UNSUPPORTED naming the missing extensions otherwise; GPR_ERR_INVALID_ARG when the file cannot be read.
Build / runtime introspection

Query the linalg backend, MPI status, and OpenMP thread budget without re-compiling the caller against gpridge_config.h.

Binding callers (eOn, ASE wrappers, Python ctypes) need to know:

  • the active linalg backend (ScaLAPACK requires MPI init, Eigen does not, Kokkos / cuSolver have GPU prerequisites);
  • whether MPI is initialised on this rank (and the rank/size if so);
  • what OpenMP thread budget the GPR will use (driven by env vars OMP_NUM_THREADS / OPENBLAS_NUM_THREADS at construction time).
const char * gpr_backend_name (void)
 Returns a static C string naming the compiled linalg backend: "slate", "scalapack", "kokkos", "cusolver", "cholmod", "stdpar", or "eigen". Caller must NOT free.
int gpr_backend_requires_mpi (void)
 Returns 1 if the compiled linalg backend requires MPI to be initialised before any GPR call (e.g. ScaLAPACK), 0 otherwise.
int gpr_mpi_initialized (void)
 Returns 1 if MPI_Init has been called on this process (queries MPI_Initialized). Returns 0 if MPI is not compiled in OR not initialised. Safe to call before any GPR construction.
int gpr_mpi_world_rank (void)
 Returns the MPI rank in MPI_COMM_WORLD on this process, or 0 if MPI is not initialised / not compiled in.
int gpr_mpi_world_size (void)
 Returns the MPI size of MPI_COMM_WORLD on this process, or 1 if MPI is not initialised / not compiled in.
int gpr_omp_max_threads (void)
 Returns the OpenMP thread budget for this process (omp_get_max_threads). Returns 1 if OpenMP is not compiled in.

Detailed Description

C API of libgpridge: Gaussian process accelerated saddle point searches and minimisation on potential energy surfaces.

Three tiers: Tier 1 (high-level): gpr_dimer_search, gpr_neb_search, gpr_minimize, gpr_neb_search_gp, gpr_ocineb_search (ABI 1.2), gpr_neb_search_local (ABI 1.6), gpr_neb_search_periodic (ABI 1.7) Tier 2 (low-level): gpr_model_* for direct GP/TP access Tier 3: analytical test potentials (Section 11)

All functions use flat arrays (double*) and opaque handles. Memory ownership: caller allocates output arrays, library manages internal state via create/destroy pairs.

Fortran: all types are iso_c_binding compatible. See fortran/gpridge.f90 for a module with derived types.

The header is C99 and C++ compatible. Every entry point catches C++ exceptions at the boundary: a failure returns a status code (or NULL for constructors) and leaves a message in gpr_last_error_message(); no call aborts the host process.

Thread safety: a handle is used by one thread at a time; distinct handles may be used from different threads at once. gpr_last_error() and gpr_last_status() are thread-local. The runtime configuration calls of Section 12 are process-wide and are made before a search starts, never while one runs.

Callbacks report a failed evaluation by writing a non-finite energy (or any non-finite force or gradient component). The dimer and NEB searches treat such a call as a rejected trial and continue; a run of more than eight consecutive failures, or a failure the search cannot continue from, returns GPR_ERR_ORACLE. gpr_minimize stops at the first failure with GPR_ERR_ORACLE.

ABI: GPR_C_ABI_MAJOR changes only when an existing declaration changes in a way that breaks a compiled caller (a struct layout, a signature, a removed symbol); GPR_C_ABI_MINOR counts additions. A caller built against this header checks the loaded library with GPR_ABI_CHECK(). abi/gpridge_c.symbols lists every exported function, and scripts/check_c_abi.py compares that list, the version numbers and the library.

Definition in file gpridge_c.h.