pub struct RowRef<'a, T> { /* private fields */ }
Expand description
Row vector view with general column stride.
For usage examples, see MatRef
.
Implementations
sourceimpl<'a, T> RowRef<'a, T>
impl<'a, T> RowRef<'a, T>
sourcepub unsafe fn from_raw_parts(
ptr: *const T,
ncols: usize,
col_stride: isize
) -> Self
pub unsafe fn from_raw_parts(
ptr: *const T,
ncols: usize,
col_stride: isize
) -> Self
Returns a row vector slice from the given arguments.
ptr
: pointer to the first element of the row vector.
ncols
: number of columns of the row vector.
col_stride
: offset between the first elements of two successive columns in the row vector.
Safety
ptr
must be non null and properly aligned for type T
.
For each j < ncols
,
ptr.offset(j as isize * col_stride)
must point to a valid
initialized object of type T
, unless memory pointing to that address is never read.
The referenced memory must not be mutated during the lifetime 'a
.
sourcepub fn as_ptr(self) -> *const T
pub fn as_ptr(self) -> *const T
Returns a pointer to the first (left) element of the row vector.
sourcepub fn col_stride(&self) -> isize
pub fn col_stride(&self) -> isize
Returns the offset between the first elements of two successive columns in the row vector.
sourcepub fn ptr_at(self, j: usize) -> *const T
pub fn ptr_at(self, j: usize) -> *const T
Returns a pointer to the element at position (0, j) in the row vector.
sourcepub unsafe fn ptr_in_bounds_at_unchecked(self, j: usize) -> *const T
pub unsafe fn ptr_in_bounds_at_unchecked(self, j: usize) -> *const T
Returns a pointer to the element at position (0, j) in the row vector, assuming it falls within its bounds with no bound checks.
Safety
Requires that j < self.ncols()
.
Otherwise, the behavior is undefined.
sourcepub fn ptr_in_bounds_at(self, j: usize) -> *const T
pub fn ptr_in_bounds_at(self, j: usize) -> *const T
Returns a pointer to the element at position (0, j) in the row vector, while asserting that it falls within its bounds.
Panics
Requires that j < self.ncols()
.
Otherwise, it panics.
sourcepub unsafe fn split_at_unchecked(self, j: usize) -> (Self, Self)
pub unsafe fn split_at_unchecked(self, j: usize) -> (Self, Self)
Splits the row vector into two parts in the following order: left, right.
Safety
Requires that j <= self.ncols()
.
Otherwise, the behavior is undefined.
sourcepub fn split_at(self, j: usize) -> (Self, Self)
pub fn split_at(self, j: usize) -> (Self, Self)
Splits the row vector into two parts in the following order: left, right.
Panics
Requires that j <= self.ncols()
.
Otherwise, it panics.
sourcepub unsafe fn get_unchecked(self, j: usize) -> &'a T
pub unsafe fn get_unchecked(self, j: usize) -> &'a T
Returns a reference to the element at position (0, j), with no bound checks.
Safety
Requires j < self.ncols()
.
Otherwise, the behavior is undefined.