Row

Type Alias Row 

Source
pub type Row<E> = Matrix<DenseRowOwn<E>>;
Expand description

Heap allocated resizable row vector.

§Note

The memory layout of Col is guaranteed to be row-major, meaning that it has a column stride of 1.

Aliased Type§

pub struct Row<E> { /* private fields */ }

Implementations§

Source§

impl<E: Entity> Row<E>

Source

pub fn new() -> Self

Returns an empty row of dimension 0.

Source

pub fn with_capacity(col_capacity: usize) -> Self

Returns a new column vector with 0 columns, with enough capacity to hold a maximum of col_capacity columnss columns without reallocating. If col_capacity is 0, the function will not allocate.

§Panics

The function panics if the total capacity in bytes exceeds isize::MAX.

Source

pub fn from_fn(ncols: usize, f: impl FnMut(usize) -> E) -> Self

Returns a new matrix with number of columns ncols, filled with the provided function.

§Panics

The function panics if the total capacity in bytes exceeds isize::MAX.

Source

pub fn zeros(ncols: usize) -> Self
where E: ComplexField,

Returns a new matrix with number of columns ncols, filled with zeros.

§Panics

The function panics if the total capacity in bytes exceeds isize::MAX.

Source

pub fn nrows(&self) -> usize

Returns the number of rows of the row. This is always equal to 1.

Source

pub fn ncols(&self) -> usize

Returns the number of columns of the row.

Source

pub unsafe fn set_ncols(&mut self, ncols: usize)

Set the dimensions of the matrix.

§Safety

The behavior is undefined if any of the following conditions are violated:

  • ncols < self.col_capacity().
  • The elements that were previously out of bounds but are now in bounds must be initialized.
Source

pub fn as_ptr(&self) -> GroupFor<E, *const E::Unit>

Returns a pointer to the data of the matrix.

Source

pub fn as_ptr_mut(&mut self) -> GroupFor<E, *mut E::Unit>

Returns a mutable pointer to the data of the matrix.

Source

pub fn col_capacity(&self) -> usize

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

Source

pub fn col_stride(&self) -> isize

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

Source

pub fn reserve_exact(&mut self, col_capacity: usize)

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

§Panics

The function panics if the new total capacity in bytes exceeds isize::MAX.

Source

pub fn resize_with(&mut self, new_ncols: usize, f: impl FnMut(usize) -> E)

Resizes the vector in-place so that the new number of columns is new_ncols. New elements are created with the given function f, so that elements at index i are created by calling f(i).

Source

pub fn as_slice(&self) -> GroupFor<E, &[E::Unit]>

Returns a reference to a slice over the row.

Source

pub fn as_slice_mut(&mut self) -> GroupFor<E, &mut [E::Unit]>

Returns a mutable reference to a slice over the row.

Source

pub fn as_ref(&self) -> RowRef<'_, E>

Returns a view over the vector.

Source

pub fn as_mut(&mut self) -> RowMut<'_, E>

Returns a mutable view over the vector.

Source

pub unsafe fn get_unchecked<ColRange>( &self, col: ColRange, ) -> <RowRef<'_, E> as RowIndex<ColRange>>::Target
where for<'a> RowRef<'a, E>: RowIndex<ColRange>,

Returns references to the element at the given index, or submatrices if col 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:

  • col must be contained in [0, self.ncols()).
Source

pub fn get<ColRange>( &self, col: ColRange, ) -> <RowRef<'_, E> as RowIndex<ColRange>>::Target
where for<'a> RowRef<'a, E>: RowIndex<ColRange>,

Returns references to the element at the given index, or submatrices if col 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:

  • col must be contained in [0, self.ncols()).
Source

pub unsafe fn get_mut_unchecked<ColRange>( &mut self, col: ColRange, ) -> <RowMut<'_, E> as RowIndex<ColRange>>::Target
where for<'a> RowMut<'a, E>: RowIndex<ColRange>,

Returns mutable references to the element at the given index, or submatrices if col 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:

  • col must be contained in [0, self.ncols()).
Source

pub fn get_mut<ColRange>( &mut self, col: ColRange, ) -> <RowMut<'_, E> as RowIndex<ColRange>>::Target
where for<'a> RowMut<'a, E>: RowIndex<ColRange>,

Returns mutable references to the element at the given index, or submatrices if col 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:

  • col must be contained in [0, self.ncols()).
Source

