batchlas::MatrixView< T, MType > Class Template Reference

Overview

template<typename T, MatrixFormat MType>
class batchlas::MatrixView< T, MType >

Non-owning view of a batch of matrices: the argument type of every entry point.

Same layout as Matrix (column-major dense with ld and stride, or strided CSR) over memory it does not own. Copying a view is cheap and aliases the data; the viewed memory must outlive every use, including kernels still in flight. The memory must be USM that the Queue's device can access; entry points check the pointers at the call. A view may be built over raw pointers, a Matrix (every Matrix is a MatrixView), a sub-block (operator()(Slice, Slice)), a single item (batch_item()) or a VectorView.

Members taking a const Queue& enqueue a kernel and return its Event without waiting. The queue-less overloads run on a new Queue() on Device::default_device().

Template Parameters
Tscalar type
MTypeMatrixFormat::Dense (default) or MatrixFormat::CSR
See also
Matrix model

Definition at line 485 of file matrix.hh.

#include <batchlas/blas/matrix.hh>

Inheritance diagram for batchlas::MatrixView< T, MType >:

Types

◆ promoted_type

template<typename T, MatrixFormat MType>
using batchlas::MatrixView< T, MType >::promoted_type = std::conditional_t<is_std_complex_v<T>, std::complex<double>, double>

T's promoted type: double, or complex<double> for complex T.

Definition at line 649 of file matrix.hh.

Constructors

◆ MatrixView() [1/8]

template<typename T, MatrixFormat MType>
template<typename U = T, MatrixFormat M = MType>
requires DenseMatrixFormat<M>
batchlas::MatrixView< T, MType >::MatrixView ( T * data,
int rows,
int cols,
int ld = 0,
int stride = 0,
int batch_size = 1,
T ** data_ptrs = nullptr )

Dense view over caller memory.

Note the argument order: the batch size is the sixth argument here and the third in Matrix(rows, cols, batch_size).

Parameters
database of item 0 (may be null for a shape-only view, e.g. a workspace query)
rowsrows per item
colscolumns per item
ldleading dimension; 0 means rows
stridebatch stride; 0 means (resolved ld) * cols. Not a broadcast.
batch_sizenumber of items
data_ptrsoptional per-item pointer array for pointer-array backends
Exceptions
batchlas::invalid_argumenton a negative argument or a resolved ld < rows (the message names the intended spelling)
Note
stride < ld * cols is not rejected here, unlike the Matrix constructor.

◆ MatrixView() [2/8]

template<typename T, MatrixFormat MType>
template<typename U = T, MatrixFormat M = MType>
requires CsrMatrixFormat<M>
batchlas::MatrixView< T, MType >::MatrixView ( T * data,
int * row_offsets,
int * col_indices,
int rows,
int cols,
NonZeros nnz,
int matrix_stride = 0,
int offset_stride = 0,
int batch_size = 1,
T ** data_ptrs = nullptr )

CSR view over caller arrays; layout as in the CSR Matrix from-data constructor.

Parameters
data_ptrsoptional per-item pointer array to the values

◆ MatrixView() [3/8]

template<typename T, MatrixFormat MType>
template<typename U = T, MatrixFormat M = MType>
requires CsrMatrixFormat<M>
batchlas::MatrixView< T, MType >::MatrixView ( T * data,
int * row_offsets,
int * col_indices,
int nnz,
int rows,
int cols,
int matrix_stride = 0,
int offset_stride = 0,
int batch_size = 1,
T ** data_ptrs = nullptr )
delete

Deleted so the pre-tag order (nnz before rows, cols) is a compile error.

◆ MatrixView() [4/8]

template<typename T, MatrixFormat MType>
template<typename U = T, MatrixFormat M = MType>
requires DenseMatrixFormat<M>
batchlas::MatrixView< T, MType >::MatrixView ( const VectorView< T > & vector_view,
VectorOrientation orientation = VectorOrientation::Column )

Views a batched vector as n x 1 (Column) or 1 x n (Row) matrices; the stride carries over.

Exceptions
batchlas::invalid_argumentfor Column when the vector's inc != 1

◆ MatrixView() [5/8]

template<typename T, MatrixFormat MType>
template<typename U = T, MatrixFormat M = MType>
requires DenseMatrixFormat<M>
batchlas::MatrixView< T, MType >::MatrixView ( const MatrixView< T, MType > & matrix_view,
int rows = -1,
int cols = -1,
int ld = -1,
int stride = -1,
int batch_size = -1 )

View of matrix_view with any of its extents or strides overridden; a value <= 0 keeps the view's.

Active extents carry over only when every override is a no-op.

◆ MatrixView() [6/8]

template<typename T, MatrixFormat MType>
batchlas::MatrixView< T, MType >::MatrixView ( )
default

An empty 0 x 0 view with batch size 0.

◆ MatrixView() [7/8]

template<typename T, MatrixFormat MType>
batchlas::MatrixView< T, MType >::MatrixView ( const MatrixView< T, MType > & )
default

◆ MatrixView() [8/8]

template<typename T, MatrixFormat MType>
batchlas::MatrixView< T, MType >::MatrixView ( MatrixView< T, MType > && )
defaultnoexcept

◆ ~MatrixView()

template<typename T, MatrixFormat MType>
batchlas::MatrixView< T, MType >::~MatrixView ( )
default

Releases nothing but the shared backend handle; the viewed memory is untouched.

Functions

◆ copy()

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::copy ( Queue & ctx,
const MatrixView< T, MType > & dest,
const MatrixView< T, MType > & src )
static

Enqueues dest := src on ctx, honouring each side's ld and stride.

Returns
the event of the copy; a no-op when both views share a base pointer
Exceptions
batchlas::invalid_argumentif rows, cols or batch size differ
batchlas::unsupportedfor CSR views

◆ operator=() [1/2]

template<typename T, MatrixFormat MType>
MatrixView & batchlas::MatrixView< T, MType >::operator= ( const MatrixView< T, MType > & )
default

◆ operator=() [2/2]

template<typename T, MatrixFormat MType>
MatrixView & batchlas::MatrixView< T, MType >::operator= ( MatrixView< T, MType > && )
defaultnoexcept

◆ init()

