Skip to main content

Module array

Module array 

Source
Expand description

In-memory array storage for the v0.11 ConFrameBuilder.

Mirrors metatensor v2’s Array trait shape so readcon’s per-atom buffers (positions / velocities / forces / atom_energies / masses / atom_ids / fixed) live behind a Box<dyn Array> and can swap between dtypes (f32 / f64 / u64 / bool), devices (CPU / future GPU backings), and ownership models (owned ArrayD<T>, Arc<RwLock<ArrayD<T>>> for shared mut, mmap’d, …) without changing the builder’s surface.

DLPack is the cross-language export protocol; every Array implementor returns a DLPackTensor view via as_dlpack so C / C++ / Python (NumPy / PyTorch / JAX / …) / Julia consumers all see the same memory through one ABI.

The default backing is Arc<RwLock<ndarray::ArrayD<T>>>

  • Arc : multiple DLPack views can share the same buffer across threads / FFI consumers.
  • RwLock : enforces aliasing soundness; concurrent reads are non-blocking, concurrent writes contend.
  • ndarray::ArrayD<T> : type-erased dimension, generic dtype, ndarray’s allocator (8-byte aligned, fine for f64; future SIMD-aligned variants implement this trait separately).

See docs/orgmode/spec.org §17 for the public contract.

Traits§

Array
Storage hook for one per-atom field of a ConFrameBuilder.

Functions§

array_from_shape
Convenience constructor for the default backing.