Skip to main content

MatrixV

Struct MatrixV 

Source
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 through Arc.
  • 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_matrix to materialise the window as an independent Matrix.
  • MatrixV::as_strided returns (data, lda) for BLAS and LAPACK, with data positioned at the first row of the window.
  • MatrixV::as_tuple returns (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::col for individual columns or convert to Table for named-column operations.

Fields§

§matrix: Arc<Matrix>

Backing matrix shared by all views over the same data.

§offset: usize

Index of the first row in the backing matrix.

§len: usize

Number of rows in the window.

Implementations§

Source§

impl MatrixV

Source

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.

Source

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.

Source

pub fn from_self(&self, offset: usize, len: usize) -> Self

Creates a sub-window with offset relative to this view.

Source

pub fn n_rows(&self) -> usize

Returns the number of rows in the window.

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of rows in the window.

Source

pub fn is_empty(&self) -> bool

Returns true if the window has no rows or the backing matrix has no columns.

Source

pub fn end(&self) -> usize

Returns the exclusive end row of the window in backing-matrix coordinates.

Source

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.

Source

pub fn name(&self) -> Option<&str>

Returns the backing matrix name.

Source

pub fn stride(&self) -> usize

Returns the backing matrix column stride in elements.

This is the BLAS leading dimension (lda).

Source

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.

Source

pub fn columns(&self) -> Vec<&[f64]>

Returns all column windows in column order.

Source

pub fn get(&self, row: usize, col: usize) -> f64

Returns the value at (row, col).

row is relative to the current window.

Source

pub fn row(&self, row: usize) -> Vec<f64>

Returns one window-relative row as an owned Vec<f64>.

Source

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.

Source

pub fn m(&self) -> i32

Returns the window row count as i32 for BLAS and LAPACK calls.

Source

pub fn n(&self) -> i32

Returns the column count as i32 for BLAS and LAPACK calls.

Source

pub fn lda(&self) -> i32

Returns the BLAS leading dimension (lda).

Row windowing does not change the physical spacing between backing columns.

Source

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.

Source

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.

Source

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.

Source

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 ByteSize for MatrixV

Available on crate features matrix and views only.
Source§

fn est_bytes(&self) -> usize

Returns the estimated byte size of this object in memory. Read more
Source§

fn logical_bytes(&self) -> usize

Returns the exact logical byte size of the data. Read more
Source§

impl Clone for MatrixV

Source§

fn clone(&self) -> MatrixV

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Concatenate for MatrixV

Source§

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 Debug for MatrixV

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for MatrixV

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Arc<Matrix>> for MatrixV

Converts a shared Arc<Matrix> to a full-span MatrixV.

Source§

fn from(matrix: Arc<Matrix>) -> Self

Converts to this type from the input type.
Source§

impl From<Matrix> for MatrixV

Converts an owned Matrix to a full-span MatrixV.

Source§

fn from(matrix: Matrix) -> Self

Converts to this type from the input type.
Source§

impl From<MatrixV> for Value

Available on crate features matrix and views only.
Source§

fn from(v: MatrixV) -> Self

Converts to this type from the input type.
Source§

impl From<MatrixV> for Matrix

Materialises a MatrixV as an owned Matrix.

Source§

fn from(view: MatrixV) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MatrixV

Equality is based on shape and values rather than backing storage.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RowSelection for MatrixV

Available on crate feature 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§

type View = MatrixV

The view type returned by selection operations
Source§

fn r<S: DataSelector>(&self, selection: S) -> MatrixV

Select rows by index or range Read more
Source§

fn get_row_count(&self) -> usize

Get the count for data resolution
Source§

fn row(&self, idx: usize) -> Self::View

Select a single row by index Read more
Source§

impl Shape for MatrixV

Source§

fn shape(&self) -> ShapeDim

Returns arbitrary Shape dimension for any data shape
Source§

fn shape_1d(&self) -> usize

Returns the first dimension shape Read more
Source§

fn shape_2d(&self) -> (usize, usize)

Returns the first and second dimension shapes Read more
Source§

fn shape_3d(&self) -> (usize, usize, usize)

Returns the first, second and third dimension shapes Read more
Source§

fn shape_4d(&self) -> (usize, usize, usize, usize)

Returns the first, second, third and fourth dimension shapes Read more
Source§

impl TryFrom<Value> for MatrixV

Available on crate features matrix and views only.
Source§

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

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Send + Sync + Clone + PartialEq + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcasts the type as Any
Source§

fn deep_clone(&self) -> Arc<dyn CustomValue>

Returns a deep clone of the object. Read more
Source§

fn eq_box(&self, other: &(dyn CustomValue + 'static)) -> bool

Performs semantic equality on the boxed object. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Print for T
where T: Display,

Source§

fn print(&self)
where Self: Display,

Source§

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

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.