mod eindir¶
- module eindir¶
rgpot as a strict superset of eindir: first-member struct embedding.
rgpot_potential_tembedseindir_objective_tas its FIRST member, so argpot_potential_t*IS-Aeindir_objective_t*at the C ABI with zero cost:rgpot_potential_t *pot = rgpot_potential_new_eindir(...); eindir_objective_t *obj = (eindir_objective_t*)pot; // zero-cost cast double val; eindir_objective_eval(obj, x, &val); // works
The eval_fn / grad_fn stored in the embedded base call through to the rgpot callback, so evaluation logic lives once – there is no duplicate eval path and no conversion method.
Re-exports
:rust:any:
eindir_core::ffi::eindir_status_t:rust:any:
eindir_core::ffi::EindirEvalFn:rust:any:
eindir_core::ffi::EindirFreeFn:rust:any:
eindir_core::ffi::EindirGradFn:rust:any:
eindir_core::ffi::eindir_objective_eval:rust:any:
eindir_core::ffi::eindir_objective_grad:rust:any:
eindir_core::ffi::eindir_objective_has_grad:rust:any:
eindir_core::ffi::eindir_objective_t
Functions
- unsafe extern C fn rgpot_potential_free_eindir(pot: *mut rgpot_potential_t)¶
Free a potential created by
rgpot_potential_new_eindir.Calls
pot_free_fn(pot_user_data)if provided, frees all owned arrays, then frees the struct. Do NOT calleindir_objective_freeon the embedded base; call this function.
- unsafe extern C fn rgpot_potential_new_eindir(callback: PotentialCallback, user_data: *mut c_void, free_fn: Option<unsafe extern C fn (*mut c_void)>, n_atoms: usize, atomic_numbers: *const i32, box_matrix: *const f64, bounds_low: *const f64, bounds_high: *const f64) -> *mut rgpot_potential_t¶
Create a potential that is ALSO a valid eindir objective.
The returned pointer is simultaneously a
rgpot_potential_t*and (via zero-cost cast to the first member) aneindir_objective_t*.callback: the rgpot force/energy callback.user_data/free_fn: opaque context for the rgpot callback.n_atoms,atomic_numbers,box_matrix: molecular context.bounds_low,bounds_high: f64 arrays of lengthn_atoms * 3(may be NULL; defaults to [-50, 50] per dimension).
The caller must eventually pass the returned pointer to
rgpot_potential_free.
Structs and Unions
- struct rgpot_potential_t¶
Superset potential: embeds
eindir_objective_tas its first member.Because
baseis first and both structs are#[repr(C)], casting a*mut rgpot_potential_tto*mut eindir_objective_tis defined behaviour at the C ABI. No conversion method is needed.- base: eindir_objective_t¶
Embedded eindir base: the IS-A relationship lives here. MUST remain the first field.
- callback: PotentialCallback¶
The underlying rgpot force/energy callback.
- pot_user_data: *mut c_void¶
Opaque context for
callback(distinct frombase.user_data).
- pot_free_fn: Option<unsafe extern C fn (*mut c_void)>¶
Optional destructor for
pot_user_data.
- n_atoms: usize¶
Atom count; set by
rgpot_potential_new_eindir.
- atomic_numbers: *mut i32¶
Atomic numbers, heap-allocated (len = n_atoms), owned by this struct.
- box_matrix: [f64; 9]¶
Box matrix (column-major, 3x3), copied at construction.
Traits implemented
- unsafe impl Send for rgpot_potential_t¶