sized_matrix

Crates.iosized_matrix
lib.rssized_matrix
version0.3.0
sourcesrc
created_at2020-08-25 22:06:40.652734
updated_at2022-06-27 14:16:39.890382
descriptionSized matrices using const generics for better type checking and performance
homepagehttps://github.com/LukeMiles49/sized-matrix-rs
repositoryhttps://github.com/LukeMiles49/sized-matrix-rs
max_upload_size
id280748
size37,610
Luke Miles (LukeMiles49)

documentation

https://docs.rs/sized_matrix

README

sized_matrix

Crate

Documentation

Repository

Changelog

Sized matrices using const generics for better type checking and performance.

use sized_matrix::{Matrix, Vector};

let a: Matrix<i32, 3, 4> = Matrix::rows([
	[ 1,  2,  3,  4],
	[ 5,  6,  7,  8],
	[ 9, 10, 11, 12],
]);

let b: Matrix<i32, 4, 2> = Matrix::rows([
	[ 0,  1],
	[ 1,  2],
	[ 3,  5],
	[ 8, 13],
]);

let c: Matrix<i32, 3, 2> = a * b;

assert_eq!(c, Matrix::rows([
	[ 43,  72],
	[ 91, 156],
	[139, 240],
]));

let d: Vector<i32, 2> = Matrix::vector([-1, 1]);

let e: Vector<i32, 3> = c * d;

assert_eq!(e, Matrix::vector([
	 29,
	 65,
	101,
]));

To use this, add it as a dependency to your Cargo.toml:

[dependencies]
sized_matrix = "^0.3.0"
Commit count: 8

cargo fmt