Struct vectrix::Matrix

source ·
#[repr(transparent)]
pub struct Matrix<T, const M: usize, const N: usize> { /* private fields */ }
Expand description

Represents a matrix with constant M rows and constant N columns.

The underlying data is represented as an array and is always stored in column-major order.

See the crate root for usage examples.

Implementations

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Creates a new vector from the given components.

Returns a zero matrix.

Create a new matrix filled with the given element.

Create a new matrix filled with computed elements.

Elements will be filled in column-major order.

Views the underlying data as a contiguous slice.

Views the underlying data as a contiguous mutable slice.

Returns a reference to an element in the matrix or None if out of bounds.

Returns a mutable reference to an element in the matrix or None if out of bounds.

Returns a reference to an element in the matrix without doing any bounds checking.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns a mutable reference to an element in the matrix without doing any bounds checking.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns a reference to the i-th row of this matrix.

Returns a mutable reference to the i-th row of this matrix.

Returns a reference to the i-th column of this matrix.

Returns a mutable reference to the i-th column of this matrix.

Returns an iterator over the underlying data.

Returns a mutable iterator over the underlying data.

Returns an iterator over the rows in this matrix.

Returns a mutable iterator over the rows in this matrix.

Returns an iterator over the columns in this matrix.

Returns a mutable iterator over the columns in this matrix.

Returns a matrix of the same size as self, with function f applied to each element in column-major order.

Returns the L1 norm of the matrix.

Also known as Manhattan Distance or Taxicab norm. L1 Norm is the sum of the magnitudes of the vectors in a space.

Note

If the matrix is a row vector this method might not do what you what you expect. For example:

let row_vector = matrix![1, 2, 3];
assert_eq!(row_vector.l1_norm(), 3);

let column_vector = matrix![1; 2; 3];
assert_eq!(column_vector.l1_norm(), 6);

Returns an identity matrix.

Returns the diagonal of the matrix.

Trait Implementations

The resulting type after applying the + operator.
Performs the + operation. 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
The resulting type after applying the + operator.
Performs the + operation. 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
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
Performs the += operation. Read more
Performs the += operation. Read more
Performs the += operation. Read more
Formats the value using the given formatter.
The resulting type after applying the & operator.
Performs the & operation. 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
The resulting type after applying the & operator.
Performs the & operation. Read more
Performs the &= operation. Read more
Performs the &= operation. 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
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
Performs the |= operation. 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
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
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

Create a new matrix using T::default() as an initializer.

Note: this implementation will not be as efficient for types that are Copy. In most cases it would be better to use one of the following:

The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably 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
The resulting type after applying the / operator.
Performs the / operation. 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
Performs the /= operation. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Create a new matrix from an iterator.

Elements will be filled in column-major order.

Panics

If the iterator doesn’t yield enough elements to fill the matrix.

Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Formats the value using the given formatter.
Formats the value using the given formatter.
The output type returned by methods.
Returns a shared reference to the output at this location, if in bounds. Read more
Returns a mutable reference to the output at this location, if in bounds. Read more
Returns a shared reference to the output at this location, without performing any bounds checking. Read more
Returns a mutable reference to the output at this location, without performing any bounds checking. Read more
Returns a shared reference to the output at this location, panicking if out of bounds. Read more
Returns a mutable reference to the output at this location, panicking if out of bounds. Read more
The output type returned by methods.
Returns a shared reference to the output at this location, if in bounds. Read more
Returns a mutable reference to the output at this location, if in bounds. Read more
Returns a shared reference to the output at this location, without performing any bounds checking. Read more
Returns a mutable reference to the output at this location, without performing any bounds checking. Read more
Returns a shared reference to the output at this location, panicking if out of bounds. Read more
Returns a mutable reference to the output at this location, panicking if out of bounds. 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
The resulting type after applying the * operator.
Performs the * operation. 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
The resulting type after applying the * operator.
Performs the * operation. 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
Performs the *= operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
The resulting type after applying the ! operator.
Performs the unary ! operation. Read more
The resulting type after applying the ! operator.
Performs the unary ! operation. Read more
Formats the value using the given formatter.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. 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
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
Performs the %= operation. 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
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
Performs the <<= operation. 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
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
Performs the >>= operation. 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
The resulting type after applying the - operator.
Performs the - operation. 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
The resulting type after applying the - operator.
Performs the - operation. 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
Performs the -= operation. Read more
Performs the -= operation. Read more
Performs the -= operation. Read more
Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more
Formats the value using the given formatter.
Formats the value using the given formatter.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.