Expand description
matten — a developer-experience-first multidimensional array (tensor)
library for Rust.
matten is a family car of Rust tensor library: easy to start,
predictable, and friendly for non-expert Rust developers doing small
numerical, data-exploration, or business proof-of-concept work. It
deliberately prioritizes developer experience over peak performance, and
is not a replacement for ndarray, nalgebra, or candle on hot paths.
§Scope
Numeric core (f64): construction, shape operations, arithmetic,
broadcasting, slicing, reductions, matrix multiplication, JSON/CSV boundary
APIs, and serde integration — all complete.
The dynamic feature (features = ["dynamic"]) supports heterogeneous
ingestion and missing-value cleanup before conversion to numeric tensors via
[Tensor::try_numeric]. Dynamic reshape/slicing/arithmetic are intentionally
guarded until a future CoW-view milestone.
§Quick start
use matten::Tensor;
let a = Tensor::new(vec![1.0, 2.0, 3.0, 4.0], &[2, 2]);
assert_eq!(a.shape(), &[2, 2]);
assert_eq!(a.ndim(), 2);
println!("{a:?}");Boundary-style construction returns a Result instead
of panicking:
use matten::{MattenError, Tensor};
let bad = Tensor::try_new(vec![1.0, 2.0, 3.0], &[2, 2]);
assert!(matches!(bad, Err(MattenError::Shape { .. })));§Panic zone vs Result zone
matten splits its API into two error zones:
- Panic zone — local, developer-authored convenience APIs (such as
Tensor::new) panic with an actionable message for fast PoC feedback. - Result zone — every external boundary (parsing, file I/O, user-driven
construction such as
Tensor::try_new) returnsMattenErrorand never panics on ordinary invalid input.
Errors are matched by variant (matches!), never by ==: MattenError
embeds std::io::Error and so derives only Debug.
§Cargo features
The default profile is convenient for PoC users:
serde(default) —Serialize/DeserializeforTensor.json(default, impliesserde) —from_json/load_json.csv(default) —from_csv/load_csv.dynamic— the heterogeneousElementengine / dynamic on-ramp (off by default).
For the smallest dependency footprint, disable defaults and opt in:
matten = { version = "0.22", default-features = false }Structs§
- Matten
Limits - Resource safety limits for shape calculations and allocations (RFC-018).
- Slice
Builder - Builder for tensor slicing (RFC-008 §10). This is the canonical API.
- Tensor
- A dense, row-major, owned multidimensional array of
f64.
Enums§
- Data
Format - The external data format associated with a
MattenError::Parse. - Matten
Error - The single public error type for
matten.