pub struct MatrixV {
pub matrix: Arc<Matrix>,
pub offset: usize,
pub len: usize,
}Expand description
§MatrixView
Row window over a Matrix covering rows [offset .. offset + len).
§Fields
matrix: backing matrix shared throughArc.offset: index of the first row in the backing matrix.len: number of rows in the window.
§Behaviour
- Construction and re-windowing do not copy column data. Use
MatrixV::to_matrixto materialise the window as an independentMatrix. MatrixV::as_stridedreturns(data, lda)for BLAS and LAPACK, withdatapositioned at the first row of the window.MatrixV::as_tuplereturns(data, offset, length, stride)for kernels that operate without the view type.- Columns are positional and have no names or null masks. Column selection
is not supported. Use
MatrixV::colfor individual columns or convert toTablefor named-column operations.
Fields§
§matrix: Arc<Matrix>Backing matrix shared by all views over the same data.
offset: usizeIndex of the first row in the backing matrix.
len: usizeNumber of rows in the window.
Implementations§
Source§impl MatrixV
impl MatrixV
Sourcepub fn from_matrix(matrix: Matrix, offset: usize, len: usize) -> Self
pub fn from_matrix(matrix: Matrix, offset: usize, len: usize) -> Self
Creates a view over rows [offset .. offset + len) of the matrix.
The matrix is moved into shared Arc storage for this view and any
subsequent views derived from it.
Sourcepub fn from_arc_matrix(matrix: Arc<Matrix>, offset: usize, len: usize) -> Self
pub fn from_arc_matrix(matrix: Arc<Matrix>, offset: usize, len: usize) -> Self
Creates a zero-copy view over matrix[offset .. offset+len) rows of an
already-shared matrix. /// Creates a view over rows [offset .. offset + len) of a shared matrix.
Sourcepub fn from_self(&self, offset: usize, len: usize) -> Self
pub fn from_self(&self, offset: usize, len: usize) -> Self
Creates a sub-window with offset relative to this view.
Sourcepub fn n_cols(&self) -> usize
pub fn n_cols(&self) -> usize
Returns the number of columns in the backing matrix.
Windowing affects rows only, so every backing column remains present.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the window has no rows or the backing matrix has no
columns.
Sourcepub fn end(&self) -> usize
pub fn end(&self) -> usize
Returns the exclusive end row of the window in backing-matrix coordinates.
Sourcepub fn spans_backing(&self) -> bool
pub fn spans_backing(&self) -> bool
Returns true if the window covers every row of the backing matrix.
Full-span views can be materialised by cloning the backing matrix rather than constructing a new row window.
Sourcepub fn stride(&self) -> usize
pub fn stride(&self) -> usize
Returns the backing matrix column stride in elements.
This is the BLAS leading dimension (lda).
Sourcepub fn col(&self, col: usize) -> &[f64]
pub fn col(&self, col: usize) -> &[f64]
Returns column col over the current row window.
The returned slice is contiguous. Panics if col is outside the
backing matrix.
Sourcepub fn get(&self, row: usize, col: usize) -> f64
pub fn get(&self, row: usize, col: usize) -> f64
Returns the value at (row, col).
row is relative to the current window.
Sourcepub fn row(&self, row: usize) -> Vec<f64>
pub fn row(&self, row: usize) -> Vec<f64>
Returns one window-relative row as an owned Vec<f64>.
Sourcepub fn as_tuple(&self) -> MatrixVT<'_>
pub fn as_tuple(&self) -> MatrixVT<'_>
Returns the view as (data, offset, length, stride).
data references the complete backing buffer. offset and length
identify the current row window, and stride gives the physical spacing
between columns.
Sourcepub fn lda(&self) -> i32
pub fn lda(&self) -> i32
Returns the BLAS leading dimension (lda).
Row windowing does not change the physical spacing between backing columns.
Sourcepub fn as_strided(&self) -> (&[f64], i32)
pub fn as_strided(&self) -> (&[f64], i32)
Returns the window as (data, lda) for BLAS and LAPACK.
data begins at the first row of the window. Element (i, j) is located
at data[j * lda + i] for the m() × n() view.
Sourcepub fn as_mut_strided(&mut self) -> (&mut [f64], i32)
pub fn as_mut_strided(&mut self) -> (&mut [f64], i32)
Returns mutable strided storage for BLAS and LAPACK routines.
Arc::make_mut provides copy-on-write behaviour when the backing matrix
is shared. Mutations affect only the resulting backing allocation after
any required copy.
Sourcepub fn to_matrix(&self) -> Matrix
pub fn to_matrix(&self) -> Matrix
Materialises the window as an owned Matrix.
Partial windows are copied into a new 64-byte-aligned column-major
buffer with stride appropriate to the new row count. Full-span windows
use the backing matrix’s Clone implementation.
Sourcepub fn gather_rows(&self, indices: &[usize]) -> Matrix
pub fn gather_rows(&self, indices: &[usize]) -> Matrix
Gathers window-relative rows into a new owned Matrix.
Output rows follow the order of indices. Panics if any index is outside
the current window.
Trait Implementations§
Source§impl Concatenate for MatrixV
impl Concatenate for MatrixV
Source§fn concat(self, other: Self) -> Result<Self, MinarrowError>
fn concat(self, other: Self) -> Result<Self, MinarrowError>
Concatenates two row windows into one owned matrix.
Both windows must have the same number of columns. The result is returned as a full-span view over the concatenated matrix.
Source§impl RowSelection for MatrixV
Available on crate feature select only.Row selection over an existing matrix view.
impl RowSelection for MatrixV
select only.Row selection over an existing matrix view.
Contiguous selections return a sub-window over the same backing matrix. Non-contiguous selections gather the requested rows into a new owned matrix and return a full-span view over it.
Source§fn get_row_count(&self) -> usize
fn get_row_count(&self) -> usize
Source§impl Shape for MatrixV
impl Shape for MatrixV
Source§impl TryFrom<Value> for MatrixV
Available on crate features matrix and views only.
impl TryFrom<Value> for MatrixV
matrix and views only.Source§fn try_from(v: Value) -> Result<Self, Self::Error>
fn try_from(v: Value) -> Result<Self, Self::Error>
Accepts any Value that resolves to a Matrix, viewed over its full
row extent. An incoming MatrixView passes through unchanged. Other
matrix-like types convert through Matrix::try_from first.
Source§type Error = MinarrowError
type Error = MinarrowError
Auto Trait Implementations§
impl Freeze for MatrixV
impl RefUnwindSafe for MatrixV
impl Send for MatrixV
impl Sync for MatrixV
impl Unpin for MatrixV
impl UnsafeUnpin for MatrixV
impl UnwindSafe for MatrixV
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomValue for T
impl<T> CustomValue for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more