mod types

module types

Convenience constructors for the core C types.

The struct definitions themselves live in crate::types. This module provides extern "C" factory functions so that C callers can construct the structs without needing to create DLPack tensors manually.

rgpot_force_input_create creates non-owning DLPack tensors internally. The caller must call rgpot_force_input_free when 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_t from raw CPU arrays.

Internally creates non-owning DLPack tensors wrapping the raw pointers. The caller must call rgpot_force_input_free to 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. pos must point to at least n_atoms * 3 doubles. atmnrs must point to at least n_atoms ints. 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 DLManagedTensorVersioned wrappers created by rgpot_force_input_create, but does NOT free the underlying data arrays (which are borrowed).

After this call, all tensor pointers in input are set to NULL.

If input is NULL, this is a no-op.

Safety input must be NULL or point to a valid rgpot_force_input_t whose tensors were created by rgpot_force_input_create.

unsafe extern C fn rgpot_force_out_create() -> rgpot_force_out_t

Create a rgpot_force_out_t with null forces and zeroed scalars.

The forces field starts as NULL — the potential callback is responsible for setting it to a valid DLPack tensor.