A linear algebra library with excellent type safety

Overview

Static L.A. (Linear Algebra)

Crates.io lib.rs.io docs

A fast minimal ultra type safe linear algebra library.

While ndarray offers no compile time type checking on dimensionality and 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 infomation to propagate through your program providing excellent compile time checking.

An example of how types will propagate through a program:

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use static_la::*;
// 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)

You must include #![feature(generic_const_exprs)] when using this library otherwise you will get a compiler error.

Comparisons

In the comparison benchmarks we are using static_la::MatrixDxD, ndarray::Array2 and naglebra::DMatrix.

We use specialization to call optimized BLAS functions for floating point types, this means this library will typically outperform standard ndarray and nalgebra with f32 and f64 operations but may underperformed with integer (u32,i32, etc.) operations.

The x axis refers to the size of the matrices e.g. 50 refers to 50x50 matrices.

You might also like...
A deep learning library for rust

Alumina An experimental deep learning library written in pure rust. Breakage expected on each release in the short term. See mnist.rs in examples or R

Machine Learning Library for Rust

autograph Machine Learning Library for Rust undergoing maintenance Features Portable accelerated compute Run SPIR-V shaders on GPU's that support Vulk

Simple neural network library for classification written in Rust.

Cogent A note I continue working on GPU stuff, I've made some interesting things there, but ultimately it made me realise this is far too monumental a

Rust wrapper for the Fast Artificial Neural Network library

fann-rs Rust wrapper for the Fast Artificial Neural Network (FANN) library. This crate provides a safe interface to FANN on top of the low-level bindi

Wrapper around Microsoft CNTK library

Bindings for CNTK library Simple low level bindings for CNTK library from Microsoft. API Documentation Status Currently exploring ways how to interact

RustFFT is a high-performance FFT library written in pure Rust.

RustFFT is a high-performance FFT library written in pure Rust. It can compute FFTs of any size, including prime-number sizes, in O(nlogn) time.

Rust crate to create Anki decks. Based on the python library genanki

genanki-rs: A Rust Crate for Generating Anki Decks With genanki-rs you can easily generate decks for the popular open source flashcard platform Anki.

Generic Automatic Differentiation library for Rust (aka "autograd")

GAD: Generic Automatic Differentiation for Rust This project aims to provide a general and extensible framework for tape-based automatic differentiati

Network-agnostic, high-level game networking library for client-side prediction and server reconciliation.
Network-agnostic, high-level game networking library for client-side prediction and server reconciliation.

WARNING: This crate currently depends on nightly rust unstable and incomplete features. crystalorb Network-agnostic, high-level game networking librar

Owner
Jonathan Woollett-Light
Been programming for a while. I like thinking about systems. MEng Swansea University Computing.
Jonathan Woollett-Light
Static Linear Algebra System

SLAS Static Linear Algebra System Provides statically allocated vector, matrix and tensor types, for interfacing with blas/blis, in a performant manor

Aksel? 34 Dec 13, 2022
Linear algebra crate for Rust.

cayley - generic, stack-allocated linear algebra in Rust cayley is a crate that fills a small niche: it provides a generic matrix type that allocates

Simeon Duwel 6 Apr 3, 2023
Simple type-safe relational algebra evaluator built entirely in Rust

ra-evaluator A simple type-safe relational algebra evaluator. Relational algebra provides the theoretical foundation for relational databases and the

Vincent Wong 4 Aug 8, 2022
A neural network model that can approximate any non-linear function by using the random search algorithm for the optimization of the loss function.

random_search A neural network model that can approximate any non-linear function by using the random search algorithm for the optimization of the los

ph04 2 Apr 1, 2022
SelfOrgMap 5 Nov 4, 2020
Using OpenAI Codex's "davinci-edit" Model for Gradual Type Inference

OpenTau: Using OpenAI Codex for Gradual Type Inference Current implementation is focused on TypeScript Python implementation comes next Requirements r

Gamma Tau 11 Dec 18, 2022
`dfx new --type=rust` + burn-rs MNIST web inference example

ic-mnist The frontend provides a canvas where users can draw a digit. The drawn digit is then sent to the backend canister running burn-rs for inferen

Marcin Nowak-Liebiediew 4 Jun 25, 2023
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Rust library for Self Organising Maps (SOM).

RusticSOM Rust library for Self Organising Maps (SOM). Using this Crate Add rusticsom as a dependency in Cargo.toml [dependencies] rusticsom = "1.1.0"

Avinash Shenoy 26 Oct 17, 2022
Rust numeric library with R, MATLAB & Python syntax

Peroxide Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros. W

Tae Geun Kim 351 Dec 29, 2022