mod types¶
- module types¶
Convenience constructors for the core C types.
The struct definitions themselves live in
crate::types. This module providesextern "C"factory functions so that C callers can construct the structs without needing to create DLPack tensors manually.rgpot_force_input_createcreates non-owning DLPack tensors internally. The caller must callrgpot_force_input_freewhen done.Functions
- unsafe extern C fn rgpot_force_input_create(n_atoms: usize, pos: *mut f64, atmnrs: *mut c_int, box_: *mut f64) -> rgpot_force_input_t¶
Create a
rgpot_force_input_tfrom raw CPU arrays.Internally creates non-owning DLPack tensors wrapping the raw pointers. The caller must call
rgpot_force_input_freeto free the tensor metadata when done (this does NOT free the underlying data arrays).Safety All pointers must be valid for the lifetime of the returned struct.
posmust point to at leastn_atoms * 3doubles.atmnrsmust point to at leastn_atomsints.box_must point to at least 9 doubles.
- unsafe extern C fn rgpot_force_input_free(input: *mut rgpot_force_input_t)¶
Free the DLPack tensor metadata in a
rgpot_force_input_t.This frees the
DLManagedTensorVersionedwrappers created byrgpot_force_input_create, but does NOT free the underlying data arrays (which are borrowed).After this call, all tensor pointers in
inputare set to NULL.If
inputis NULL, this is a no-op.Safety
inputmust be NULL or point to a validrgpot_force_input_twhose tensors were created byrgpot_force_input_create.
- unsafe extern C fn rgpot_force_out_create() -> rgpot_force_out_t¶
Create a
rgpot_force_out_twith null forces and zeroed scalars.The
forcesfield starts as NULL — the potential callback is responsible for setting it to a valid DLPack tensor.