template<typename T, MatrixFormat MType>
void batchlas::MatrixView< T, MType >::init ( ) const

Creates the backend descriptor now instead of on first use; idempotent.

◆ operator->()

template<typename T, MatrixFormat MType>
BackendMatrixHandle< T, MType > * batchlas::MatrixView< T, MType >::operator-> ( ) const

The backend descriptor, created on first use.

◆ operator*()

template<typename T, MatrixFormat MType>
BackendMatrixHandle< T, MType > & batchlas::MatrixView< T, MType >::operator* ( ) const

The backend descriptor, created on first use.

◆ operator[]()

template<typename T, MatrixFormat MType>
MatrixView< T, MType > batchlas::MatrixView< T, MType >::operator[] ( int i) const

batch_item(i).

◆ data()

template<typename T, MatrixFormat MType>
Span< T > batchlas::MatrixView< T, MType >::data ( ) const
inline

The viewed value storage, from item 0 to the end of the last item.

Definition at line 577 of file matrix.hh.

◆ set_access_device()

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::set_access_device ( const Queue & ctx) const
inline

Migrates the viewed memory to the device of ctx.

Definition at line 582 of file matrix.hh.

◆ prefetch()

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::prefetch ( const Queue & ctx) const
inline

Migrates the viewed memory to the device of ctx.

Definition at line 591 of file matrix.hh.

◆ data_ptr()

template<typename T, MatrixFormat MType>
T * batchlas::MatrixView< T, MType >::data_ptr ( ) const
inline

Base pointer of item 0.

Definition at line 600 of file matrix.hh.

◆ batch_size()

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::batch_size ( ) const
inline

Number of batch items.

Definition at line 603 of file matrix.hh.

◆ rows() [1/2]

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::rows ( ) const
inline

Rows per item (the capacity on a heterogeneous batch).

Definition at line 605 of file matrix.hh.

◆ rows() [2/2]

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::rows ( int batch_index) const
inline

Active rows of item batch_index.

Definition at line 607 of file matrix.hh.

◆ cols() [1/2]

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::cols ( ) const
inline

Columns per item (the capacity on a heterogeneous batch).

Definition at line 611 of file matrix.hh.

◆ cols() [2/2]

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::cols ( int batch_index) const
inline

Active columns of item batch_index.

Definition at line 613 of file matrix.hh.

◆ rows_capacity()

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::rows_capacity ( ) const
inline

Equal to rows().

Definition at line 617 of file matrix.hh.

◆ cols_capacity()

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::cols_capacity ( ) const
inline

Equal to cols().

Definition at line 619 of file matrix.hh.

◆ is_heterogeneous()

template<typename T, MatrixFormat MType>
bool batchlas::MatrixView< T, MType >::is_heterogeneous ( ) const
inline

True when per-item active extents are attached.

Definition at line 621 of file matrix.hh.

◆ active_rows()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Span< int > batchlas::MatrixView< T, MType >::active_rows ( ) const
inline

Per-item active row counts; empty when homogeneous.

Definition at line 626 of file matrix.hh.

◆ active_cols()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Span< int > batchlas::MatrixView< T, MType >::active_cols ( ) const
inline

Per-item active column counts; empty when homogeneous.

Definition at line 631 of file matrix.hh.

◆ astype() [1/2]

template<typename T, MatrixFormat MType>
template<typename U>
Matrix< U, MType > batchlas::MatrixView< T, MType >::astype ( ) const

Packed dense copy with every element converted by static_cast<U>; host loop, no Queue.

Definition at line 2083 of file matrix.hh.

◆ up()

template<typename T, MatrixFormat MType>
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
promoted_type batchlas::MatrixView< T, MType >::up ( U x)
inlinestatic

x as promoted_type.

Definition at line 654 of file matrix.hh.

◆ make()

template<typename T, MatrixFormat MType>
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
U batchlas::MatrixView< T, MType >::make ( double re,
double im = 0.0 )
inlinestatic

re + i im rounded to T; the imaginary part is dropped for a real T.

Definition at line 659 of file matrix.hh.

◆ conj()

template<typename T, MatrixFormat MType>
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
U batchlas::MatrixView< T, MType >::conj ( U x)
inlinestatic

The complex conjugate of x; x itself for a real T.

Definition at line 667 of file matrix.hh.

◆ cabs1()

template<typename T, MatrixFormat MType>
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
double batchlas::MatrixView< T, MType >::cabs1 ( U x)
inlinestatic

|re| + |im|, LAPACK's partial-pivoting metric; |x| for a real T.

Definition at line 675 of file matrix.hh.

◆ finite()

template<typename T, MatrixFormat MType>
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
bool batchlas::MatrixView< T, MType >::finite ( U x)
inlinestatic

True when every component of x is finite.

Definition at line 683 of file matrix.hh.

◆ all_items()

template<typename T, MatrixFormat MType>
std::vector< int > batchlas::MatrixView< T, MType >::all_items ( ) const

Every item index, 0 .. batch_size() - 1.

Definition at line 2130 of file matrix.hh.

◆ default_items()

template<typename T, MatrixFormat MType>
std::vector< int > batchlas::MatrixView< T, MType >::default_items ( ) const

{0, batch_size() / 2, batch_size() - 1}, sorted and de-duplicated ({} for batch 0): what a check reads by default.

Definition at line 2137 of file matrix.hh.

◆ astype() [2/2]

template<typename T, MatrixFormat MType>
template<typename U>
Matrix< U, MType > batchlas::MatrixView< T, MType >::astype ( std::span< const int > items) const

astype() of items only, packed in that order (item g at g * rows() * cols()).

Exceptions
batchlas::out_of_rangefor an item outside [0, batch_size())
batchlas::invalid_argumentfor a heterogeneous view

Definition at line 2112 of file matrix.hh.

◆ product()

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::product ( const Queue & ctx,
const MatrixView< T, MType > & A,
Transpose ta,
const MatrixView< T, MType > & B,
Transpose tb,
const MatrixView< T, MType > & C )
static

C := op(A) op(B) per item: one work-item per element of C, the inner sum in order.

The reference product of the checks, independent of gemm's tuned kernels.

Exceptions
batchlas::invalid_argumenton a shape mismatch

◆ potrf_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::potrf_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & F,
Uplo uplo,
std::span< const int > items = {} )
static

||A0 - L L^H||_F / ||A0||_F (Lower) or ||A0 - U^H U||_F / ||A0||_F (Upper) over the factor's triangle; the other triangle of F is not read.

◆ getrf_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::getrf_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & F,
const VectorView< std::int32_t > & piv,
std::span< const int > items = {} )
static

||P A0 - L U||_F / ||A0||_F for an m x n factor with packed 1-based pivots (min(m, n) per item); an out-of-range pivot makes that item NaN.

◆ qr_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::qr_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & F,
const VectorView< T > & tau,
std::span< const int > items = {} )
static

||A0 - Q R||_F / ||A0||_F for F in LAPACK geqrf storage and its min(m, n) tau.

◆ form_q() [1/2]

template<typename T, MatrixFormat MType>
Matrix< promoted_type, MType > batchlas::MatrixView< T, MType >::form_q ( Queue & ctx,
const MatrixView< T, MType > & F,
const VectorView< T > & tau,
int item,
int cols )
static

The first cols columns of Q = H_0 ... H_{k-1} of item item of a geqrf factor (k = min(m, n)); F's diagonal and upper triangle are not read.

◆ form_q() [2/2]

template<typename T, MatrixFormat MType>
Matrix< promoted_type, MType > batchlas::MatrixView< T, MType >::form_q ( Queue & ctx,
const MatrixView< T, MType > & F,
const VectorView< T > & tau,
std::span< const int > items,
int cols )
static

form_q() of each of items (empty: default_items()), packed in that order: item g of the result is the first cols columns of Q of item items[g].

◆ qr_reconstruction()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::qr_reconstruction ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & Q,
const MatrixView< T, MType > & R,
std::span< const int > items = {} )
static

||A0 - Q triu(R)||_F / ||A0||_F with an explicit m x k Q; the first k rows of R are read on and above the diagonal.

◆ similarity_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::similarity_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & Q,
const MatrixView< T, MType > & B,
std::span< const int > items = {} )
static

||A0 - Q B Q^H||_F / ||A0||_F for square operands of equal order.

◆ svd_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::svd_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & U,
const VectorView< float_t< T > > & s,
const MatrixView< T, MType > & Vh,
std::span< const int > items = {} )
static

||A0 - U diag(s) Vh||_F / ||A0||_F for an m x n A0 over the first k = min(m, n) columns of U, values of s and rows of Vh (thin or full factors).

Exceptions
batchlas::invalid_argumenton a shape mismatch

◆ solve_residual() [1/2]

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::solve_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
Transpose ta,
const MatrixView< T, MType > & X,
const MatrixView< T, MType > & B0,
std::span< const int > items = {},
double full_limit = double(1<< 28) )
static

||op(A0) X - B0||_F / (||A0||_F ||X||_F); an empty B0 (rows() == 0) is the identity.

Above full_limit multiply-adds per item, 8 seeded probe columns of X stand in for all.

◆ solve_residual() [2/2]

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::solve_residual ( Queue & ctx,
const MatrixView< T, MType > & A0,
const MatrixView< T, MType > & X,
const MatrixView< T, MType > & B0,
std::span< const int > items = {} )
static

solve_residual() with op(A0) = A0.

◆ lu_solve_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::lu_solve_residual ( Queue & ctx,
const MatrixView< T, MType > & F,
const VectorView< std::int32_t > & piv,
Transpose ta,
const MatrixView< T, MType > & X,
const MatrixView< T, MType > & B0,
std::span< const int > items = {},
double full_limit = double(1<< 28) )
static

solve_residual() with A = P L U formed per item from getrf factors F and pivots piv; full_limit as for solve_residual().

◆ gemm_backward_error()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::gemm_backward_error ( Queue & ctx,
const MatrixView< T, MType > & A,
Transpose ta,
const MatrixView< T, MType > & B,
Transpose tb,
const MatrixView< T, MType > & C0,
const MatrixView< T, MType > & C,
promoted_type alpha,
promoted_type beta,
std::span< const int > items = {},
std::optional< Uplo > c_triangle = std::nullopt )
static

Componentwise max |C - (alpha op(A) op(B) + beta C0)| / (|alpha| |op(A)| |op(B)| + |beta| |C0|), over c_triangle of C when given; C0 is not read when beta == 0.

◆ gemm_max_denominator()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::gemm_max_denominator ( Queue & ctx,
const MatrixView< T, MType > & A,
Transpose ta,
const MatrixView< T, MType > & B,
Transpose tb,
const MatrixView< T, MType > & C0,
promoted_type alpha,
promoted_type beta,
std::span< const int > items = {} )
static

