Skip to content

lazymatrix::Submatrix ​

LazyMatrix for Rust · 0.8.1

Source

rust
pub struct Submatrix<'a, M, F = f64>

A borrowed restriction of an already normalized matrix to contiguous ranges.

Construction and nested selection take O(1) time, allocate nothing, and borrow the original data and fitted parameters. Selecting rows never refits normalization. All entry indices exposed by this view are local.

Dense products visit only selected entries. Sparse products scan stored entries in selected outer rows or columns, filtering the other axis. They use O(selected rows + selected columns) workspace, never a dense design copy. Column filtering scans the parent column; row filtering scans the parent row.

This is a logical operator, not a contiguous sparse storage capability. Filtered sparse views expose iterators instead of rebased index slices.

rust
use lazymatrix::{LazyMatrix, SparseColumns, Submatrix};
fn needs_slices<M: SparseColumns<f64>>() {}
fn restricted_columns<M: SparseColumns<f64>>(_: &LazyMatrix<M>) {
    needs_slices::<Submatrix<'_, M>>();
}
rust
use lazymatrix::{LazyMatrix, SparseRows, Submatrix};
fn needs_slices<M: SparseRows<f64>>() {}
fn restricted_rows<M: SparseRows<f64>>(_: &LazyMatrix<M>) {
    needs_slices::<Submatrix<'_, M>>();
}

Inherent implementation ​

Source

rust
impl<'a, M: MatrixShape, F: Scalar> Submatrix<'a, M, F>

centers ​

rust
pub fn centers(&self) -> Option<&'a [F]>

Source

Borrow the selected columns' original centers.

column ​

rust
pub fn column(
    &self,
    j: usize
) -> LazyColumn<FilteredRawColumn<<M as RawColumns>::Column<'_>>, F> where M: RawColumns<F>

Source

Borrow a logical column, filtering and rebasing its stored row indices.

Filtering takes O(parent stored entries) per traversal and allocates nothing. The parent must provide natural column borrowing.

Panics ​

Panics if j >= self.ncols().

ncols ​

rust
pub fn ncols(&self) -> usize

Source

Number of selected columns.

nrows ​

rust
pub fn nrows(&self) -> usize

Source

Number of selected rows.

row ​

rust
pub fn row(&self, i: usize) -> SubmatrixRow<'_, F> where M: SparseRows<F>

Source

Borrow a filtered normalized sparse row without copying its entries.

Stored-entry iteration takes O(parent stored row entries), preserves order and duplicates, and rebases column indices to the selection.

Panics ​

Panics if i >= self.nrows().

scales ​

rust
pub fn scales(&self) -> Option<&'a [F]>

Source

Borrow the selected columns' original scales.

sparse_column ​

rust
pub fn sparse_column(
    &self,
    j: usize
) -> SubmatrixSparseColumn<'_, F> where M: SparseColumns<F>

Source

Borrow a filtered sparse column with locally indexed entry iterators.

Panics ​

Panics if j >= self.ncols().

submatrix ​

rust
pub fn submatrix(&self, rows: Range<usize>, columns: Range<usize>) -> Self

Source

Select a rectangle using coordinates relative to this view.

Panics ​

Panics on reversed or out-of-bounds ranges.

Inherent implementation ​

Source

rust
impl<M: SubmatrixKernel<F>, F: Scalar> Submatrix<'_, M, F>

to_eager ​

rust
pub fn to_eager<D: MatrixOwned<F>>(
    &self
) -> Result<EagerMatrix<D, F>, <M as MatrixErrorType>::Error>

Source

Explicitly allocate and materialize this rectangle in a dense backend.

Requires O(selected rows * selected columns) output storage. Only the selected fitted parameters are cloned; no statistics are recomputed. Returns the source error on failure.

to_eager_into ​

rust
pub fn to_eager_into<'b, D: MatrixWrite<F> + ?Sized>(
    &self,
    out: &'b mut D
) -> Result<EagerMatrix<&'b mut D, F>, <M as MatrixErrorType>::Error>

Source

Overwrite dense output and return an eager operator borrowing it.

Fitted metadata is cloned, and kernels may allocate one working row or column. Output may be partial on a source error.

Panics ​

Panics before writing if the output shape differs from this rectangle.

Implementation of Clone ​

Source

rust
impl<M, F> Clone for Submatrix<'_, M, F>

clone ​

rust
fn clone(&self) -> Self

Source

Implementation of Columns ​

Source

rust
impl<M: RawColumns<F>, F: Scalar> Columns<F> for Submatrix<'_, M, F>

Column ​

rust
type Column<'b> = LazyColumn<FilteredRawColumn<<M as RawColumns<F>>::Column<'b>>, F> where Self: 'b;

Source

column ​

rust
fn column(&self, j: usize) -> <Self as Columns>::Column<'_>

Source

Implementation of Debug ​

Source

rust
impl<'a, M: core::fmt::Debug, F: core::fmt::Debug> Debug for Submatrix<'a, M, F>

fmt ​

rust
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

