https://github.com/jonathanwoollett-light/tensor-lib
A fast minimal ultra type safe linear algebra library.
https://github.com/jonathanwoollett-light/tensor-lib
Last synced: 3 months ago
JSON representation
A fast minimal ultra type safe linear algebra library.
- Host: GitHub
- URL: https://github.com/jonathanwoollett-light/tensor-lib
- Owner: JonathanWoollett-Light
- Created: 2022-02-24T10:09:41.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T22:31:11.000Z (about 2 years ago)
- Last Synced: 2025-01-30T19:19:09.332Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 12.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tensor-Lib
[](https://jonathanwoollett-light.github.io/tensor-lib/doc/tensor_lib/index.html)
A fast minimal ultra type safe linear algebra library.
While [ndarray](https://docs.rs/ndarray/latest/ndarray/) offers no compile time type checking on dimensionality and [nalgebra](https://docs.rs/nalgebra/latest/nalgebra/) offers some finnicky checking, this offers the maximum possible checking.
When performing the addition of a `MatrixDxS` (a matrix with a known number of columns at compile time) and a `MatrixSxD` (a matrix with a known number of rows at compile time) you get a `MatrixSxS` (a matrix with a known number of rows and columns at compile time) since now both the number of rows and columns are known at compile time. This then allows this information to propagate through your program providing excellent compile time checking.
An example of how types will propagate through a program:
```rust
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use tensor_lib::*;
// MatrixSxS
let a = MatrixSxS::from([[1,2,3],[4,5,6]]);
// MatrixDxS
let b = MatrixDxS::from(vec![[2,2,2],[3,3,3]]);
// MatrixSxS
let c = (a.clone() + b.clone()) - a.clone();
// MatrixDxS
let d = c.add_rows(b);
// MatrixSxS
let e = MatrixSxS::from([[1,2,3],[4,5,6],[7,8,9],[10,11,12]]);
// MatrixSxS
let f = d.add_columns(e);
```
In this example the only operations which cannot be fully checked at compile time are:
1. `a.clone() + b.clone()`
2. `d.add_columns(e)`## Installation
The library utilize BLAS by default, on Linux it requires:
```
sudo apt-get install gfortran
```I have not tested it on any platform outside Linux.