matten-ndarray
Production-ready candidate (
0.19.xfamily release). A small conversion bridge betweenmatten::Tensorandndarray::ArrayD<f64>. The scope is closed and the API is stable; still pre-1.0, so pin the minor version.
Part of the matten workspace — see it for the full family.
Overview
matten-ndarray converts between matten's numeric Tensor and ndarray's
dynamic-dimension ArrayD<f64>, and nothing else. It is the first companion
crate in the matten workspace and exists to let you hand data off to the
ndarray ecosystem when you outgrow matten's family-car scope.
It adds no dependency to core matten, wraps none of the ndarray API, and
exposes no view or lifetime types.
Quick start
use Tensor;
use ;
let t = new;
let arr = to_arrayd?; // Tensor -> ArrayD<f64>
let back = from_arrayd?; // ArrayD<f64> -> Tensor
# Ok::
Dependency style. This crate depends on
matten, but official examples importTensor(and other core types) frommattendirectly:use Tensor; use to_arrayd;This keeps ownership and feature selection clear:
Tensorbelongs tomatten, and core features (e.g.dynamic) are enabled on themattendependency. Declare bothmattenand this crate in yourCargo.toml(RFC-032).
Design notes
- Both directions copy. No zero-copy is claimed; that would need layout guarantees out of scope for a copy-based bridge.
- Logical order is preserved.
from_arraydconverts a non-standard-layoutArrayD(transposed / sliced) by its logical element order, never the raw backing buffer. - Zero-sized axes are rejected. Core
mattendoes not support zero-length dimensions, sofrom_arraydreturns an error for them. - Dynamic tensors are rejected, not panicked. Passing a dynamic (
Element) tensor returnsMattenNdarrayError::DynamicTensorregardless of whether the companiondynamicfeature is enabled (RFC-031); convert it withTensor::try_numeric()first. - Supported
ndarray: the0.16minor.
Compatibility
- SemVer: pre-1.0 (
0.x). A0.xminor bump may contain breaking changes; patch releases are additive only. Pin the minor (matten-ndarray = "0.19"). - MSRV: Rust 1.85 (edition 2024).
matten: shares the0.19family version (RFC-030).ndarray: supports the0.16minor. Anndarrayminor bump is treated as a compatibility event and handled by amatten-ndarrayminor bump (RFC-025 §6); broadndarrayversion compatibility is not promised until CI tests it.- A
1.0release requires explicit maintainer confirmation.
More detail
See the workspace ROADMAP.md, RFC-025 (bridge policy), and
RFC-027 (this crate's design) under rfcs/.
License
Apache-2.0 © nabbisen