class rgpot::InputSpec¶
Overview¶
Move-only wrapper that creates non-owning DLPack tensors from raw CPU arrays. More…
#include <types.hpp>
class InputSpec {
public:
// construction
InputSpec(size_t n_atoms, double* pos, int* atmnrs, double* box);
InputSpec(std::vector<double>& positions, std::vector<int>& atmnrs, double* box);
InputSpec(InputSpec&& other);
InputSpec(const InputSpec&);
~InputSpec();
// methods
InputSpec& operator=(InputSpec&& other);
InputSpec& operator=(const InputSpec&);
const rgpot_force_input_t& c_struct() const;
size_t n_atoms() const;
};
Detailed Documentation¶
Move-only wrapper that creates non-owning DLPack tensors from raw CPU arrays.
Wraps rgpot_force_input_t. The constructor calls rgpot_force_input_create() which creates non-owning DLPack tensors wrapping the caller’s buffers. The destructor calls rgpot_force_input_free() to release the tensor metadata (NOT the underlying data).
Example¶
double pos[] = {0,0,0, 1,0,0};
int atm[] = {1, 1};
double box[] = {10,0,0, 0,10,0, 0,0,10};
rgpot::InputSpec input(2, pos, atm, box);
Construction¶
InputSpec(size_t n_atoms, double* pos, int* atmnrs, double* box)
Construct from raw arrays (data is borrowed, not copied).
Parameters:
n_atoms |
Number of atoms in the configuration. |
pos |
Flat position array ```` [n_atoms*3], row-major xyz. |
atmnrs |
Atomic number array ```` [n_atoms]. |
box |
Flat 3x3 cell matrix ```` [9], row-major. |
InputSpec(std::vector<double>& positions, std::vector<int>& atmnrs, double* box)
Construct from STL containers and a flat box pointer.
Note
The vectors must outlive this InputSpec since the tensors borrow their data.
Parameters:
positions |
Flat position vector; size must be a multiple of 3. |
atmnrs |
Atomic number vector. |
box |
Flat 3x3 cell matrix ```` [9], row-major. |
Methods¶
const rgpot_force_input_t& c_struct() const
Access the underlying C struct.
Returns:
Const reference to the wrapped rgpot_force_input_t.
size_t n_atoms() const
Returns the number of atoms.
Returns:
Atom count.