#matrix #stack #array

yanked rowcol

Simple fixed-size vectors/matrices, allocated on the stack

Uses old Rust 2015

0.3.3 Nov 12, 2016
0.3.2 Nov 9, 2016
0.2.1 Nov 5, 2016
0.1.1 Nov 3, 2016

#388 in #stack

MIT/Apache

99KB
2.5K SLoC

rowcol

Build Status crates.io docs.rs

rowcol crate provides fixed-size Vector and Matrix. Their length or number of rows/columns are specified as type parameters, using type-level numbers provided by typenum crate.


lib.rs:

rowcol crate provides fixed-size Vector and Matrix. Their length or number of rows/columns are specified as type parameters, using type-level numbers provided by typenum crate. This lets vectors and matrices be internally represented as fixed-length arrays, therefore they are allocated on the stack, and becomes Copy if their content is Copy. Also, errors like computing the determinant of a non-square matrix can be detected at compile-time, instead of causing runtime panic.

#[macro_use] extern crate rowcol;
use rowcol::prelude::*;

fn fib(n: usize) -> u64 {
    // inferred as `f: Vector<u64, U2>`
    let f = vector![1, 0];

    // inferred as `a: Matrix<u64, U2, U2>`
    let a = matrix![[1, 1], [1, 0]];

    (a.pow(n) * f)[1]
}

assert_eq!(fib(0), 0);
assert_eq!(fib(10), 55);
assert_eq!(fib(50), 12586269025);

Dependencies

~340–760KB
~14K SLoC