Skip to main content

Crate matten

Crate matten 

Source
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.

§Status

This is 0.5.0 (milestone M5, Boundary Integration). Serde, from_json/load_json, and from_csv/load_csv are now in place. Reductions, matmul, and the examples suite arrive in later milestones.

§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) returns MattenError and 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 / Deserialize for Tensor.
  • json (default, implies serde)from_json / load_json.
  • csv (default)from_csv / load_csv.
  • dynamic — the Phase 2 heterogeneous Element engine (off by default).

For the smallest dependency footprint, disable defaults and opt in:

matten = { version = "0.1", default-features = false }

Structs§

SliceBuilder
Builder for tensor slicing (RFC-008 §10). This is the canonical API.
Tensor
A dense, row-major, owned multidimensional array of f64.

Enums§

DataFormat
The external data format associated with a MattenError::Parse.
MattenError
The single public error type for matten.