pub type Col<E> = Matrix<DenseColOwn<E>>;Expand description
Heap allocated resizable column vector.
§Note
The memory layout of Col is guaranteed to be column-major, meaning that it has a row stride
of 1.
Aliased Type§
pub struct Col<E> { /* private fields */ }Implementations§
Source§impl<E: Entity> Col<E>
impl<E: Entity> Col<E>
Sourcepub fn with_capacity(row_capacity: usize) -> Self
pub fn with_capacity(row_capacity: usize) -> Self
Returns a new column vector with 0 rows, with enough capacity to hold a maximum of
row_capacity rows columns without reallocating. If row_capacity is 0,
the function will not allocate.
§Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
Sourcepub fn from_fn(nrows: usize, f: impl FnMut(usize) -> E) -> Self
pub fn from_fn(nrows: usize, f: impl FnMut(usize) -> E) -> Self
Returns a new matrix with number of rows nrows, filled with the provided function.
§Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
Sourcepub fn zeros(nrows: usize) -> Selfwhere
E: ComplexField,
pub fn zeros(nrows: usize) -> Selfwhere
E: ComplexField,
Returns a new matrix with number of rows nrows, filled with zeros.
§Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
Sourcepub fn ncols(&self) -> usize
pub fn ncols(&self) -> usize
Returns the number of columns of the column. This is always equal to 1.
Sourcepub unsafe fn set_nrows(&mut self, nrows: usize)
pub unsafe fn set_nrows(&mut self, nrows: usize)
Set the dimensions of the matrix.
§Safety
The behavior is undefined if any of the following conditions are violated:
nrows < self.row_capacity().- The elements that were previously out of bounds but are now in bounds must be initialized.
Sourcepub fn as_ptr(&self) -> GroupFor<E, *const E::Unit>
pub fn as_ptr(&self) -> GroupFor<E, *const E::Unit>
Returns a pointer to the data of the matrix.
Sourcepub fn as_ptr_mut(&mut self) -> GroupFor<E, *mut E::Unit>
pub fn as_ptr_mut(&mut self) -> GroupFor<E, *mut E::Unit>
Returns a mutable pointer to the data of the matrix.
Sourcepub fn row_capacity(&self) -> usize
pub fn row_capacity(&self) -> usize
Returns the row capacity, that is, the number of rows that the matrix is able to hold without needing to reallocate, excluding column insertions.
Sourcepub fn row_stride(&self) -> isize
pub fn row_stride(&self) -> isize
Returns the offset between the first elements of two successive rows in the matrix.
Always returns 1 since the matrix is column major.
Sourcepub fn reserve_exact(&mut self, row_capacity: usize)
pub fn reserve_exact(&mut self, row_capacity: usize)
Reserves the minimum capacity for row_capacity rows without reallocating. Does nothing if
the capacity is already sufficient.
§Panics
The function panics if the new total capacity in bytes exceeds isize::MAX.
Sourcepub fn resize_with(&mut self, new_nrows: usize, f: impl FnMut(usize) -> E)
pub fn resize_with(&mut self, new_nrows: usize, f: impl FnMut(usize) -> E)
Resizes the vector in-place so that the new number of rows is new_nrows.
New elements are created with the given function f, so that elements at index i
are created by calling f(i).
Sourcepub fn as_slice(&self) -> GroupFor<E, &[E::Unit]>
pub fn as_slice(&self) -> GroupFor<E, &[E::Unit]>
Returns a reference to a slice over the column.
Sourcepub fn as_slice_mut(&mut self) -> GroupFor<E, &mut [E::Unit]>
pub fn as_slice_mut(&mut self) -> GroupFor<E, &mut [E::Unit]>
Returns a mutable reference to a slice over the column.
Sourcepub unsafe fn get_unchecked<RowRange>(
&self,
row: RowRange,
) -> <ColRef<'_, E> as ColIndex<RowRange>>::Target
pub unsafe fn get_unchecked<RowRange>( &self, row: RowRange, ) -> <ColRef<'_, E> as ColIndex<RowRange>>::Target
Returns references to the element at the given index, or submatrices if row is a range.
§Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
§Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).
Sourcepub fn get<RowRange>(
&self,
row: RowRange,
) -> <ColRef<'_, E> as ColIndex<RowRange>>::Target
pub fn get<RowRange>( &self, row: RowRange, ) -> <ColRef<'_, E> as ColIndex<RowRange>>::Target
Returns references to the element at the given index, or submatrices if row is a range,
with bound checks.
§Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
§Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).
Sourcepub unsafe fn get_mut_unchecked<RowRange>(
&mut self,
row: RowRange,
) -> <ColMut<'_, E> as ColIndex<RowRange>>::Target
pub unsafe fn get_mut_unchecked<RowRange>( &mut self, row: RowRange, ) -> <ColMut<'_, E> as ColIndex<RowRange>>::Target
Returns mutable references to the element at the given index, or submatrices if
row is a range.
§Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
§Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).
Sourcepub fn get_mut<RowRange>(
&mut self,
row: RowRange,
) -> <ColMut<'_, E> as ColIndex<RowRange>>::Target
pub fn get_mut<RowRange>( &mut self, row: RowRange, ) -> <ColMut<'_, E> as ColIndex<RowRange>>::Target
Returns mutable references to the element at the given index, or submatrices if
row is a range, with bound checks.
§Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
§Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).
Sourcepub unsafe fn read_unchecked(&self, row: usize) -> E
pub unsafe fn read_unchecked(&self, row: usize) -> E
Reads the value of the element at the given index.
§Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().
Sourcepub fn read(&self, row: usize) -> E
pub fn read(&self, row: usize) -> E
Reads the value of the element at the given index, with bound checks.
§Panics
The function panics if any of the following conditions are violated:
row < self.nrows().
Sourcepub unsafe fn write_unchecked(&mut self, row: usize, value: E)
pub unsafe fn write_unchecked(&mut self, row: usize, value: E)
Writes the value to the element at the given index.
§Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().
Sourcepub fn write(&mut self, row: usize, value: E)
pub fn write(&mut self, row: usize, value: E)
Writes the value to the element at the given index, with bound checks.
§Panics
The function panics if any of the following conditions are violated:
row < self.nrows().
Sourcepub fn fill_zero(&mut self)where
E: ComplexField,
pub fn fill_zero(&mut self)where
E: ComplexField,
Fills the elements of self with zeros.
Sourcepub fn conjugate(&self) -> ColRef<'_, E::Conj>where
E: Conjugate,
pub fn conjugate(&self) -> ColRef<'_, E::Conj>where
E: Conjugate,
Returns a view over the conjugate of self.
Sourcepub fn adjoint(&self) -> RowRef<'_, E::Conj>where
E: Conjugate,
pub fn adjoint(&self) -> RowRef<'_, E::Conj>where
E: Conjugate,
Returns a view over the conjugate transpose of self.
Sourcepub fn to_owned(&self) -> Col<E::Canonical>where
E: Conjugate,
pub fn to_owned(&self) -> Col<E::Canonical>where
E: Conjugate,
Returns an owning Col of the data
Sourcepub fn has_nan(&self) -> boolwhere
E: ComplexField,
pub fn has_nan(&self) -> boolwhere
E: ComplexField,
Returns true if any of the elements is NaN, otherwise returns false.
Sourcepub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
pub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
Returns true if all of the elements are finite, otherwise returns false.
Sourcepub fn norm_max(&self) -> E::Realwhere
E: ComplexField,
pub fn norm_max(&self) -> E::Realwhere
E: ComplexField,
Returns the maximum norm of self.
Sourcepub fn norm_l2(&self) -> E::Realwhere
E: ComplexField,
pub fn norm_l2(&self) -> E::Realwhere
E: ComplexField,
Returns the L2 norm of self.
Sourcepub fn sum(&self) -> Ewhere
E: ComplexField,
pub fn sum(&self) -> Ewhere
E: ComplexField,
Returns the sum of self.