The largest denominator of gemm_backward_error() over items (empty: A's default_items(), while gemm_backward_error() defaults to C's: pass both the same span when A's batch differs).

◆ gemv_backward_error()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::gemv_backward_error ( Queue & ctx,
const MatrixView< T, MType > & A,
Transpose ta,
const VectorView< T > & x,
const VectorView< T > & y0,
const VectorView< T > & y,
promoted_type alpha,
promoted_type beta,
std::span< const int > items = {} )
static

gemm_backward_error() of y = alpha op(A) x + beta y0.

◆ trsm_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::trsm_residual ( Queue & ctx,
const MatrixView< T, MType > & A,
Side side,
Uplo uplo,
Transpose ta,
Diag diag,
const MatrixView< T, MType > & X,
const MatrixView< T, MType > & B0,
promoted_type alpha,
std::span< const int > items = {} )
static

||op(A) X - alpha B0||_F / (||A||_F ||X||_F + |alpha| ||B0||_F) (Side::Right: X op(A)); only the uplo triangle of A is read, its diagonal only for Diag::NonUnit.

◆ spmm_backward_error()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::spmm_backward_error ( Queue & ctx,
const MatrixView< T, MatrixFormat::CSR > & A,
Transpose ta,
const MatrixView< T, MType > & B,
Transpose tb,
const MatrixView< T, MType > & C0,
const MatrixView< T, MType > & C,
promoted_type alpha,
promoted_type beta,
std::span< const int > items = {} )
static

gemm_backward_error() with a CSR A; an out-of-range column index makes the result NaN.

◆ rank2k_backward_error()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::rank2k_backward_error ( Queue & ctx,
const MatrixView< T, MType > & A,
const MatrixView< T, MType > & B,
Transpose trans,
const MatrixView< T, MType > & C0,
const MatrixView< T, MType > & C,
Uplo uplo,
promoted_type alpha,
promoted_type beta,
bool hermitian,
std::span< const int > items = {} )
static

Componentwise backward error of a rank-2k update over the uplo triangle of C: her2k (hermitian, real beta, C0's diagonal read as real) or syr2k.

◆ orthogonality()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::orthogonality ( Queue & ctx,
const MatrixView< T, MType > & Q,
std::span< const int > items = {} )
static

||Q^H Q - I||_F over Q's columns.

◆ eigen_residual()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::eigen_residual ( Queue & ctx,
const MatrixView< T, MType > & A,
const MatrixView< T, MType > & V,
const VectorView< float_t< T > > & w,
std::span< const int > items = {} )
static

||A V - V diag(w)||_F / ||A||_F; A Hermitian, read from its lower triangle.

◆ values_error()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::values_error ( const VectorView< float_t< T > > & w,
const std::vector< std::vector< double > > & ref,
double scale,
std::span< const int > items = {} )
static

max |w - ref| / scale per item; ref[item] holds w.size() values in the caller's order.

◆ pivot_ratio()

template<typename T, MatrixFormat MType>
double batchlas::MatrixView< T, MType >::pivot_ratio ( const MatrixView< T, MType > & F,
std::span< const int > items = {} )
static

max cabs1(L(i,k) U(k,k)) / cabs1(U(k,k)) over a getrf factor: at most 1, up to rounding, for cabs1 partial pivoting (a residual cannot see the pivot rule).

◆ pivots_valid()

template<typename T, MatrixFormat MType>
bool batchlas::MatrixView< T, MType >::pivots_valid ( const VectorView< std::int32_t > & piv,
int n )
static

True when every pivot of every item lies in [1, n].

◆ ld()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
int batchlas::MatrixView< T, MType >::ld ( ) const
inline

Leading dimension: element distance between columns.

Definition at line 818 of file matrix.hh.

◆ stride()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
int batchlas::MatrixView< T, MType >::stride ( ) const
inline

Batch stride: element distance between items.

Definition at line 823 of file matrix.hh.

◆ inc()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
int batchlas::MatrixView< T, MType >::inc ( ) const
inline

Always 1: the element distance down a column.

Definition at line 828 of file matrix.hh.

◆ row_offsets()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
Span< int > batchlas::MatrixView< T, MType >::row_offsets ( ) const
inline

Zero-based row offsets, offset_stride() per item.

Definition at line 833 of file matrix.hh.

◆ col_indices()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
Span< int > batchlas::MatrixView< T, MType >::col_indices ( ) const
inline

Column indices, matrix_stride() per item.

Definition at line 838 of file matrix.hh.

◆ nnz() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
int batchlas::MatrixView< T, MType >::nnz ( ) const
inline

Per-item non-zero capacity, not a count; see Matrix::nnz().

Definition at line 843 of file matrix.hh.

◆ nnz_capacity()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
int batchlas::MatrixView< T, MType >::nnz_capacity ( ) const
inline

Slots allocated per item; see Matrix::nnz_capacity().

Definition at line 848 of file matrix.hh.

◆ nnz() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
int batchlas::MatrixView< T, MType >::nnz ( int batch_index) const
inline

Non-zeros actually stored by item batch_index, read on the host.

Precondition
The row offsets are host-readable: not over sycl::malloc_device memory (use KernelMatrixView::nnz(int) in a kernel instead).

Definition at line 855 of file matrix.hh.

◆ matrix_stride()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
int batchlas::MatrixView< T, MType >::matrix_stride ( ) const
inline

Element distance between items' value (and column-index) arrays.

Definition at line 864 of file matrix.hh.

◆ offset_stride()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
int batchlas::MatrixView< T, MType >::offset_stride ( ) const
inline

Element distance between items' row-offset arrays.

Definition at line 869 of file matrix.hh.

◆ data_ptrs()

template<typename T, MatrixFormat MType>
Span< T * > batchlas::MatrixView< T, MType >::data_ptrs ( Queue & ctx) const
inline

Fills the per-item pointer array from this view's base and stride on ctx and waits.

The array may be shared with the parent Matrix and its other views, so it holds whatever the last view to fill it wrote.

Exceptions
batchlas::invalid_argumentif the view has no pointer array of batch_size() entries

Definition at line 876 of file matrix.hh.

◆ at() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
T & batchlas::MatrixView< T, MType >::at ( int row,
int col,
int batch = 0 )

Host reference to element (row, col) of item batch.

Exceptions
batchlas::out_of_rangeoutside the item's active extents

◆ at() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
const T & batchlas::MatrixView< T, MType >::at ( int row,
int col,
int batch = 0 ) const

Host const reference to element (row, col) of item batch.

Exceptions
batchlas::out_of_rangeoutside the item's active extents

◆ operator()() [1/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
T & batchlas::MatrixView< T, MType >::operator() ( int row,
int col,
int batch = 0 )
inline

at(row, col, batch).

Definition at line 896 of file matrix.hh.

◆ operator()() [2/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
const T & batchlas::MatrixView< T, MType >::operator() ( int row,
int col,
int batch = 0 ) const
inline

at(row, col, batch).

Definition at line 903 of file matrix.hh.

◆ operator()() [3/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
MatrixView< T, MType > batchlas::MatrixView< T, MType >::operator() ( Slice rows,
Slice cols ) const
inline

View of the sub-block rows x cols of every item; keeps ld and stride, never copies.

Exceptions
batchlas::invalid_argumentif either slice is empty; batchlas::out_of_range past a dimension

Definition at line 911 of file matrix.hh.

◆ operator()() [4/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
MatrixView< T, MType > batchlas::MatrixView< T, MType >::operator() ( Slice rows) const
inline

View of rows rows over all columns of every item.

Definition at line 927 of file matrix.hh.

◆ operator()() [5/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
VectorView< T > batchlas::MatrixView< T, MType >::operator() ( int32_t row,
Slice cols ) const
inline

Part of row row of every item as a batched VectorView (inc = ld(), stride = stride()).

Exceptions
batchlas::invalid_argumentif the slice is empty; batchlas::out_of_range past a dimension

Definition at line 935 of file matrix.hh.

◆ operator()() [6/6]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
VectorView< T > batchlas::MatrixView< T, MType >::operator() ( Slice rows,
int32_t col ) const
inline

Part of column col of every item as a batched VectorView (inc = 1, stride = stride()).

Exceptions
batchlas::invalid_argumentif the slice is empty; batchlas::out_of_range past a dimension

Definition at line 948 of file matrix.hh.

◆ symmetrize() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::symmetrize ( const Queue & ctx,
Uplo uplo ) const

Copies the uplo triangle onto the other: a_ji := a_ij for (i, j) in uplo.

Precondition
rows() == cols()

◆ symmetrize() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::symmetrize ( Uplo uplo) const
inline

symmetrize() on a new default queue.

Definition at line 972 of file matrix.hh.

◆ hermitize() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::hermitize ( const Queue & ctx,
Uplo uplo ) const

Mirrors the uplo triangle conjugated (a_ji := conj(a_ij)) and makes the diagonal real.

Precondition
rows() == cols()

◆ hermitize() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::hermitize ( Uplo uplo) const
inline

hermitize() on a new default queue.

Definition at line 985 of file matrix.hh.

◆ transpose() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::transpose ( const Queue & ctx,
bool conjugate = false ) const

In-place (conjugate) transpose.

Note
Declared but not defined by the library: a call fails to link.

◆ transpose() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::transpose ( bool conjugate = false) const
inline

transpose() on a new default queue; likewise undefined.

Definition at line 998 of file matrix.hh.

◆ triangularize() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::triangularize ( const Queue & ctx,
Uplo uplo,
Diag diag ) const

Zeros the strict triangle opposite uplo, keeping the uplo triangle; with Diag::Unit also sets the diagonal to 1.

Uplo::Upper leaves an upper-triangular matrix. Honours rows() != cols().

◆ triangularize() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::triangularize ( Uplo uplo,
Diag diag ) const
inline

triangularize() on a new default queue.

Definition at line 1013 of file matrix.hh.

◆ fill_random() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random ( const Queue & ctx,
bool hermitian = false,
unsigned int seed = 42 ) const

Fills with values uniform in [-1, 1], deterministic in seed; see Matrix::Random().

Note
Writes every element of data(), padding between columns and items included.
Exceptions
batchlas::invalid_argumentif hermitian and rows() != cols()

◆ fill_random() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random ( bool hermitian = false,
unsigned int seed = 42 ) const
inline

fill_random() on a new default queue.

Definition at line 1027 of file matrix.hh.

◆ fill_random_sparse_hermitian() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_sparse_hermitian ( const Queue & ctx,
float density,
unsigned int seed = 42,
typename base_type< T >::type diagonal_boost = typename base_type< T >::type(1),
bool shared_pattern = true ) const

CSR: fills this storage with a random diagonally dominant Hermitian pattern and values.

See csr_generators::random_sparse_hermitian_csr() for the construction. Blocks on ctx while building the pattern; the returned Event is the value fill.

Exceptions
batchlas::invalid_argumentunless the view is square, non-empty, and its nnz() equals the count density implies

◆ fill_random_sparse_hermitian() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires CsrMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_sparse_hermitian ( float density,
unsigned int seed = 42,
typename base_type< T >::type diagonal_boost = typename base_type<T>::type(1),
bool shared_pattern = true ) const
inline

fill_random_sparse_hermitian() on a new default queue.

Definition at line 1048 of file matrix.hh.

◆ fill() [1/2]

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::fill ( const Queue & ctx,
T value ) const

Sets every element of every item (dense: within rows() x cols(); CSR: every stored value).

◆ fill() [2/2]

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::fill ( T value) const
inline

fill() on a new default queue.

Definition at line 1059 of file matrix.hh.

◆ fill_zeros()

template<typename T, MatrixFormat MType>
Event batchlas::MatrixView< T, MType >::fill_zeros ( const Queue & ctx) const
inline

fill() with zero. Deliberately has no queue-less form, which would run on the default device.

Definition at line 1064 of file matrix.hh.

◆ fill_identity()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_identity ( const Queue & ctx,
T value = T(1) ) const

Zeros every item, then sets its main diagonal to value.

◆ fill_diagonal() [1/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_diagonal ( const Queue & ctx,
const Span< T > & diag_values,
int64_t k = 0 ) const

Writes diagonal k (k > 0 above the main diagonal, k < 0 below).

The diagonal has d = max(0, min(rows() - max(-k, 0), cols() - max(k, 0))) entries. diag_values holds either d values used for every item, or d * batch_size() values, one run per item. Other entries are untouched; d = 0 writes nothing.

◆ fill_diagonal() [2/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_diagonal ( const Queue & ctx,
const VectorView< T > & diag_values,
int64_t k = 0 ) const

Writes diagonal k from a VectorView: per item when its batch size equals batch_size(), otherwise its item 0 for every item.

Precondition
diag_values.size() >= d, d as in the Span overload

◆ fill_diagonal() [3/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_diagonal ( const Span< T > & diag_values,
int64_t k = 0 ) const
inline

fill_diagonal() on a new default queue.

Definition at line 1092 of file matrix.hh.

◆ fill_diagonal() [4/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_diagonal ( const Queue & ctx,
const T & value ) const

Sets the main diagonal of every item to value.

◆ fill_diagonal() [5/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_diagonal ( const T & value) const
inline

fill_diagonal() on a new default queue.

Definition at line 1104 of file matrix.hh.

◆ fill_triangular() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_triangular ( const Queue & ctx,
Uplo uplo,
T diagonal_value = T(1),
T non_diagonal_value = T(0.5) ) const

Writes a full triangular matrix: diagonal_value on the diagonal, non_diagonal_value in the uplo strict triangle, zero elsewhere.

◆ fill_triangular() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_triangular ( Uplo uplo,
T diagonal_value = T(1),
T non_diagonal_value = T(0.5) ) const
inline

fill_triangular() on a new default queue.

Definition at line 1118 of file matrix.hh.

◆ fill_tridiag()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_tridiag ( const Queue & ctx,
VectorView< T > sub_diag,
VectorView< T > diag,
VectorView< T > super_diag ) const
inline

Writes the three diagonals from per-item vectors; other entries are untouched.

Definition at line 1126 of file matrix.hh.

◆ fill_tridiag_toeplitz() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_tridiag_toeplitz ( const Queue & ctx,
T diag = T(1),
T sub_diag = T(-0.5),
T super_diag = T(0.5) ) const

Writes a full tridiagonal Toeplitz matrix (zero off the three diagonals).

Precondition
The view is packed: ld() == rows() == cols(), stride() == rows() * cols()

◆ fill_tridiag_toeplitz() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_tridiag_toeplitz ( T diag = T(1),
T sub_diag = T(-0.5),
T super_diag = T(0.5) ) const
inline

fill_tridiag_toeplitz() on a new default queue.

Definition at line 1145 of file matrix.hh.

◆ fill_triangular_random() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_triangular_random ( const Queue & ctx,
Uplo uplo,
Diag diag = Diag::Unit,
unsigned int seed = 42 ) const

Writes a full random triangular matrix: uniform [-1, 1] in the uplo triangle, 1 on the diagonal for Diag::Unit, zero elsewhere.

Note
Every item receives the same matrix (the values depend on seed and the position only).
Precondition
The view is packed: ld() == rows() == cols(), stride() == rows() * cols()

◆ fill_triangular_random() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_triangular_random ( Uplo uplo,
Diag diag = Diag::Unit,
unsigned int seed = 42 ) const
inline

fill_triangular_random() on a new default queue.

Definition at line 1163 of file matrix.hh.

◆ fill_random_spd() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_spd ( const Queue & ctx,
unsigned int seed = 42 ) const

Random Hermitian (real T: symmetric) positive definite matrix, a different one per item.

The Hermitian fill_random() values with the shift n (2n for complex T, whose entries reach modulus sqrt(2)) added to the real diagonal: every row is strictly diagonally dominant with a positive diagonal. a_ij == conj(a_ji) holds bitwise. Deterministic in seed, independent of ld() and stride(); writes only the rows() x cols() entries.

Exceptions
batchlas::invalid_argumentif rows() != cols()

◆ fill_random_spd() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_spd ( unsigned int seed = 42) const
inline

fill_random_spd() on a new default queue.

Definition at line 1183 of file matrix.hh.

◆ fill_random_pivoted() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_pivoted ( const Queue & ctx,
unsigned int seed = 42 ) const

Row-permuted diagonally dominant random matrix, so LU partial pivoting is not the identity.

Item b is P_b D_b: D_b holds uniform [-1, 1) entries plus the fill_random_spd() shift on the diagonal, and P_b is a seeded random n-cycle (no row stays in place for n >= 2), a different one per item. Each column's dominant entry therefore sits in a distinct row. Deterministic in seed; writes only the rows() x cols() entries.

Exceptions
batchlas::invalid_argumentif rows() != cols(), or if n ints exceed the device's local memory

◆ fill_random_pivoted() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_random_pivoted ( unsigned int seed = 42) const
inline

fill_random_pivoted() on a new default queue.

Definition at line 1201 of file matrix.hh.

◆ fill_graded_hermitian() [1/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_graded_hermitian ( const Queue & ctx,
double log10_cond,
unsigned int seed = 42 ) const

Hermitian Q diag(lambda) Q^H with condition number 10^log10_cond, a different Q per item.

lambda_i = 10^(-log10_cond * i / (n - 1)) for i = 0..n-1 (1 when n == 1). Q is the product of n Householder reflectors I - 2 v v^H of seeded random unit vectors (real for real T), applied in T's precision. The result is exactly Hermitian with a real diagonal. Deterministic in seed; writes only the rows() x cols() entries.

Exceptions
batchlas::invalid_argumentif rows() != cols(), if log10_cond is not finite, or if 2n elements of T exceed the device's local memory

◆ fill_graded_hermitian() [2/2]

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_graded_hermitian ( double log10_cond,
unsigned int seed = 42 ) const
inline

fill_graded_hermitian() on a new default queue.

Definition at line 1220 of file matrix.hh.

◆ fill_near_degenerate_hermitian()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
Event batchlas::MatrixView< T, MType >::fill_near_degenerate_hermitian ( const Queue & ctx,
double noise,
unsigned int seed = 42 ) const

Clustered-spectrum Hermitian matrix: diagonal floor(i / 4) + (i % 4) 1e-4 plus noise times a seeded Hermitian perturbation.

Off-diagonal a_ij = noise * z_ij (i > j, z uniform [-1, 1), both parts for complex T) and a_ji = conj(a_ij) bitwise; the diagonal adds noise * Re(z_ii). Groups of four nearly equal eigenvalues exercise deflation and tie-breaking. Deterministic in seed (Philox, the same on every compiler), independent of ld() and stride(); writes only the rows() x cols() entries.

Exceptions
batchlas::invalid_argumentif rows() != cols()

◆ batch_item()

template<typename T, MatrixFormat MType>
MatrixView< T, MType > batchlas::MatrixView< T, MType >::batch_item ( int batch_index) const

A batch-size-1 view of item batch_index.

Dense: its active extents, the parent's ld, no pointer array. CSR: the parent's strides.

Exceptions
batchlas::out_of_rangeif batch_index is outside [0, batch_size())

◆ with_active_dims()

template<typename T, MatrixFormat MType>
template<MatrixFormat M = MType>
requires DenseMatrixFormat<M>
MatrixView< T, MType > batchlas::MatrixView< T, MType >::with_active_dims ( Span< int > active_rows,
Span< int > active_cols ) const
inline

A copy of this view with per-item active extents attached (not copied: the spans must outlive the view).

Exceptions
batchlas::invalid_argumentunder the same rules as Matrix::set_active_dims()

Definition at line 1248 of file matrix.hh.

◆ all_close()

template<typename T, MatrixFormat MType>
bool batchlas::MatrixView< T, MType >::all_close ( Queue & ctx,
const MatrixView< T, MType > & a,
const MatrixView< T, MType > & b,
float_t< T > tol = std::numeric_limits< float_t< T > >::epsilon() )
static

True when every element of a and b agrees to relative tolerance tol; waits on ctx.

Elements agree when |x - y| / max(|x|, |y|) <= tol (the denominator is 1 when the larger magnitude is below tol, and two values both below epsilon agree); complex compares the real and imaginary parts separately. Dense only.

Exceptions
batchlas::invalid_argumentif the shapes or batch sizes differ
batchlas::unsupportedfor CSR

◆ stream_formatted_to()

template<typename T, MatrixFormat MType>
std::ostream & batchlas::MatrixView< T, MType >::stream_formatted_to ( std::ostream & os,
int max_rows_to_print = 10,
int max_cols_to_print = 10,
int max_elements_to_print_csr = 20 ) const
inline

Prints each item's leading block (dense) or leading entries (CSR) in scientific notation.

Returns
os, with its format flags restored

Definition at line 1267 of file matrix.hh.

◆ print()

template<typename T, MatrixFormat MType>
void batchlas::MatrixView< T, MType >::print ( std::ostream & os = std::cout,
int max_rows_to_print = 10,
int max_cols_to_print = 10,
int max_elements_to_print_csr = 20 ) const
inline

stream_formatted_to() without the return value; reads the data on the host.

Definition at line 1328 of file matrix.hh.

◆ kernel_view()

template<typename T, MatrixFormat MType>
KernelMatrixView< T, MType > batchlas::MatrixView< T, MType >::kernel_view ( ) const
inlinenoexcept

The trivially copyable device-side view, for capture in a kernel.

Definition at line 1333 of file matrix.hh.

◆ init_data_ptr_array()

template<typename T, MatrixFormat MType>
void batchlas::MatrixView< T, MType >::init_data_ptr_array ( Queue & ctx,
Span< T * > target = {} ) const
protected

Variables

◆ rows_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::rows_ = 0

Definition at line 573 of file matrix.hh.

◆ cols_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::cols_ = 0

Definition at line 573 of file matrix.hh.

◆ batch_size_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::batch_size_ = 0

Definition at line 573 of file matrix.hh.

◆ data_

template<typename T, MatrixFormat MType>
Span<T> batchlas::MatrixView< T, MType >::data_
protected

Definition at line 1356 of file matrix.hh.

◆ ld_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::ld_ = 0
protected

Definition at line 1358 of file matrix.hh.

◆ stride_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::stride_ = 0
protected

Definition at line 1359 of file matrix.hh.

◆ active_rows_

template<typename T, MatrixFormat MType>
Span<int> batchlas::MatrixView< T, MType >::active_rows_
protected

Definition at line 1360 of file matrix.hh.

◆ active_cols_

template<typename T, MatrixFormat MType>
Span<int> batchlas::MatrixView< T, MType >::active_cols_
protected

Definition at line 1361 of file matrix.hh.

◆ data_ptrs_

template<typename T, MatrixFormat MType>
Span<T*> batchlas::MatrixView< T, MType >::data_ptrs_
protected

Definition at line 1363 of file matrix.hh.

◆ row_offsets_

template<typename T, MatrixFormat MType>
Span<int> batchlas::MatrixView< T, MType >::row_offsets_
protected

Definition at line 1365 of file matrix.hh.

◆ col_indices_

template<typename T, MatrixFormat MType>
Span<int> batchlas::MatrixView< T, MType >::col_indices_
protected

Definition at line 1366 of file matrix.hh.

◆ nnz_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::nnz_ = 0
protected

Definition at line 1367 of file matrix.hh.

◆ matrix_stride_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::matrix_stride_ = 0
protected

Definition at line 1368 of file matrix.hh.

◆ offset_stride_

template<typename T, MatrixFormat MType>
int batchlas::MatrixView< T, MType >::offset_stride_ = 0
protected

Definition at line 1369 of file matrix.hh.

◆ backend_handle_

template<typename T, MatrixFormat MType>
std::shared_ptr<BackendMatrixHandle<T, MType> > batchlas::MatrixView< T, MType >::backend_handle_
mutableprotected

Definition at line 1372 of file matrix.hh.

Verification

Accuracy checks of a computed result against its inputs (Verification library).

Each reads every operand through ld() and stride(), promotes to double / complex<double>, runs on ctx (an in-order sibling of it when ctx is out of order), waits, and returns the worst value over items (empty: default_items(); no items checked returns 0); a NaN anywhere is the result. Operands are read as stored: apply triangularize(), hermitize() or symmetrize() to a copy first to check against a triangle or a mirrored matrix.

Precondition
every operand is host-readable (unified or host memory) and the work that wrote it has completed: the caller waits on its queue first.
using promoted_type = std::conditional_t<is_std_complex_v<T>, std::complex<double>, double>
 T's promoted type: double, or complex<double> for complex T.
std::vector< int > all_items () const
 Every item index, 0 .. batch_size() - 1.
std::vector< int > default_items () const
 {0, batch_size() / 2, batch_size() - 1}, sorted and de-duplicated ({} for batch 0): what a check reads by default.
template<typename U>
Matrix< U, MType > astype (std::span< const int > items) const
 astype() of items only, packed in that order (item g at g * rows() * cols()).
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
static promoted_type up (U x)
 x as promoted_type.
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
static U make (double re, double im=0.0)
 re + i im rounded to T; the imaginary part is dropped for a real T.
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
static U conj (U x)
 The complex conjugate of x; x itself for a real T.
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
static double cabs1 (U x)
 |re| + |im|, LAPACK's partial-pivoting metric; |x| for a real T.
template<typename U = T>
requires (std::is_floating_point_v<U> || is_std_complex_v<U>)
static bool finite (U x)
 True when every component of x is finite.
static Event product (const Queue &ctx, const MatrixView &A, Transpose ta, const MatrixView &B, Transpose tb, const MatrixView &C)
 C := op(A) op(B) per item: one work-item per element of C, the inner sum in order.
static double potrf_residual (Queue &ctx, const MatrixView &A0, const MatrixView &F, Uplo uplo, std::span< const int > items={})
 ||A0 - L L^H||_F / ||A0||_F (Lower) or ||A0 - U^H U||_F / ||A0||_F (Upper) over the factor's triangle; the other triangle of F is not read.
static double getrf_residual (Queue &ctx, const MatrixView &A0, const MatrixView &F, const VectorView< std::int32_t > &piv, std::span< const int > items={})
 ||P A0 - L U||_F / ||A0||_F for an m x n factor with packed 1-based pivots (min(m, n) per item); an out-of-range pivot makes that item NaN.
static double qr_residual (Queue &ctx, const MatrixView &A0, const MatrixView &F, const VectorView< T > &tau, std::span< const int > items={})
 ||A0 - Q R||_F / ||A0||_F for F in LAPACK geqrf storage and its min(m, n) tau.
static Matrix< promoted_type, MType > form_q (Queue &ctx, const MatrixView &F, const VectorView< T > &tau, int item, int cols)
 The first cols columns of Q = H_0 ... H_{k-1} of item item of a geqrf factor (k = min(m, n)); F's diagonal and upper triangle are not read.
static Matrix< promoted_type, MType > form_q (Queue &ctx, const MatrixView &F, const VectorView< T > &tau, std::span< const int > items, int cols)
 form_q() of each of items (empty: default_items()), packed in that order: item g of the result is the first cols columns of Q of item items[g].
static double qr_reconstruction (Queue &ctx, const MatrixView &A0, const MatrixView &Q, const MatrixView &R, std::span< const int > items={})
 ||A0 - Q triu(R)||_F / ||A0||_F with an explicit m x k Q; the first k rows of R are read on and above the diagonal.
static double similarity_residual (Queue &ctx, const MatrixView &A0, const MatrixView &Q, const MatrixView &B, std::span< const int > items={})
 ||A0 - Q B Q^H||_F / ||A0||_F for square operands of equal order.
static double svd_residual (Queue &ctx, const MatrixView &A0, const MatrixView &U, const VectorView< float_t< T > > &s, const MatrixView &Vh, std::span< const int > items={})
 ||A0 - U diag(s) Vh||_F / ||A0||_F for an m x n A0 over the first k = min(m, n) columns of U, values of s and rows of Vh (thin or full factors).
static double solve_residual (Queue &ctx, const MatrixView &A0, Transpose ta, const MatrixView &X, const MatrixView &B0, std::span< const int > items={}, double full_limit=double(1<< 28))
 ||op(A0) X - B0||_F / (||A0||_F ||X||_F); an empty B0 (rows() == 0) is the identity.
static double solve_residual (Queue &ctx, const MatrixView &A0, const MatrixView &X, const MatrixView &B0, std::span< const int > items={})
 solve_residual() with op(A0) = A0.
static double lu_solve_residual (Queue &ctx, const MatrixView &F, const VectorView< std::int32_t > &piv, Transpose ta, const MatrixView &X, const MatrixView &B0, std::span< const int > items={}, double full_limit=double(1<< 28))
 solve_residual() with A = P L U formed per item from getrf factors F and pivots piv; full_limit as for solve_residual().
static double gemm_backward_error (Queue &ctx, const MatrixView &A, Transpose ta, const MatrixView &B, Transpose tb, const MatrixView &C0, const MatrixView &C, promoted_type alpha, promoted_type beta, std::span< const int > items={}, std::optional< Uplo > c_triangle=std::nullopt)
 Componentwise max |C - (alpha op(A) op(B) + beta C0)| / (|alpha| |op(A)| |op(B)| + |beta| |C0|), over c_triangle of C when given; C0 is not read when beta == 0.
static double gemm_max_denominator (Queue &ctx, const MatrixView &A, Transpose ta, const MatrixView &B, Transpose tb, const MatrixView &C0, promoted_type alpha, promoted_type beta, std::span< const int > items={})
 The largest denominator of gemm_backward_error() over items (empty: A's default_items(), while gemm_backward_error() defaults to C's: pass both the same span when A's batch differs).
static double gemv_backward_error (Queue &ctx, const MatrixView &A, Transpose ta, const VectorView< T > &x, const VectorView< T > &y0, const VectorView< T > &y, promoted_type alpha, promoted_type beta, std::span< const int > items={})
 gemm_backward_error() of y = alpha op(A) x + beta y0.
static double trsm_residual (Queue &ctx, const MatrixView &A, Side side, Uplo uplo, Transpose ta, Diag diag, const MatrixView &X, const MatrixView &B0, promoted_type alpha, std::span< const int > items={})
 ||op(A) X - alpha B0||_F / (||A||_F ||X||_F + |alpha| ||B0||_F) (Side::Right: X op(A)); only the uplo triangle of A is read, its diagonal only for Diag::NonUnit.
static double spmm_backward_error (Queue &ctx, const MatrixView< T, MatrixFormat::CSR > &A, Transpose ta, const MatrixView &B, Transpose tb, const MatrixView &C0, const MatrixView &C, promoted_type alpha, promoted_type beta, std::span< const int > items={})
 gemm_backward_error() with a CSR A; an out-of-range column index makes the result NaN.
static double rank2k_backward_error (Queue &ctx, const MatrixView &A, const MatrixView &B, Transpose trans, const MatrixView &C0, const MatrixView &C, Uplo uplo, promoted_type alpha, promoted_type beta, bool hermitian, std::span< const int > items={})
 Componentwise backward error of a rank-2k update over the uplo triangle of C: her2k (hermitian, real beta, C0's diagonal read as real) or syr2k.
static double orthogonality (Queue &ctx, const MatrixView &Q, std::span< const int > items={})
 ||Q^H Q - I||_F over Q's columns.
static double eigen_residual (Queue &ctx, const MatrixView &A, const MatrixView &V, const VectorView< float_t< T > > &w, std::span< const int > items={})
 ||A V - V diag(w)||_F / ||A||_F; A Hermitian, read from its lower triangle.
static double values_error (const VectorView< float_t< T > > &w, const std::vector< std::vector< double > > &ref, double scale, std::span< const int > items={})
 max |w - ref| / scale per item; ref[item] holds w.size() values in the caller's order.
static double pivot_ratio (const MatrixView &F, std::span< const int > items={})
 max cabs1(L(i,k) U(k,k)) / cabs1(U(k,k)) over a getrf factor: at most 1, up to rounding, for cabs1 partial pivoting (a residual cannot see the pivot rule).
static bool pivots_valid (const VectorView< std::int32_t > &piv, int n)
 True when every pivot of every item lies in [1, n].