Struct libmat::mat::SMatrix[]

pub struct SMatrix<T, const M: usize, const N: usize> { /* fields omitted */ }
Expand description

Statically sized matrix.

SMatrix is used almost just like Matrix, but its size is known at compile-time, so operations can be done without the & operator. The size of this matrix cannot be changed.

Example

let mut mat_a: SMatrix<i32, 3, 3> = SMatrix::one();
mat_a = mat_a * 2;
mat_a[1] = [1,2,3];
assert_eq!(mat_a, smatrix!{{2,0,0},{1,2,3},{0,0,2}});

Implementations

Methods for matrices with general dimensions.

Creates new Matrix

Example

let mut mat_a: SMatrix<i32, 3, 3> = SMatrix::new(1_i32);
mat_a[1] = [1, 2, 3];
assert_eq!(mat_a[1], [1, 2, 3]);
assert_eq!(mat_a[1][1], 2);
let mat_b = smatrix!{1, 1, 1; 1, 1, 1; 1, 1, 1;};
let mat_c: SMatrix<u32, 3, 3> = SMatrix::new(1);
assert_eq!(mat_b, mat_c);

Get the number of rows

Get the number of columns

Returns true if the matrix is a square matrix, false otherwise.

Transpose a matrix.

This functions returns a new SMatrix with a different type.

Example

let mat_a: SMatrix<i32, 4, 3> = smatrix!{1, 2, 3;
                                         3, 2, 1;
                                         2, 3, 1;
                                         3, 1, 2};
assert_eq!(mat_a.transpose(), smatrix!{1,3,2,3;2,2,3,1;3,1,1,2});

Creates a diagonal matrix with every diagonal entry havong the value of init.

Creates a diagonal matrix with initial entries specified in entries.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the conversion.

The result after applying the operator.

Returns the multiplicative inverse of self. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

Returns the multiplicative identity element of Self, 1. Read more

Sets self to the multiplicative identity element of Self, 1.

Returns true if self is equal to the multiplicative identity. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Returns the additive identity element of Self, 0. Read more

Returns true if self is equal to the additive identity.

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.