pub struct OwnedMatrix<T, A: Allocator = Global> { /* private fields */ }
Expand description
A matrix that owns its elements.
To pass it to algorithms, use the .data()
and .data_mut()
functions.
§Example
#![feature(allocator_api)]
let mut A = OwnedMatrix::identity(2, 2, StaticRing::<i32>::RING);
let mut B = OwnedMatrix::identity(2, 2, StaticRing::<i32>::RING);
let mut C = OwnedMatrix::identity(2, 2, StaticRing::<i32>::RING);
StaticRing::<i32>::RING.get_ring().solve_right(A.data_mut(), B.data_mut(), C.data_mut(), Global).assert_solved();
Implementations§
Source§impl<T> OwnedMatrix<T>
impl<T> OwnedMatrix<T>
Sourcepub fn from_fn<F>(row_count: usize, col_count: usize, f: F) -> Self
pub fn from_fn<F>(row_count: usize, col_count: usize, f: F) -> Self
Creates the row_count x col_count
OwnedMatrix
whose (i, j)
-th entry
is the output of the given function on (i, j)
.
Source§impl<T, A: Allocator> OwnedMatrix<T, A>
impl<T, A: Allocator> OwnedMatrix<T, A>
Sourcepub fn new(data: Vec<T, A>, col_count: usize) -> Self
pub fn new(data: Vec<T, A>, col_count: usize) -> Self
Creates the row_count x col_count
OwnedMatrix
matrix, whose entries are
taken from the given vector, interpreted as a row-major matrix. The number of
rows is row_count = data.len() / col_count
.
If col_count
is zero, this will panic. If that can happen, consider
using OwnedMatrix::new_with_shape()
.
Sourcepub fn new_with_shape(
data: Vec<T, A>,
row_count: usize,
col_count: usize,
) -> Self
pub fn new_with_shape( data: Vec<T, A>, row_count: usize, col_count: usize, ) -> Self
Creates the row_count x col_count
OwnedMatrix
matrix, whose entries are
taken from the given vector, interpreted as a row-major matrix.
§Example
let matrix = OwnedMatrix::new_with_shape(vec![1, 2, 3, 4, 5, 6], 3, 2);
assert_eq!(3, *matrix.at(1, 0));
assert_eq!(6, *matrix.at(2, 1));
Sourcepub fn from_fn_in<F>(
row_count: usize,
col_count: usize,
f: F,
allocator: A,
) -> Self
Available on crate feature unstable-enable
only.
pub fn from_fn_in<F>( row_count: usize, col_count: usize, f: F, allocator: A, ) -> Self
unstable-enable
only.Creates the row_count x col_count
OwnedMatrix
whose (i, j)
-th entry
is the output of the given function on (i, j)
.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn data<'a>(&'a self) -> Submatrix<'a, AsFirstElement<T>, T>
pub fn data<'a>(&'a self) -> Submatrix<'a, AsFirstElement<T>, T>
Returns a Submatrix
view on the data of this matrix.
Sourcepub fn data_mut<'a>(&'a mut self) -> SubmatrixMut<'a, AsFirstElement<T>, T>
pub fn data_mut<'a>(&'a mut self) -> SubmatrixMut<'a, AsFirstElement<T>, T>
Returns a SubmatrixMut
view on the data of this matrix.
Sourcepub fn at(&self, i: usize, j: usize) -> &T
pub fn at(&self, i: usize, j: usize) -> &T
Returns a reference to the (i, j)
-th entry of this matrix.
Sourcepub fn at_mut(&mut self, i: usize, j: usize) -> &mut T
pub fn at_mut(&mut self, i: usize, j: usize) -> &mut T
Returns a mutable reference to the (i, j)
-th entry of this matrix.
Sourcepub fn zero_in<R: RingStore>(
row_count: usize,
col_count: usize,
ring: R,
allocator: A,
) -> Self
Available on crate feature unstable-enable
only.
pub fn zero_in<R: RingStore>( row_count: usize, col_count: usize, ring: R, allocator: A, ) -> Self
unstable-enable
only.Creates the row_count x col_count
zero matrix over the given ring.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn identity_in<R: RingStore>(
row_count: usize,
col_count: usize,
ring: R,
allocator: A,
) -> Self
Available on crate feature unstable-enable
only.
pub fn identity_in<R: RingStore>( row_count: usize, col_count: usize, ring: R, allocator: A, ) -> Self
unstable-enable
only.Creates the row_count x col_count
identity matrix over the given ring.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn clone_matrix<R: RingStore>(&self, ring: R) -> Self
Available on crate feature unstable-enable
only.
pub fn clone_matrix<R: RingStore>(&self, ring: R) -> Self
unstable-enable
only.§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn set_row_count<F>(&mut self, new_count: usize, new_entries: F)where
F: FnMut() -> T,
Available on crate feature unstable-enable
only.
pub fn set_row_count<F>(&mut self, new_count: usize, new_entries: F)where
F: FnMut() -> T,
unstable-enable
only.§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Trait Implementations§
Source§impl<T> MatrixCompare<T> for OwnedMatrix<T>
impl<T> MatrixCompare<T> for OwnedMatrix<T>
Auto Trait Implementations§
impl<T, A> Freeze for OwnedMatrix<T, A>where
A: Freeze,
impl<T, A> RefUnwindSafe for OwnedMatrix<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for OwnedMatrix<T, A>
impl<T, A> Sync for OwnedMatrix<T, A>
impl<T, A> Unpin for OwnedMatrix<T, A>
impl<T, A> UnwindSafe for OwnedMatrix<T, A>where
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more