EllAlgo 1.6.13
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Matrix Class Reference

Square matrix with flat std::vector<double> storage. More...

#include <ell_matrix.hpp>

Public Member Functions

 Matrix (std::size_t ndim, double init=0.0)
 Construct an ndim × ndim matrix.
 
void clear (double value=0.0)
 Reset all elements to value.
 
doubleoperator() (std::size_t row, std::size_t col)
 Access element (row, col) — mutable.
 
const doubleoperator() (std::size_t row, std::size_t col) const
 Access element (row, col) — const.
 
Matrixoperator*= (double alpha)
 Scale all elements by alpha.
 
Matrix operator* (double alpha) const
 Return a scaled copy.
 
void identity ()
 Set to identity matrix.
 
SliceView diagonal ()
 Mutable view of the diagonal (stride = ndim + 1)
 
SliceView row (std::size_t r)
 Mutable view of row r (contiguous, stride = 1)
 
SliceView column (std::size_t c)
 Mutable view of column c (strided, stride = ndim)
 
double trace () const
 Sum of diagonal elements.
 

Detailed Description

Square matrix with flat std::vector<double> storage.

Provides element access via operator()(row, col) and strided views (row, column, diagonal) via SliceView, which supports assignment from valarray, scalar fill, element access, and implicit valarray conversion — matching the original std::slice_array<double> API.

Constructor & Destructor Documentation

◆ Matrix()

Matrix::Matrix ( std::size_t  ndim,
double  init = 0.0 
)
inlineexplicit

Construct an ndim × ndim matrix.

Parameters
[in]ndimNumber of rows/columns
[in]initFill value (default 0.0)

Member Function Documentation

◆ clear()

void Matrix::clear ( double  value = 0.0)
inline

Reset all elements to value.

◆ column()

SliceView Matrix::column ( std::size_t  c)
inline

Mutable view of column c (strided, stride = ndim)

◆ diagonal()

SliceView Matrix::diagonal ( )
inline

Mutable view of the diagonal (stride = ndim + 1)

◆ identity()

void Matrix::identity ( )
inline

Set to identity matrix.

◆ operator()() [1/2]

double & Matrix::operator() ( std::size_t  row,
std::size_t  col 
)
inline

Access element (row, col) — mutable.

◆ operator()() [2/2]

const double & Matrix::operator() ( std::size_t  row,
std::size_t  col 
) const
inline

Access element (row, col) — const.

◆ operator*()

Matrix Matrix::operator* ( double  alpha) const
inline

Return a scaled copy.

◆ operator*=()

Matrix & Matrix::operator*= ( double  alpha)
inline

Scale all elements by alpha.

◆ row()

SliceView Matrix::row ( std::size_t  r)
inline

Mutable view of row r (contiguous, stride = 1)

◆ trace()

double Matrix::trace ( ) const
inline

Sum of diagonal elements.

\[ \operatorname{tr}(A) = \sum_{i=1}^{n} A_{ii} \]


The documentation for this class was generated from the following file: