Skip to main content

Module view

Module view 

Source
Expand description

§Chapter 12.0.2 — Dense views

§Purpose

The caller’s data — an R matrix, a NumPy array in Fortran order, a block inside a larger array — is borrowed, not copied: MatRef and MatMut are column-major views with a leading dimension (decision S3 of D-0127). The owned type of the crate’s outputs is DenseBlock of xingo-sparse (ld = rows).

§Notation

A view is rows × cols with leading dimension ld ≥ rows: a_ij = data[i + j·ld]. Column j is the contiguous slice `data[j·ld .. j·ld

  • rows]. A C-order NumPy array is the view of its *transpose* (a rule for xingo-ffi`).

§Algorithm V (checked construction)

V1. [Leading dimension.] If ld < rows, InvalidArgument. V2. [Extent.] If cols = 0 the extent is 0; otherwise need = ld·(cols − 1) + rows, computed with checked arithmetic (InvalidArgument on usize overflow). V3. [Length.] If data.len() < need, Dimension { what: "data", expected: need, found: data.len() }. Longer slices are accepted (the tail is not part of the view).

Finiteness is not checked here, but by the consumers (each reports the column-major position i + j·rows).

§Invariant

(W1) ld ≥ rows and data.len() ≥ need for every live view, so every accessor below indexes in bounds; the accessors that take indices return None (or an error) out of range instead of panicking.

Structs§

MatMut
The mutable counterpart of MatRef.
MatRef
A borrowed column-major rows × cols matrix with leading dimension ld ≥ rows: a_ij = data[i + j·ld] (the LAPACK/R layout; a C-order NumPy array is the view of its transpose, a rule for xingo-ffi). data.len() ≥ ld·(cols − 1) + rows when cols > 0.

Functions§

extent 🔒
Algorithm V: the extent need of a view, or the error.