RowRef

Type Alias RowRef 

Source
pub type RowRef<'a, T, Cols = usize, CStride = isize> = Row<Ref<'a, T, Cols, CStride>>;
Expand description

immutable view over a row vector, similar to an immutable reference to a strided slice

§note

unlike a slice, the data pointed to by RowRef<'_, T> is allowed to be partially or fully uninitialized under certain conditions. in this case, care must be taken to not perform any operations that read the uninitialized values, or form references to them, either directly or indirectly through any of the numerical library routines, unless it is explicitly permitted

Aliased Type§

#[repr(transparent)]
pub struct RowRef<'a, T, Cols = usize, CStride = isize>(pub Ref<'a, T, Cols, CStride>);

Tuple Fields§

§0: Ref<'a, T, Cols, CStride>

Implementations§

Source§

impl<'a, T> RowRef<'a, T>

Source

pub fn from_ref(value: &'a T) -> Self

creates a row view over the given element

Source

pub fn from_slice(slice: &'a [T]) -> Self

creates a RowRef from slice views over the row vector data, the result has the same number of columns as the length of the input slice

Source§

impl<'a, T, Cols: Shape, CStride: Stride> RowRef<'a, T, Cols, CStride>

Source

pub const unsafe fn from_raw_parts( ptr: *const T, ncols: Cols, col_stride: CStride, ) -> Self

creates a RowRef from pointers to the column vector data, number of rows, and row stride

§safety

this function has the same safety requirements as [MatRef::from_raw_parts(ptr, 1, ncols, 0, col_stride)]

Source

pub fn as_ptr(&self) -> *const T

returns a pointer to the row data

Source

pub fn nrows(&self) -> usize

returns the number of rows of the row (always 1)

Source

pub fn ncols(&self) -> Cols

returns the number of columns of the row

Source

pub fn shape(&self) -> (usize, Cols)

returns the number of rows and columns of the row

Source

pub fn col_stride(&self) -> CStride

returns the column stride of the row

Source

pub fn ptr_at(&self, col: IdxInc<Cols>) -> *const T

returns a raw pointer to the element at the given index

Source

pub unsafe fn ptr_inbounds_at(&self, col: Idx<Cols>) -> *const T

returns a raw pointer to the element at the given index, assuming the provided index is within the row bounds

§safety

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

  • col < self.ncols()
Source

pub fn split_at_col( self, col: IdxInc<Cols>, ) -> (RowRef<'a, T, usize, CStride>, RowRef<'a, T, usize, CStride>)

splits the row vertically at the given column into two parts and returns an array of each subrow, in the following order:

  • left
  • right
§panics

the function panics if the following condition is violated:

  • col <= self.ncols()
Source

pub fn transpose(self) -> ColRef<'a, T, Cols, CStride>

returns a view over the transpose of self

Source

pub fn conjugate(self) -> RowRef<'a, T::Conj, Cols, CStride>
where T: Conjugate,

returns a view over the conjugate of self

Source

pub fn canonical(self) -> RowRef<'a, T::Canonical, Cols, CStride>
where T: Conjugate,

returns an unconjugated view over self

Source

pub fn adjoint(self) -> ColRef<'a, T::Conj, Cols, CStride>
where T: Conjugate,

returns a view over the conjugate transpose of self

Source

pub fn get<ColRange>( self, col: ColRange, ) -> <RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
where RowRef<'a, T, Cols, CStride>: RowIndex<ColRange>,

returns a reference to the element at the given index, or a subrow if col is a range, with bound checks

§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_unchecked<ColRange>( self, col: ColRange, ) -> <RowRef<'a, T, Cols, CStride> as RowIndex<ColRange>>::Target
where RowRef<'a, T, Cols, CStride>: RowIndex<ColRange>,

returns a reference to the element at the given index, or a subrow if col is a range, without bound checks

§panics

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

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

pub fn reverse_cols(self) -> RowRef<'a, T, Cols, CStride::Rev>

returns a view over the self, with the columns in reversed order

Source

pub fn subcols<V: Shape>( self, col_start: IdxInc<Cols>, ncols: V, ) -> RowRef<'a, T, V, CStride>

returns a view over the subrow starting at column col_start, and with number of columns ncols

§panics

the function panics if any of the following conditions are violated:

  • col_start <= self.ncols()
  • ncols <= self.ncols() - col_start
Source

pub fn as_col_shape<V: Shape>(self, ncols: V) -> RowRef<'a, T, V, CStride>

returns the input row with the given column shape after checking that it matches the current column shape

Source

pub fn as_dyn_cols(self) -> RowRef<'a, T, usize, CStride>

returns the input row with dynamic column shape

Source

pub fn as_dyn_stride(self) -> RowRef<'a, T, Cols, isize>

returns the input row with dynamic stride

Source

pub fn iter( self, ) -> impl 'a + ExactSizeIterator + DoubleEndedIterator<Item = &'a T>
where Cols: 'a,

returns an iterator over the elements of the row

Source

pub fn par_iter(self) -> impl 'a + IndexedParallelIterator<Item = &'a T>
where T: Sync, Cols: 'a,

returns a parallel iterator over the elements of the row

Source

pub fn par_partition( self, count: usize, ) -> impl 'a + IndexedParallelIterator<Item = RowRef<'a, T, usize, CStride>>
where T: Sync, Cols: 'a,

returns a parallel iterator that provides exactly count successive chunks of the elements of this row

only available with the rayon feature

Source

pub fn try_as_row_major(self) -> Option<RowRef<'a, T, Cols, ContiguousFwd>>

returns a view over the row with a static column stride equal to +1, or None otherwise

Source

pub fn as_mat(self) -> MatRef<'a, T, usize, Cols, isize, CStride>

returns a matrix view over self

Source

pub fn as_diagonal(self) -> DiagRef<'a, T, Cols, CStride>

interprets the row as a diagonal matrix

Source§

impl<'a, T, Rows: Shape> RowRef<'a, T, Rows, ContiguousFwd>

Source

pub fn as_slice(self) -> &'a [T]

returns a reference over the elements as a slice

Source§

impl<'a, 'ROWS, T> RowRef<'a, T, Dim<'ROWS>, ContiguousFwd>

Source

pub fn as_array(self) -> &'a Array<'ROWS, T>

returns a reference over the elements as a lifetime-bound slice

Source§

impl<'a, T, Cols: Shape, CStride: Stride> RowRef<'a, T, Cols, CStride>
where T: RealField,

Source

pub fn max(&self) -> Option<T>

Returns the maximum element in the row, or None if the row is empty

Source

pub fn min(&self) -> Option<T>

Returns the minimum element in the row, or None if the row is empty

Trait Implementations§

Source§

impl<T, Cols: Shape, Rs: Stride> AsMatRef for RowRef<'_, T, Cols, Rs>

Source§

type Cols = Cols

column dimension type
Source§

type Owned = Row<Own<T, Cols>>

owned matrix type
Source§

type Rows = One

row dimension type
Source§

type T = T

scalar type
Source§

fn as_mat_ref(&self) -> MatRef<'_, Self::T, One, Self::Cols>

returns a view over self
Source§

impl<'a, T, Cols: Shape, CStride: Stride> IntoView for &'a RowRef<'_, T, Cols, CStride>

Source§

type Target = Row<Ref<'a, T, Cols, CStride>>

Source§

fn into_view(self) -> Self::Target

Source§

impl<'a, T, Cols: Shape, CStride: Stride> IntoView for &'a mut RowRef<'_, T, Cols, CStride>

Source§

type Target = Row<Ref<'a, T, Cols, CStride>>

Source§

fn into_view(self) -> Self::Target

Source§

impl<'a, T, Cols: Shape, CStride: Stride> IntoView for RowRef<'a, T, Cols, CStride>

Source§

type Target = Row<Ref<'a, T, Cols, CStride>>

Source§

fn into_view(self) -> Self::Target

Source§

impl<'b, T, Len: Shape, Strd: Stride> MatIndex for RowRef<'b, T, Len, Strd>

Source§

type Cols = Len

type of columns
Source§

type Dyn = Row<Ref<'b, T>>

matrix type with type erased dimensions
Source§

type Index = <Len as ShapeIdx>::Idx<usize>

indexing type
Source§

type Item = &'b T

item produced by the zip views
Source§

type Kind = Row

Source§

type LayoutTransform = VecLayoutTransform

layout transformation type
Source§

type Rows = ()

type of rows
Source§

type Slice = SliceRef<'b, T>

Source§

fn nrows(_: &Self) -> Self::Rows

returns the number of rows
Source§

fn ncols(this: &Self) -> Self::Cols

returns the number of columns
Source§

unsafe fn get_slice_unchecked<'a>( this: &'a mut Self, idx: Self::Index, n_elems: usize, ) -> <Self::Slice as SliceFamily<'a, Self::Item>>::Slice

returns slice at index of length n_elems
Source§

unsafe fn from_dyn_idx(idx: <Self::Dyn as MatIndex>::Index) -> Self::Index

converts a type erased index back to its original representation
Source§

unsafe fn get_unchecked(this: &mut Self, i: Self::Index) -> Self::Item

get the item at the given index, skipping bound checks
Source§

unsafe fn next_unchecked<'a>( slice: &mut <Self::Slice as SliceFamily<'a, Self::Item>>::Slice, ) -> Self::Item

