Expand description
matten-ndarray — a conversion bridge between matten::Tensor and
ndarray::ArrayD<f64>.
This is a deliberately boring companion crate (RFC-025, RFC-027): it
converts between the two owned representations and does nothing else. It adds
no dependency to core matten, wraps none of the ndarray API, and exposes
no view or lifetime types.
use matten::Tensor;
use matten_ndarray::{from_arrayd, to_arrayd};
let t = Tensor::new(vec![1.0, 2.0, 3.0, 4.0], &[2, 2]);
let arr = to_arrayd(&t).unwrap();
let back = from_arrayd(arr).unwrap();
assert_eq!(back.as_slice(), t.as_slice());§Status
Production-ready candidate. The API is stable for the 0.19 family.
Supported ndarray: the 0.16 minor.
§Behavior
- Both conversions copy; no zero-copy is claimed.
from_arraydpreserves logical element order even for non-standard (transposed / sliced)ArrayDinputs.from_arraydrejects shapes with a zero-length axis (mattenforbids zero-sized dimensions).- A dynamic tensor passed to
to_arraydalways returnsMattenNdarrayError::DynamicTensor— this guard is unconditional and does not depend on the companiondynamicfeature (RFC-031).
§Feature flags
dynamic— Compatibility forwarding feature. No longer required for dynamic rejection as of v0.19.1. Dynamic tensors are rejected at companion boundaries regardless of whether this feature is enabled. Reconsider removal no earlier than v0.20.0.
Enums§
- Matten
Ndarray Error - Errors produced by the
matten↔ndarrayconversions.
Functions§
- from_
arrayd - Converts an
ndarray::ArrayD<f64>into aTensor. - to_
arrayd - Converts a numeric
Tensorinto anndarray::ArrayD<f64>.