N-dimensional matrix class for Rust 1.0. It links to OpenBLAS and LAPACK to make tensor operations fast (such as matrix multiplications and linear solvers). It utilizes Rust's move semantics as much as possible to avoid unnecessary copies.
Some of the completed and planned features:
Tensor<bool>
to Tensor<f64>
)```rust
extern crate numeric;
use numeric::Tensor;
fn main() {
let a: Tensor
let d = &a + &b; // a copy is made
println!("d = {}", d);
let e = a.dot(&c); // matrix multiplication (returns a new tensor)
println!("e = {}", e);
let f = a + &b; // a is moved (no new memory is allocated)
println!("f = {}", f);
// Higher-dimensional
let g: Tensor<f64> = Tensor::ones(&[2, 3, 4, 5]);
println!("g = {}", g);
} ```
Output:
d =
7 4 4
0 6 0
[Tensor<f64> of shape 2x3]
e =
7 43
[Tensor<f64> of shape 2]
f =
7 4 4
0 6 0
[Tensor<f64> of shape 2x3]
g =
...
[Tensor<f64> of shape 2x3x4x5]
Borrowing shamelessly from the great projects Numpy and Torch7.