Skip to main content

Module array

Module array 

Source
Expand description

Opaque numeric storage for builders and frames (metatensor v0.2.x shape).

Design: internal data is DLPack-shaped (shape / dtype / device / as_dlpack(device, stream, max_version)), not “AoS structs with a DLPack export bolt-on.” Callers query storage dtype/device, then as_dlpack with a requested device (and stream / max version)—same contract as metatensor mts_array_t. Choosing f32 vs f64 is choosing storage (or a future typed builder), not passing a cast-target on every export.

ConFrame keeps row-major ArcArray blocks for positions and optional sections; atom_data is the CON-text AoS projection for the writer.

Implementors can swap dtypes (f32 / f64 / u64 / bool), devices (CPU / future GPU), and ownership (ArrayD, Arc<RwLock<...>>, …) without changing the public surface.

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.