SLUT::tensor

1 pkd667 1 5/27/2025, 4:49:07 PM crates.io โ†—

Comments (1)

pkd667 ยท 1d ago
Static Linear Untiful Tensors

A library for vectors and matrices with physical dimensions. Basically `uom` but in a vector space.

```

let mass = (10.0).scalar::<Kilogram>();

let force = Vec2::<f64,Force>::new::<Newton>([1.0, 2.0]);

// let error = mass + force; // error (expected)

let mass = mass + Scalar::<f64,Mass>::from::<Gram>(5.0); // works

println!("{}", mass);

/*

Tensor [1x1x1]: M^1

-- Layer 0 --

( 10.005 )

*/

let acc = force.scale(mass.inv()); // works

println!("{}", acc);

/*

Tensor [1x2x1]: L^1 * T^-2

-- Layer 0 --

( 0.09995002498750624 )

( 0.19990004997501248 )

*/

```