pub struct ColRef<'a, T> { /* private fields */ }
Expand description
Column vector view with general row stride.
For usage examples, see MatRef
.
Implementations
sourceimpl<'a, T> ColRef<'a, T>
impl<'a, T> ColRef<'a, T>
sourcepub unsafe fn from_raw_parts(
ptr: *const T,
nrows: usize,
row_stride: isize
) -> Self
pub unsafe fn from_raw_parts(
ptr: *const T,
nrows: usize,
row_stride: isize
) -> Self
Returns a column vector slice from the given arguments.
ptr
: pointer to the first element of the column vector.
ncols
: number of columns of the column vector.
col_stride
: offset between the first elements of two successive columns in the column
vector.
Safety
ptr
must be non null and properly aligned for type T
.
For each i < nrows
,
ptr.offset(i as isize * row_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 (top) element of the column vector.
sourcepub fn ncols(&self) -> usize
pub fn ncols(&self) -> usize
Returns the number of columns of the column vector. Always returns 1
.
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 column vector.
sourcepub fn ptr_at(self, i: usize) -> *const T
pub fn ptr_at(self, i: usize) -> *const T
Returns a pointer to the element at position (i, 0) in the column vector.
sourcepub unsafe fn ptr_in_bounds_at_unchecked(self, i: usize) -> *const T
pub unsafe fn ptr_in_bounds_at_unchecked(self, i: usize) -> *const T
Returns a pointer to the element at position (i, 0) in the column vector, assuming it falls within its bounds with no bound checks.
Safety
Requires that i < self.nrows()
.
Otherwise, the behavior is undefined.
sourcepub fn ptr_in_bounds_at(self, i: usize) -> *const T
pub fn ptr_in_bounds_at(self, i: usize) -> *const T
Returns a pointer to the element at position (i, 0) in the column vector, while asserting that it falls within its bounds.
Panics
Requires that i < self.nrows()
.
Otherwise, it panics.
sourcepub unsafe fn split_at_unchecked(self, i: usize) -> (Self, Self)
pub unsafe fn split_at_unchecked(self, i: usize) -> (Self, Self)
Splits the column vector into two parts in the following order: top, bottom.
Safety
Requires that i <= self.nrows()
.
Otherwise, the behavior is undefined.
sourcepub fn split_at(self, i: usize) -> (Self, Self)
pub fn split_at(self, i: usize) -> (Self, Self)
Splits the column vector into two parts in the following order: top, bottom.
Panics
Requires that i <= self.nrows()
.
Otherwise, it panics.
sourcepub unsafe fn get_unchecked(self, i: usize) -> &'a T
pub unsafe fn get_unchecked(self, i: usize) -> &'a T
Returns a reference to the element at position (i, 0), with no bound checks.
Safety
Requires i < self.nrows()
.
Otherwise, the behavior is undefined.