Uses old Rust 2015
0.3.3 


0.3.2 

0.2.1 

0.1.1 

#94 in #stack
99KB
2.5K
SLoC
rowcol
rowcol
crate provides fixedsize Vector
and Matrix
.
Their length or number of rows/columns are specified as type parameters,
using typelevel numbers provided by typenum
crate.
lib.rs
:
rowcol crate provides fixedsize Vector
and Matrix
.
Their length or number of rows/columns are specified as type parameters,
using typelevel numbers provided by typenum crate.
This lets vectors and matrices be internally represented as fixedlength arrays,
therefore they are allocated on the stack, and becomes Copy
if their content
is Copy
. Also, errors like computing the determinant of a nonsquare matrix
can be detected at compiletime, 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]
}
# fn main() {
assert_eq!(fib(0), 0);
assert_eq!(fib(10), 55);
assert_eq!(fib(50), 12586269025);
# }
Dependencies
~455KB