![]() |
CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
|
The sparse matrix class (compressed sparse row format). More...

Constructors | |
| XxMatrix () | |
| Default constructor. | |
| XxMatrix (T_Int nr, T_Int nc, T_Int nz, const Property &pr=Property::General()) | |
| Dimension constructor. | |
| XxMatrix (T_Int nr, T_Int nc, T_Int *rptr, T_Int *cidx, T_Scalar *vals, bool bind, const Property &pr=Property::General()) | |
| Auxiliary constructor. | |
| XxMatrix (const XxMatrix< T_Int, T_Scalar > &other) | |
| Copy constructor. | |
| XxMatrix (XxMatrix< T_Int, T_Scalar > &&other) | |
| Move constructor. | |
| ~XxMatrix () | |
| Destructor. | |
Operators | |
| XxMatrix< T_Int, T_Scalar > & | operator= (const XxMatrix< T_Int, T_Scalar > &other) |
| Copy assignment operator. | |
| XxMatrix< T_Int, T_Scalar > & | operator= (XxMatrix< T_Int, T_Scalar > &&other) |
| Move assignment operator. | |
| alias::VirtualScal_csr< T_Int, T_Scalar > | operator- () const |
| Unary negation operator. | |
Arguments | |
| T_Int * | rowptr () |
| Access the row pointer array. | |
| const T_Int * | rowptr () const |
| Access the row pointer array. | |
| T_Int * | colidx () |
| Access the column index array. | |
| const T_Int * | colidx () const |
| Access the column index array. | |
| T_Int | nnz () const |
| Get the number of non-zero elements. | |
Public Member Functions | |
| void | clear () |
| Clear the sparse matrix. | |
| std::string | info (const std::string &header="") const |
| Get information about the sparse matrix. | |
| XxMatrix< T_Int, T_Scalar > | copy () const |
| Create a deep copy of the sparse matrix. | |
| XxMatrix< T_Int, T_Scalar > | rcopy () |
| Create a reference copy (shallow copy) of the sparse matrix. | |
| Guard< XxMatrix< T_Int, T_Scalar > > | rcopy () const |
| Create a guarded reference copy (shallow copy) of the sparse matrix. | |
| XxMatrix< T_Int, T_Scalar > | move () |
| Move the sparse matrix's resources. | |
| void | toStream (std::ostream &os, std::streamsize prec=0) const |
| Output the sparse matrix to a stream. | |
| void | iscale (T_Scalar val) |
| Scale the sparse matrix in-place. | |
| alias::VirtualTrans_csr< T_Int, T_Scalar > | transpose () const |
| Transpose the sparse matrix. | |
| alias::VirtualTrans_csr< T_Int, T_Scalar > | ctranspose () const |
| Conjugate transpose the sparse matrix. | |
| alias::VirtualConj_csr< T_Int, T_Scalar > | conjugate () const |
| Compute the complex conjugate. | |
| void | iconjugate () |
| Conjugate the sparse matrix in-place. | |
| T_RScalar | normOne () const |
| Compute the 1-norm. | |
| T_RScalar | normInf () const |
| Compute the infinity norm. | |
| T_RScalar | normMax () const |
| Compute the maximum norm. | |
| T_RScalar | normFro () const |
| Compute the Frobenius norm. | |
| XxMatrix< T_Int, T_Scalar > | general () const |
| Convert to general sparse matrix. | |
| dns::XxMatrix< T_Scalar > | toDns () const |
| Convert to dense matrix format. | |
| XxMatrix< T_Int, T_Scalar > | permuteLeftRight (const prm::PxMatrix< T_Int > &P, const prm::PxMatrix< T_Int > &Q) const |
| Permute rows and columns. | |
| XxMatrix< T_Int, T_Scalar > | permuteLeft (const prm::PxMatrix< T_Int > &P) const |
| Permute rows. | |
| XxMatrix< T_Int, T_Scalar > | permuteRight (const prm::PxMatrix< T_Int > &Q) const |
| Permute columns. | |
| XxMatrix< T_Int, T_Scalar > | permuteMirror (const prm::PxMatrix< T_Int > &P) const |
| Permute rows and columns symmetrically. | |
| XxMatrix< T_Int, T_Scalar > | block (T_Int ibgn, T_Int jbgn, T_Int ni, T_Int nj) const |
| Extract a block as a new sparse matrix. | |
Creators/Generators | |
| static XxMatrix< T_Int, T_Scalar > | random (T_Int nr, T_Int nc, T_Int nz, const Property &pr=Property::General(), T_RScalar lo=T_RScalar(0), T_RScalar hi=T_RScalar(1)) |
| Create a random sparse matrix. | |
| static Guard< XxMatrix< T_Int, T_Scalar > > | view (T_Int nr, T_Int nc, const T_Int *rptr, const T_Int *cidx, const T_Scalar *vals, const Property &pr=Property::General()) |
| Create a view of existing CSR arrays. | |
Additional Inherited Members | |
| Public Member Functions inherited from cla3p::MatrixMeta< T_Int > | |
| const Property & | prop () const |
| Matrix property accessor. | |
| Public Member Functions inherited from cla3p::Meta2D< T_Int > | |
| virtual T_Int | nrows () const |
| Number of rows. | |
| virtual T_Int | ncols () const |
| Number of columns. | |
| bool | empty () const |
| Tests whether the object has zero dimensions. | |
| operator bool () const | |
| Boolean conversion operator. | |
| Public Member Functions inherited from cla3p::csx::XxContainerBase< T_Int, T_Scalar > | |
| T_Scalar * | values () |
| Access the data buffer. | |
| const T_Scalar * | values () const |
| Access the data buffer. | |
| Public Member Functions inherited from cla3p::Ownership | |
| Ownership () | |
| Default constructor. | |
| Ownership (bool owner) | |
| Ownership constructor. | |
| ~Ownership () | |
| Destructor. | |
| bool | owner () const |
| Tests memory ownership. | |
| void | unbind () |
| Relinquishes memory ownership. | |
The sparse matrix class (compressed sparse row format).
| cla3p::csr::XxMatrix< T_Int, T_Scalar >::XxMatrix | ( | ) |
Default constructor.
Creates an empty sparse matrix with no allocated memory.
|
explicit |
Dimension constructor.
Creates a sparse matrix of the specified dimensions in CSR format and allocates memory.
| [in] | nr | The number of rows. |
| [in] | nc | The number of columns. |
| [in] | nz | The number of non-zero elements. |
| [in] | pr | The matrix property (default: General). |
|
explicit |
Auxiliary constructor.
Creates a sparse matrix using existing CSR format arrays.
| [in] | nr | The number of rows. |
| [in] | nc | The number of columns. |
| [in] | rptr | Pointer to existing row pointer array. |
| [in] | cidx | Pointer to existing column index array. |
| [in] | vals | Pointer to existing values array. |
| [in] | bind | If true, the matrix takes ownership of the memory. |
| [in] | pr | The matrix property (default: General). |
| cla3p::csr::XxMatrix< T_Int, T_Scalar >::XxMatrix | ( | const XxMatrix< T_Int, T_Scalar > & | other | ) |
Copy constructor.
Creates a new sparse matrix by copying another sparse matrix.
| [in] | other | The sparse matrix to copy. |
| cla3p::csr::XxMatrix< T_Int, T_Scalar >::XxMatrix | ( | XxMatrix< T_Int, T_Scalar > && | other | ) |
Move constructor.
Creates a new sparse matrix by moving resources from another sparse matrix.
| [in] | other | The sparse matrix to move from. |
| cla3p::csr::XxMatrix< T_Int, T_Scalar >::~XxMatrix | ( | ) |
Destructor.
Destroys the sparse matrix and releases allocated memory.
| XxMatrix< T_Int, T_Scalar > & cla3p::csr::XxMatrix< T_Int, T_Scalar >::operator= | ( | const XxMatrix< T_Int, T_Scalar > & | other | ) |
Copy assignment operator.
Copies the contents of another sparse matrix to this sparse matrix.
| [in] | other | The sparse matrix to copy. |
| XxMatrix< T_Int, T_Scalar > & cla3p::csr::XxMatrix< T_Int, T_Scalar >::operator= | ( | XxMatrix< T_Int, T_Scalar > && | other | ) |
Move assignment operator.
Moves resources from another sparse matrix to this sparse matrix.
| [in] | other | The sparse matrix to move from. |
| alias::VirtualScal_csr< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::operator- | ( | ) | const |
Unary negation operator.
Returns a negated copy of the sparse matrix.
| T_Int * cla3p::csr::XxMatrix< T_Int, T_Scalar >::rowptr | ( | ) |
Access the row pointer array.
Returns a pointer to the row pointer array (CSR format).
| const T_Int * cla3p::csr::XxMatrix< T_Int, T_Scalar >::rowptr | ( | ) | const |
Access the row pointer array.
Returns a pointer to the row pointer array (CSR format).
| T_Int * cla3p::csr::XxMatrix< T_Int, T_Scalar >::colidx | ( | ) |
Access the column index array.
Returns a pointer to the column index array (CSR format).
| const T_Int * cla3p::csr::XxMatrix< T_Int, T_Scalar >::colidx | ( | ) | const |
Access the column index array.
Returns a pointer to the column index array (CSR format).
| T_Int cla3p::csr::XxMatrix< T_Int, T_Scalar >::nnz | ( | ) | const |
Get the number of non-zero elements.
Returns the number of stored non-zero elements in the sparse matrix.
| void cla3p::csr::XxMatrix< T_Int, T_Scalar >::clear | ( | ) |
Clear the sparse matrix.
Releases all memory and resets the matrix to an empty state.
| std::string cla3p::csr::XxMatrix< T_Int, T_Scalar >::info | ( | const std::string & | header = "" | ) | const |
Get information about the sparse matrix.
Returns a string containing information about the matrix's dimensions, non-zeros, and properties.
| [in] | header | Optional header string to prepend to the information. |
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::copy | ( | ) | const |
Create a deep copy of the sparse matrix.
Creates a new sparse matrix with its own memory allocation and copies all elements from this matrix to the new matrix.
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::rcopy | ( | ) |
Create a reference copy (shallow copy) of the sparse matrix.
Creates a new sparse matrix object that references the same memory as this matrix. Changes to either matrix will affect both.
| Guard< XxMatrix< T_Int, T_Scalar > > cla3p::csr::XxMatrix< T_Int, T_Scalar >::rcopy | ( | ) | const |
Create a guarded reference copy (shallow copy) of the sparse matrix.
Creates a guarded sparse matrix object that references the same memory as this matrix. The guard ensures the reference is read-only.
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::move | ( | ) |
Move the sparse matrix's resources.
Transfers ownership of the memory to a new sparse matrix object, leaving this matrix in an empty state.
| void cla3p::csr::XxMatrix< T_Int, T_Scalar >::toStream | ( | std::ostream & | os, |
| std::streamsize | prec = 0 ) const |
Output the sparse matrix to a stream.
Writes the sparse matrix elements to the specified output stream with specified precision.
| [in,out] | os | The output stream to write to. |
| [in] | prec | The output precision (default: 0 for default precision). |
| void cla3p::csr::XxMatrix< T_Int, T_Scalar >::iscale | ( | T_Scalar | val | ) |
Scale the sparse matrix in-place.
Multiplies all non-zero elements of the sparse matrix by a scalar value.
| [in] | val | The scalar value to multiply by. |
| alias::VirtualTrans_csr< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::transpose | ( | ) | const |
Transpose the sparse matrix.
Returns a transposed view of the sparse matrix.
| alias::VirtualTrans_csr< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::ctranspose | ( | ) | const |
Conjugate transpose the sparse matrix.
Returns a conjugate transposed view of the sparse matrix.
| alias::VirtualConj_csr< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::conjugate | ( | ) | const |
Compute the complex conjugate.
Returns a virtual expression containing the complex conjugate of each non-zero element.
| void cla3p::csr::XxMatrix< T_Int, T_Scalar >::iconjugate | ( | ) |
Conjugate the sparse matrix in-place.
Replaces all non-zero elements with their complex conjugates.
| T_RScalar cla3p::csr::XxMatrix< T_Int, T_Scalar >::normOne | ( | ) | const |
Compute the 1-norm.
Computes the maximum absolute column sum.
| T_RScalar cla3p::csr::XxMatrix< T_Int, T_Scalar >::normInf | ( | ) | const |
Compute the infinity norm.
Computes the maximum absolute row sum.
| T_RScalar cla3p::csr::XxMatrix< T_Int, T_Scalar >::normMax | ( | ) | const |
Compute the maximum norm.
Computes the maximum absolute value of all non-zero elements.
| T_RScalar cla3p::csr::XxMatrix< T_Int, T_Scalar >::normFro | ( | ) | const |
Compute the Frobenius norm.
Computes the square root of the sum of squared absolute values of all non-zero elements.
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::general | ( | ) | const |
Convert to general sparse matrix.
Creates a new general sparse matrix by copying all relevant elements from a structured sparse matrix.
| dns::XxMatrix< T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::toDns | ( | ) | const |
Convert to dense matrix format.
Converts the sparse matrix to a dense matrix by expanding all elements.
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::permuteLeftRight | ( | const prm::PxMatrix< T_Int > & | P, |
| const prm::PxMatrix< T_Int > & | Q ) const |
Permute rows and columns.
Applies left and right permutations to the sparse matrix.
| [in] | P | The row permutation matrix. |
| [in] | Q | The column permutation matrix. |
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::permuteLeft | ( | const prm::PxMatrix< T_Int > & | P | ) | const |
Permute rows.
Applies a left (row) permutation to the sparse matrix.
| [in] | P | The row permutation matrix. |
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::permuteRight | ( | const prm::PxMatrix< T_Int > & | Q | ) | const |
Permute columns.
Applies a right (column) permutation to the sparse matrix.
| [in] | Q | The column permutation matrix. |
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::permuteMirror | ( | const prm::PxMatrix< T_Int > & | P | ) | const |
Permute rows and columns symmetrically.
Applies the same permutation to both rows and columns (mirror permutation).
| [in] | P | The permutation matrix to apply to both rows and columns. |
| XxMatrix< T_Int, T_Scalar > cla3p::csr::XxMatrix< T_Int, T_Scalar >::block | ( | T_Int | ibgn, |
| T_Int | jbgn, | ||
| T_Int | ni, | ||
| T_Int | nj ) const |
Extract a block as a new sparse matrix.
Creates a new sparse matrix containing a copy of a contiguous block of elements.
| [in] | ibgn | The starting row index of the block. |
| [in] | jbgn | The starting column index of the block. |
| [in] | ni | The number of rows in the block. |
| [in] | nj | The number of columns in the block. |
|
static |
Create a random sparse matrix.
Creates a sparse matrix with random non-zero values uniformly distributed in the specified range.
| [in] | nr | The number of rows. |
| [in] | nc | The number of columns. |
| [in] | nz | The number of non-zero elements. |
| [in] | pr | The matrix property (default: General). |
| [in] | lo | The lower bound of the random values (default: 0). |
| [in] | hi | The upper bound of the random values (default: 1). |
|
static |
Create a view of existing CSR arrays.
Creates a guarded sparse matrix that references existing CSR format memory without taking ownership. The memory must remain valid for the lifetime of the returned view.
| [in] | nr | The number of rows. |
| [in] | nc | The number of columns. |
| [in] | rptr | Pointer to the row pointer array. |
| [in] | cidx | Pointer to the column index array. |
| [in] | vals | Pointer to the values array. |
| [in] | pr | The matrix property (default: General). |