Source

Implementation of MatTransposeVec ​

Source

rust
impl<M, V, F> MatTransposeVec<V> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, V: VectorOwned<F, Owned = V> + VectorViewMut<F>

mat_transpose_vec ​

rust
fn mat_transpose_vec(
    &self,
    x: &V
) -> Result<V, <Self as MatrixErrorType>::Error>

Source

Implementation of MatTransposeVecInto ​

Source

rust
impl<M, X, Y, F> MatTransposeVecInto<X, Y> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, X: VectorView<F>, Y: VectorViewMut<F>

mat_transpose_vec_into ​

rust
fn mat_transpose_vec_into(
    &self,
    x: &X,
    out: &mut Y
) -> Result<(), <Self as MatrixErrorType>::Error>

Source

Implementation of MatTransposeVecScaledInto ​

Source

rust
impl<M, X, Y, F> MatTransposeVecScaledInto<X, Y, F> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, X: VectorView<F>, Y: VectorViewMut<F>

mat_transpose_vec_scaled_into ​

rust
fn mat_transpose_vec_scaled_into(
    &self,
    alpha: F,
    x: &X,
    beta: F,
    out: &mut Y
) -> Result<(), <Self as MatrixErrorType>::Error>

Source

Implementation of MatVec ​

Source

rust
impl<M, V, F> MatVec<V> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, V: VectorOwned<F, Owned = V> + VectorViewMut<F>

matvec ​

rust
fn matvec(&self, x: &V) -> Result<V, <Self as MatrixErrorType>::Error>

Source

Implementation of MatVecInto ​

Source

rust
impl<M, X, Y, F> MatVecInto<X, Y> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, X: VectorView<F>, Y: VectorViewMut<F>

matvec_into ​

rust
fn matvec_into(
    &self,
    x: &X,
    out: &mut Y
) -> Result<(), <Self as MatrixErrorType>::Error>

Source

Implementation of MatVecScaledInto ​

Source

rust
impl<M, X, Y, F> MatVecScaledInto<X, Y, F> for Submatrix<'_, M, F> where M: SubmatrixKernel<F>, F: Scalar, X: VectorView<F>, Y: VectorViewMut<F>

matvec_scaled_into ​

rust
fn matvec_scaled_into(
    &self,
    alpha: F,
    x: &X,
    beta: F,
    out: &mut Y
) -> Result<(), <Self as MatrixErrorType>::Error>

Source

Implementation of MatrixErrorType ​

Source

rust
impl<M: MatrixErrorType, F> MatrixErrorType for Submatrix<'_, M, F>

Error ​

rust
type Error = <M as MatrixErrorType>::Error;

Source

Implementation of MatrixShape ​

Source

rust
impl<M, F> MatrixShape for Submatrix<'_, M, F>

ncols ​

rust
fn ncols(&self) -> usize

Source

nrows ​

rust
fn nrows(&self) -> usize

Source

Implementation of Freeze ​

rust
impl<'a, M, F> Freeze for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: Freeze

Implementation of RefUnwindSafe ​

rust
impl<'a, M, F> RefUnwindSafe for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: RefUnwindSafe

Implementation of Send ​

rust
impl<'a, M, F> Send for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: Send

Implementation of Sync ​

rust
impl<'a, M, F> Sync for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: Sync

Implementation of Unpin ​

rust
impl<'a, M, F> Unpin for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: Unpin

Implementation of UnsafeUnpin ​

rust
impl<'a, M, F> UnsafeUnpin for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: UnsafeUnpin

Implementation of UnwindSafe ​

rust
impl<'a, M, F> UnwindSafe for Submatrix<'a, M, F> where &'a LazyMatrix<M, F>: UnwindSafe

Implementation of Any ​

rust
impl<T> Any for T where T: 'static + ?Sized

Implementation of Borrow ​

rust
impl<T> Borrow<T> for T where T: ?Sized

Implementation of BorrowMut ​

rust
impl<T> BorrowMut<T> for T where T: ?Sized

Implementation of ByRef ​

rust
impl<T> ByRef<T> for T

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized

Implementation of CloneToUninit ​

rust
impl<T> CloneToUninit for T where T: Clone

Implementation of From ​

rust
impl<T> From<T> for T

Implementation of Imply ​

rust
impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized

Implementation of Into ​

rust
impl<T, U> Into<U> for T where U: From<T>

Implementation of IntoEither ​

rust
impl<T> IntoEither for T

Implementation of Pointable ​

rust
impl<T> Pointable for T

Implementation of Read ​

rust
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized

Implementation of Same ​

rust
impl<T> Same for T

Implementation of SupersetOf ​

rust
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>

Implementation of ToOwned ​

rust
impl<T> ToOwned for T where T: Clone

Implementation of TryFrom ​

rust
impl<T, U> TryFrom<U> for T where U: Into<T>

Implementation of TryInto ​

rust
impl<T, U> TryInto<U> for T where U: TryFrom<T>

Released under the MIT and Apache 2.0 licenses.