ColRef

Type Alias ColRef 

Source
pub type ColRef<'a, T, Rows = usize, RStride = isize> = Col<Ref<'a, T, Rows, RStride>>;
Expand description

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

§note

unlike a slice, the data pointed to by ColRef<'_, 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 ColRef<'a, T, Rows = usize, RStride = isize>(pub Ref<'a, T, Rows, RStride>);

Tuple Fields§

§0: Ref<'a, T, Rows, RStride>

Implementations§

Source§

impl<'a, T> ColRef<'a, T>

Source

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

creates a column view over the given element

Source

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

creates a ColRef from slice views over the column vector data, the result has the same number of rows as the length of the input slice

Source§

impl<'a, T, Rows: Shape, RStride: Stride> ColRef<'a, T, Rows, RStride>

Source

pub const unsafe fn from_raw_parts( ptr: *const T, nrows: Rows, row_stride: RStride, ) -> Self

creates a ColRef 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, nrows, 1, row_stride, 0)]

Source

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

returns a pointer to the column data

Source

pub fn nrows(&self) -> Rows

returns the number of rows of the column

Source

pub fn ncols(&self) -> usize

returns the number of columns of the column (always 1)

Source

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

returns the number of rows and columns of the column

Source

pub fn row_stride(&self) -> RStride

returns the row stride of the column, specified in number of elements, not in bytes

Source

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

returns a raw pointer to the element at the given index

Source

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

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

§safety

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

  • row < self.nrows()
Source

pub fn split_at_row( self, row: IdxInc<Rows>, ) -> (ColRef<'a, T, usize, RStride>, ColRef<'a, T, usize, RStride>)

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

  • top
  • bottom
§panics

the function panics if the following condition is violated:

  • row <= self.nrows()
Source

pub fn transpose(self) -> RowRef<'a, T, Rows, RStride>

returns a view over the transpose of self

Source

pub fn conjugate(self) -> ColRef<'a, T::Conj, Rows, RStride>
where T: Conjugate,

returns a view over the conjugate of self

Source

pub fn canonical(self) -> ColRef<'a, T::Canonical, Rows, RStride>
where T: Conjugate,

returns an unconjugated view over self

Source

pub fn adjoint(self) -> RowRef<'a, T::Conj, Rows, RStride>
where T: Conjugate,

returns a view over the conjugate transpose of self

Source

pub fn get<RowRange>( self, row: RowRange, ) -> <ColRef<'a, T, Rows, RStride> as ColIndex<RowRange>>::Target
where ColRef<'a, T, Rows, RStride>: ColIndex<RowRange>,

returns a reference to the element at the given index, or a subcolumn if row is a range

§panics

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

  • row must be contained in [0, self.nrows())
Source

pub unsafe fn get_unchecked<RowRange>( self, row: RowRange, ) -> <ColRef<'a, T, Rows, RStride> as ColIndex<RowRange>>::Target
where ColRef<'a, T, Rows, RStride>: ColIndex<RowRange>,

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

§safety

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

  • row must be contained in [0, self.nrows())
Source

pub fn reverse_rows(self) -> ColRef<'a, T, Rows, RStride::Rev>

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

Source

pub fn subrows<V: Shape>( self, row_start: IdxInc<Rows>, nrows: V, ) -> ColRef<'a, T, V, RStride>

returns a view over the column starting at row row_start, and with number of rows nrows

§panics

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

  • row_start <= self.nrows()
  • nrows <= self.nrows() - row_start
Source

pub fn as_row_shape<V: Shape>(self, nrows: V) -> ColRef<'a, T, V, RStride>

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

Source

pub fn as_dyn_rows(self) -> ColRef<'a, T, usize, RStride>

returns the input column with dynamic row shape

Source

pub fn as_dyn_stride(self) -> ColRef<'a, T, Rows, isize>

returns the input column with dynamic stride

Source

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

returns an iterator over the elements of the column

Source

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

returns a parallel iterator over the elements of the column

Source

pub fn par_partition( self, count: usize, ) -> impl 'a + IndexedParallelIterator<Item = ColRef<'a, T, usize, RStride>>
where T: Sync, Rows: 'a,

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

only available with the rayon feature

Source

pub fn try_as_col_major(self) -> Option<ColRef<'a, T, Rows, ContiguousFwd>>

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

Source

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

returns a matrix view over self

Source

pub fn as_diagonal(self) -> DiagRef<'a, T, Rows, RStride>

interprets the column as a diagonal matrix

Source§

impl<'a, T, Rows: Shape> ColRef<'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> ColRef<'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, Rows: Shape, RStride: Stride> ColRef<'a, T, Rows, RStride>
where T: RealField,

Source

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

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

Source

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

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

Trait Implementations§

Source§

impl<T, Rows: Shape, Rs: Stride> AsMatRef for ColRef<'_, T, Rows, Rs>

Source§

type Cols = One

column dimension type
Source§

type Owned = Col<Own<T, Rows>>

owned matrix type
Source§

type Rows = Rows

row dimension type
Source§

type T = T

scalar type
Source§

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

returns a view over self
Source§

impl<'a, 'N, T, Rs: Stride> ColIndex<<Dim<'N> as ShapeIdx>::Idx<usize>> for ColRef<'a, T, Dim<'N>, Rs>

Source§

type Target = &'a T

sliced view type
Source§

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

slice this using row
Source§

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

slice this using row, without bound checks
Source§

impl<'a, T, Rs: Stride> ColIndex<<usize as ShapeIdx>::Idx<usize>> for ColRef<'a, T, usize, Rs>

Source§

type Target = &'a T

sliced view type
Source§

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

slice this using row
Source§

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

slice this using row, without bound checks
Source§

impl<'a, R: Shape, T, Rs: Stride, RowRange: IntoRange<IdxInc<R>, Len<R>: 'a>> ColIndex<RowRange> for ColRef<'a, T, R, Rs>

Source§

type Target = Col<Ref<'a, T, <RowRange as IntoRange<<R as ShapeIdx>::IdxInc<usize>>>::Len<R>, Rs>>

sliced view type
Source§

fn get(this: Self, row: RowRange) -> Self::Target

slice this using row
Source§

unsafe fn get_unchecked(this: Self, row: RowRange) -> Self::Target

slice this using row, without bound checks
Source§

impl<'a, T, Rows: Shape, RStride: Stride> IntoView for &'a ColRef<'_, T, Rows, RStride>

Source§

type Target = Col<Ref<'a, T, Rows, RStride>>

Source§

fn into_view(self) -> Self::Target

Source§

impl<'a, T, Rows: Shape, RStride: Stride> IntoView for &'a mut ColRef<'_, T, Rows, RStride>

Source§

type Target = Col<Ref<'a, T, Rows, RStride>>

Source§

fn into_view(self) -> Self::Target

Source§

impl<'a, T, Rows: Shape, RStride: Stride> IntoView for ColRef<'a, T, Rows, RStride>

Source§

type Target = Col<Ref<'a, T, Rows, RStride>>

Source§

fn into_view(self) -> Self::Target

Source§

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

Source§

type Cols = ()

type of columns
Source§

type Dyn = Col<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 = Col

Source§

type LayoutTransform = VecLayoutTransform

layout transformation type
Source§

type Rows = Len

type of rows
Source§

type Slice = SliceRef<'b, T>

Source§

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

returns the number of rows
Source§

fn ncols(_: &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