Crates.io | qmat |
lib.rs | qmat |
version | 0.5.1 |
source | src |
created_at | 2022-06-27 12:19:58.875203 |
updated_at | 2022-07-01 05:29:56.905354 |
description | A simple library for 2-dimensional matrices. |
homepage | https://github.com/Breadinator/qmat/ |
repository | https://github.com/Breadinator/qmat/ |
max_upload_size | |
id | 614084 |
size | 56,911 |
qmat is a simple library for 2-dimensional matrices.
There are three main ways to create a new matrix.
use qmat::prelude::*;
// Creates the matrix 2x3
// [0, 1, 2]
// [3, 4, 5]
// The generics are the data type, the number of rows, the
// number of cols then the lenth of the data (rows * cols)
let mat: Matrix<i32, 2, 3, 6> = Matrix::new([0, 1, 2, 3, 4, 5]).unwrap();
// Or,
let mat = Matrix::<_, 2, 3, 6>::new([0, 1, 2, 3, 4, 5]).unwrap();
use qmat::prelude::*;
// Creates the same matrix using the analagous macro pattern.
// Automatically unwraps the errors.
let mat = matrix!(2, 3, [0, 1, 2, 3, 4, 5]);
use qmat::prelude::*;
let mat = matrix!([[0, 1, 2], [3, 4, 5]]);
Matrices can also be created using Matrix::empty and Matrix::diag.
use qmat::prelude::*;
let mat = matrix!([[0, 1, 2], [3, 4, 5]]);
println!("{}", mat[[1, 1]]); // 4
use qmat::prelude::*;
let mat = matrix!([[0, 1, 2], [3, 4, 5]]);
let pos = Position(0, 2);
println!("{}", mat[pos]); // 2