pub unsafe fn read_unchecked(&self, col: 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:

  • col < self.ncols().
Source

pub fn read(&self, col: 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:

  • col < self.ncols().
Source

pub unsafe fn write_unchecked(&mut self, col: 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:

  • col < self.ncols().
Source

pub fn write(&mut self, col: 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:

  • col < self.ncols().
Source

pub fn copy_from(&mut self, other: impl AsRowRef<E>)

Copies the values from other into self.

Source

pub fn fill_zero(&mut self)
where E: ComplexField,

Fills the elements of self with zeros.

Source

pub fn fill(&mut self, constant: E)

Fills the elements of self with copies of constant.

Source

pub fn transpose(&self) -> ColRef<'_, E>

Returns a view over the transpose of self.

Source

pub fn conjugate(&self) -> RowRef<'_, E::Conj>
where E: Conjugate,

Returns a view over the conjugate of self.

Source

pub fn adjoint(&self) -> ColRef<'_, E::Conj>
where E: Conjugate,

Returns a view over the conjugate transpose of self.

Source

pub fn to_owned(&self) -> Row<E::Canonical>
where E: Conjugate,

Returns an owning Row of the data

Source

pub fn has_nan(&self) -> bool
where E: ComplexField,

Returns true if any of the elements is NaN, otherwise returns false.

Source

pub fn is_all_finite(&self) -> bool
where E: ComplexField,

Returns true if all of the elements are finite, otherwise returns false.

Source

pub fn norm_max(&self) -> E::Real
where E: ComplexField,

Returns the maximum norm of self.

Source

pub fn norm_l2(&self) -> E::Real
where E: ComplexField,

Returns the L2 norm of self.

Source

pub fn sum(&self) -> E
where E: ComplexField,

Returns the sum of self.

Source

pub fn kron(&self, rhs: impl As2D<E>) -> Mat<E>
where E: ComplexField,

Kroneckor product of self and rhs.

This is an allocating operation; see kron for the allocation-free version or more info in general.

Trait Implementations§

Source§

impl<E: Entity> As2D<E> for &Row<E>

Source§

fn as_2d_ref(&self) -> MatRef<'_, E>

Convert to a 2D matrix view.
Source§

impl<E: Entity> As2D<E> for Row<E>

Source§

fn as_2d_ref(&self) -> MatRef<'_, E>

Convert to a 2D matrix view.
Source§

impl<E: Entity> As2DMut<E> for &mut Row<E>

Source§

fn as_2d_mut(&mut self) -> MatMut<'_, E>

Convert to a mutable 2D matrix view.
Source§

impl<E: Entity> As2DMut<E> for Row<E>

Source§

fn as_2d_mut(&mut self) -> MatMut<'_, E>

Convert to a mutable 2D matrix view.
Source§

impl<E: Entity> AsRowMut<E> for &mut Row<E>

Source§

fn as_row_mut(&mut self) -> RowMut<'_, E>

Convert to a mutable row view.
Source§

impl<E: Entity> AsRowMut<E> for Row<E>

Source§

fn as_row_mut(&mut self) -> RowMut<'_, E>

Convert to a mutable row view.
Source§

impl<E: Entity> AsRowRef<E> for &Row<E>

Source§

fn as_row_ref(&self) -> RowRef<'_, E>

Convert to a row view.
Source§

impl<E: Entity> AsRowRef<E> for Row<E>

Source§

fn as_row_ref(&self) -> RowRef<'_, E>

Convert to a row view.
Source§

impl<E: Entity> Default for Row<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E: SimpleEntity> Index<usize> for Row<E>

Source§

type Output = E

The returned type after indexing.
Source§

fn index(&self, col: usize) -> &E

Performs the indexing (container[index]) operation. Read more
Source§

impl<E: SimpleEntity> IndexMut<usize> for Row<E>

Source§

fn index_mut(&mut self, col: usize) -> &mut E

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<E: Entity> ViewMut for &Row<E>

Source§

type Target<'a> = Matrix<DenseRowRef<'a, E>> where Self: 'a

View type.
Source§

fn view_mut(&mut self) -> Self::Target<'_>

Returns the view over self.
Source§

impl<E: Entity> ViewMut for &mut Row<E>

Source§

type Target<'a> = Matrix<DenseRowMut<'a, E>> where Self: 'a

View type.
Source§

fn view_mut(&mut self) -> Self::Target<'_>

Returns the view over self.
Source§

impl<E: Entity> ViewMut for Row<E>

Source§

type Target<'a> = Matrix<DenseRowRef<'a, E>> where Self: 'a

View type.
Source§

fn view_mut(&mut self) -> Self::Target<'_>

Returns the view over self.