Matrix
items
- Items of the matrix in row by row orderorder
- Order of the matrix
Examples
use Matrix;
let matrix = new;
let invalid_matrix = new;
assert_eq!;
assert_eq!;
assert_eq!;
Matrixes from functions
Using functions to describe the matrix
use Matrix;
// Function generated matrix
// i^2 + 3j - 7
let function_generated = generate;
// -3 0 3 6 9
// 0 3 6 9 12
// 5 8 11 14 17
// 12 15 18 21 24
// 21 24 27 30 33
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Built in matrices
Row matrix
- A matrix with only 1 rowColumn matrix
- A matrix with only 1 columnNull matrix
- A matrix with all zerosSquare matrix
- A matrix with equal number of rows and columnsDiagonal matrix
- A matrix with items only along the diagonalScalar matrix
- A diagonal matrix with only 1 valueIdentity matrix
- A scalar matrix with the value of 1
use Matrix;
// Row matrix
let row_matrix = row_matrix;
assert_eq!;
assert_eq!;
// Column matrix
let column_matrix = column_matrix;
assert_eq!;
assert_eq!;
// Null matrix
let null_matrix = null_matrix;
assert_eq!;
assert_eq!;
assert_eq!;
// Square matrix
let square_matrix = square_matrix;
let invalid_square_matrix = square_matrix;
assert_eq!;
assert_eq!;
// Diagonal matrix
let diagonal_matrix = diagonal_matrix;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
/// Scalar matrix
let scalar_matrix = scalar_matrix;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
/// Identity matrix
let identity_matrix = identity_matrix;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Traces
Traces are the diagonal items of a square matrix
use Matrix;
// Traces
let random_matrix = new.unwrap;
let trace = random_matrix.trace;
// trace: [ 6, 89, 45, 9 ]
let no_trace_matrix = new.unwrap;
let invalid_trace = no_trace_matrix.trace;
assert_eq!;
assert_eq!;
let trace = trace.unwrap;
assert_eq!;
assert_eq!;
Getting and Setting items
get_row
- Returns nth rowget_column
- Returns nth columnget
- Get the item from the matrixset
- Set the item from the matrix
use Matrix;
let mut matrix = new.unwrap;
// 6 4 87
// 3 6 89
// 6 8 4
// 2 45 2
// 5 7 9
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
matrix.set;
assert_eq!;