Struct faer_core::Mat

source ·
pub struct Mat<T: 'static> { /* private fields */ }
Expand description

Owning matrix structure stored in column major format.

A matrix can be thought of as a 2D array of values. These values are stored in memory so that the columns are contiguous.

Note

Note that the matrix as a whole may not necessarily be contiguous. The implementation may add padding at the end of each column when overaligning each column can provide a performance gain.

Let us consider a 3×4 matrix

 0 │ 3 │ 6 │  9
───┼───┼───┼───
 1 │ 4 │ 7 │ 10
───┼───┼───┼───
 2 │ 5 │ 8 │ 11

The memory representation of such a matrix could look like the following:

0 1 2 X 3 4 5 X 6 7 8 X 9 10 11 X

where X represents padding elements.

Implementations

Returns a new matrix with dimensions (0, 0). This does not allocate.

Returns a matrix from preallocated pointer, dimensions, and capacities.

Safety

The inputs to this function must be acquired from the return value of some previous call to Self::into_raw_parts.

Consumes self and returns its raw parts in this order: pointer to data, number of rows, number of columns, row capacity and column capacity.

Returns a new matrix with dimensions (0, 0), with enough capacity to hold a maximum of row_capacity rows and col_capacity columns without reallocating. If either is 0, the matrix will not allocate.

Panics

Panics if the total capacity in bytes exceeds isize::MAX.

Returns a new matrix with dimensions (nrows, ncols), filled with the provided function.

Panics

Panics if the total capacity in bytes exceeds isize::MAX.

Returns a new matrix with dimensions (nrows, ncols), filled with zeros.

Panics

Panics if the total capacity in bytes exceeds isize::MAX.

Set the dimensions of the matrix.

Safety
  • nrows must be less than self.row_capacity().
  • ncols must be less than self.col_capacity().
  • The elements that were previously out of bounds but are now in bounds must be initialized.

Returns a pointer to the data of the matrix.

Returns a mutable pointer to the data of the matrix.

Returns the number of rows of the matrix.

Returns the number of columns of the matrix.

Returns the row capacity, that is, the number of rows that the matrix is able to hold without needing to reallocate, excluding column insertions.

Returns the column capacity, that is, the number of columns that the matrix is able to hold without needing to reallocate, excluding row insertions.

Returns the offset between the first elements of two successive rows in the matrix. Always returns 1 since the matrix is column major.

Returns the offset between the first elements of two successive columns in the matrix.

Reserves the minimum capacity for row_capacity rows and col_capacity columns without reallocating. Does nothing if the capacity is already sufficient.

Panics

Panics if the new total capacity in bytes exceeds isize::MAX.

Resizes the matrix in-place so that the new dimensions are (new_nrows, new_ncols). Elements that are now out of bounds are dropped, while new elements are created with the given function f, so that elements at position (i, j) are created by calling f(i, j).

Returns a view over the matrix.

Returns a mutable view over the matrix.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more

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 alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
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
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.