3 unstable releases
Uses old Rust 2015
0.2.0 | May 11, 2018 |
---|---|
0.1.1 | Apr 8, 2018 |
0.1.0 | Feb 19, 2018 |
#835 in Science
34 downloads per month
Used in 4 crates
(via madgwick)
14KB
325 lines
mat
Statically sized matrices for
no_std
applications
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
Statically sized matrices for no_std
applications
This library provides support for creating and performing mathematical operations on statically
sized matrices. That is matrices whose dimensions are known at compile time. The main use case
for this library are no_std
programs where a memory allocator is not available.
Since the matrices are statically allocated the dimensions of the matrix are stored in the type system and used to prevent invalid operations (e.g. adding a 3x4 matrix to a 4x3 matrix) at compile time.
For performance reasons all operations, except for the indexing get
method, are lazy and
perform no actual computation. An expression like a * b + c;
simply builds an expression
tree. get
can be used to force evaluation of such a tree; see below:
#[macro_use]
extern crate mat;
use mat::traits::Matrix;
fn main() {
// 2 by 3 matrix
let a = mat!(i32, [
[1, 2, 3],
[3, 4, 5],
]);
// 3 by 2 matrix
let b = mat!(i32, [
[1, 2],
[3, 4],
[5, 6],
]);
// build an expression tree
let c = &a * &b;
// partially evaluate the tree
assert_eq!(c.get(0, 0), 22);
}
This program does not allocate and compute a whole new matrix C of size 2x2; it simply performs the operations required to get the element at row 0 and column 0 that such matrix C would have.
Out of scope
The following features are out of scope for this library.
- Operations that require dynamic memory allocation
- SIMD acceleration
- n-dimensional arrays
If you are looking for such features check out the ndarray
crate.
Development status
This library is unlikely to see much development until support for const generics lands in the compiler.
Dependencies
~260KB