get the item at the given slice position, skipping bound checks
Source§

fn is_contiguous(this: &Self) -> bool

checks if the zip matrices are contiguous
Source§

fn preferred_layout(this: &Self) -> Self::LayoutTransform

computes the preferred iteration layout of the matrices
Source§

fn with_layout(this: Self, layout: Self::LayoutTransform) -> Self::Dyn

applies the layout transformation to the matrices
Source§

impl<'a, 'N, T, Cs: Stride> RowIndex<<Dim<'N> as ShapeIdx>::Idx<usize>> for RowRef<'a, T, Dim<'N>, Cs>

Source§

type Target = &'a T

sliced view type
Source§

fn get(this: Self, col: Idx<Dim<'N>>) -> Self::Target

slice this using col
Source§

unsafe fn get_unchecked(this: Self, col: Idx<Dim<'N>>) -> Self::Target

slice this using col without bound checks
Source§

impl<'a, T, Cs: Stride> RowIndex<<usize as ShapeIdx>::Idx<usize>> for RowRef<'a, T, usize, Cs>

Source§

type Target = &'a T

sliced view type
Source§

fn get(this: Self, col: Idx<usize>) -> Self::Target

slice this using col
Source§

unsafe fn get_unchecked(this: Self, col: Idx<usize>) -> Self::Target

slice this using col without bound checks
Source§

impl<'a, C: Shape, T, Cs: Stride, ColRange: IntoRange<IdxInc<C>, Len<C>: 'a>> RowIndex<ColRange> for RowRef<'a, T, C, Cs>

Source§

type Target = Row<Ref<'a, T, <ColRange as IntoRange<<C as ShapeIdx>::IdxInc<usize>>>::Len<C>, Cs>>

sliced view type
Source§

fn get(this: Self, col: ColRange) -> Self::Target

slice this using col
Source§

unsafe fn get_unchecked(this: Self, col: ColRange) -> Self::Target

slice this using col without bound checks