Linear algebra crate for Rust.

Overview

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 its data on the stack. This makes cayley pretty quick even on very large scales. It also handles slightly more complex operations on matrices, such as finding the determinant and inverse of a matrix. These calculations are not very optimised as of now, but at least they exist. cayley is named after Arthur Cayley, a prominent mathematician who introduced matrix multiplication.

One of the major features of this crate (and at the time of writing its greatest drawback too) is that it uses the generic_const_exprs feature. This is experimental Rust, but it allows a type-safe dimensionality system. Take, for example, matrix multiplication. A 4 by 3 matrix can't be multiplied by a 7 by 5 one. I wasn't able to find any other crate that's able to check that at compile time. cayley does. It's impossible to compile code that will try to perform a matrix operation which shoudln't be possible. The hindrance is that Rust's type inference doesn't fully support generic constant expressions (yet) and as a result the user has to explicitly annotate the dimensions of the Matrix type, like so:

use cayley::Matrix;

let m1: Matrix<f64, 2, 3> = Matrix::ones(2, 3);
let m2: Matrix<f64, 3, 2> = Matrix::from_closure(3, 2, |x, y| (x + y) as f64);

let m3: m1 * m2; // compile-time multiplication checks!

As you can see in the example above, cayley's matrices are generic. The crate was designed with as much type flexibility in mind. To give an example, for two matrices of different types T and Q to be multiplyable, there needs to exist a 'tensor type' R so that an implementation of Mul<Q, Output = R> exists on T and an implementation of Add exists on R. For sensible numerical types these implementations are automatically handled by the num_traits crate (which, incidentally, handles a lot of the mathematical logic in cayley).

Contributions

I'm but a humble seventeen-year-old high schooler from Belgium who likes to write code in their free time. If you feel like helping out, feel free to do so!

You might also like...
Rust crate for reconstructing Arabic sentences to be used in applications that don't support Arabic

Arabic Reshaper Rust Reconstruct Arabic sentences to be used in applications that don't support Arabic script. Usage: resahpe a single line of string

A neural network crate

RustNN An easy to use neural network library written in Rust. Crate Documentation Description RustNN is a feedforward neural network library. The libr

Awesome deep learning crate
Awesome deep learning crate

NeuroFlow is fast neural networks (deep learning) Rust crate. It relies on three pillars: speed, reliability, and speed again. Hello, everyone! Work o

convolutions-rs is a crate that provides a fast, well-tested convolutions library for machine learning

convolutions-rs convolutions-rs is a crate that provides a fast, well-tested convolutions library for machine learning written entirely in Rust with m

A high level, easy to use gpgpu crate based on wgpu

A high level, easy to use gpgpu crate based on wgpu. It is made for very large computations on powerful gpus

Small crate to work with URL in miniquad/macroquad.

quad-url This is the crate to work with URL and open links in miniquad/macroquad environment. Web demo. Usage Add this to your Cargo.toml dependencies

Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Practice repo for learning Rust. Currently going through "Rust for JavaScript Developers" course.

rust-practice 🦀 Practice repo for learning Rust. Directories /rust-for-js-dev Files directed towards "Rust for JavaScript Developers" course. Thank y

A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Owner
Simeon Duwel
I code silly things.
Simeon Duwel
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
A linear algebra library with excellent type safety

Static L.A. (Linear Algebra) A fast minimal ultra type safe linear algebra library. While ndarray offers no compile time type checking on dimensionali

Jonathan Woollett-Light 2 Feb 21, 2022
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
Machine learning crate for Rust

rustlearn A machine learning package for Rust. For full usage details, see the API documentation. Introduction This crate contains reasonably effectiv

Maciej Kula 547 Dec 28, 2022
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.

Yannick Funk 63 Dec 23, 2022
High-level non-blocking Deno bindings to the rust-bert machine learning crate.

bertml High-level non-blocking Deno bindings to the rust-bert machine learning crate. Guide Introduction The ModelManager class manages the FFI bindin

Carter Snook 14 Dec 15, 2022
Machine learning crate in Rust

DeepRust - Machine learning in Rust Vision To create a deeplearning crate in rust aiming to create a great experience for ML researchers & developers

Vigneshwer Dhinakaran 8 Sep 6, 2022
Talk with your machine in this minimalistic Rust crate!

Speak Speak is a simple, easy to use Natural Language Processor (NLP) written in Rust. Why use Speak? Speak uses a custom engine, and to setup you jus

Alex 15 Oct 11, 2022
A gpu accelerated (optional) neural network Rust crate.

Intricate A GPU accelerated library that creates/trains/runs neural networks in pure safe Rust code. Architechture overview Intricate has a layout ver

Gabriel Miranda 11 Dec 26, 2022