CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::coo::XxMatrix< T_Int, T_Scalar > Class Template Reference

The sparse matrix class (coordinate format). More...

Inheritance diagram for cla3p::coo::XxMatrix< T_Int, T_Scalar >:

Constructors

 XxMatrix ()
 Default constructor.
 XxMatrix (T_Int nr, T_Int nc, const Property &pr=Property::General())
 Dimension constructor.
 XxMatrix (const XxMatrix< T_Int, T_Scalar > &other)=default
 Copy constructor.
 XxMatrix (XxMatrix< T_Int, T_Scalar > &&other)=default
 Move constructor.
 ~XxMatrix ()
 Destructor.

Operators

XxMatrix< T_Int, T_Scalar > & operator= (const XxMatrix< T_Int, T_Scalar > &other)=default
 Copy assignment operator.
XxMatrix< T_Int, T_Scalar > & operator= (XxMatrix< T_Int, T_Scalar > &&other)=default
 Move assignment operator.

Arguments

T_Int nnz () const
 Get the number of non-zero elements.

Public Member Functions

void clear ()
 Clear the sparse matrix.
void reserve (T_Int nz)
 Reserve storage for non-zero elements.
void insert (const Tuple< T_Int, T_Scalar > &tuple)
 Insert a non-zero element using a tuple.
void insert (T_Int i, T_Int j, T_Scalar v)
 Insert a non-zero element.
std::string info (const std::string &header="") const
 Get information about the sparse matrix.
void toStream (std::ostream &os, std::streamsize prec=0) const
 Output the sparse matrix to a stream.
csc::XxMatrix< T_Int, T_Scalar > toCsc (dup_t duplicatePolicy=dup_t::Sum) const
 Convert to compressed sparse column (CSC) format.
csr::XxMatrix< T_Int, T_Scalar > toCsr (dup_t duplicatePolicy=dup_t::Sum) const
 Convert to compressed sparse row (CSR) format.

Additional Inherited Members

Public Member Functions inherited from cla3p::MatrixMeta< T_Int >
const Propertyprop () 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.

Detailed Description

template<typename T_Int, typename T_Scalar>
class cla3p::coo::XxMatrix< T_Int, T_Scalar >

The sparse matrix class (coordinate format).

Constructor & Destructor Documentation

◆ XxMatrix() [1/4]

template<typename T_Int, typename T_Scalar>
cla3p::coo::XxMatrix< T_Int, T_Scalar >::XxMatrix ( )

Default constructor.

Creates an empty sparse matrix with no allocated memory.

◆ XxMatrix() [2/4]

template<typename T_Int, typename T_Scalar>
cla3p::coo::XxMatrix< T_Int, T_Scalar >::XxMatrix ( T_Int nr,
T_Int nc,
const Property & pr = Property::General() )
explicit

Dimension constructor.

Creates a sparse matrix of the specified dimensions in coordinate format.

Parameters
[in]nrThe number of rows.
[in]ncThe number of columns.
[in]prThe matrix property (default: General).

◆ XxMatrix() [3/4]

template<typename T_Int, typename T_Scalar>
cla3p::coo::XxMatrix< T_Int, T_Scalar >::XxMatrix ( const XxMatrix< T_Int, T_Scalar > & other)
default

Copy constructor.

Creates a new sparse matrix by copying another sparse matrix.

Parameters
[in]otherThe sparse matrix to copy.

◆ XxMatrix() [4/4]

template<typename T_Int, typename T_Scalar>
cla3p::coo::XxMatrix< T_Int, T_Scalar >::XxMatrix ( XxMatrix< T_Int, T_Scalar > && other)
default

Move constructor.

Creates a new sparse matrix by moving resources from another sparse matrix.

Parameters
[in]otherThe sparse matrix to move from.

◆ ~XxMatrix()

template<typename T_Int, typename T_Scalar>
cla3p::coo::XxMatrix< T_Int, T_Scalar >::~XxMatrix ( )

Destructor.

Destroys the sparse matrix and releases allocated memory.

Member Function Documentation

◆ operator=() [1/2]

template<typename T_Int, typename T_Scalar>
XxMatrix< T_Int, T_Scalar > & cla3p::coo::XxMatrix< T_Int, T_Scalar >::operator= ( const XxMatrix< T_Int, T_Scalar > & other)
default

Copy assignment operator.

Copies the contents of another sparse matrix to this sparse matrix.

Parameters
[in]otherThe sparse matrix to copy.
Returns
Reference to this sparse matrix.

◆ operator=() [2/2]

template<typename T_Int, typename T_Scalar>
XxMatrix< T_Int, T_Scalar > & cla3p::coo::XxMatrix< T_Int, T_Scalar >::operator= ( XxMatrix< T_Int, T_Scalar > && other)
default

Move assignment operator.

Moves resources from another sparse matrix to this sparse matrix.

Parameters
[in]otherThe sparse matrix to move from.
Returns
Reference to this sparse matrix.

◆ nnz()

template<typename T_Int, typename T_Scalar>
T_Int cla3p::coo::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.

Returns
The number of non-zero elements.

◆ clear()

template<typename T_Int, typename T_Scalar>
void cla3p::coo::XxMatrix< T_Int, T_Scalar >::clear ( )

Clear the sparse matrix.

Releases all memory and resets the matrix to an empty state.

◆ reserve()

template<typename T_Int, typename T_Scalar>
void cla3p::coo::XxMatrix< T_Int, T_Scalar >::reserve ( T_Int nz)

Reserve storage for non-zero elements.

Preallocates memory for the specified number of non-zero elements to avoid reallocations.

Parameters
[in]nzThe number of non-zero elements to reserve space for.

◆ insert() [1/2]

template<typename T_Int, typename T_Scalar>
void cla3p::coo::XxMatrix< T_Int, T_Scalar >::insert ( const Tuple< T_Int, T_Scalar > & tuple)

Insert a non-zero element using a tuple.

Inserts a non-zero element specified as a tuple (row, column, value) into the sparse matrix.

Parameters
[in]tupleThe tuple containing the row index, column index, and value.

◆ insert() [2/2]

template<typename T_Int, typename T_Scalar>
void cla3p::coo::XxMatrix< T_Int, T_Scalar >::insert ( T_Int i,
T_Int j,
T_Scalar v )

Insert a non-zero element.

Inserts a non-zero element at the specified row and column with the given value.

Parameters
[in]iThe row index.
[in]jThe column index.
[in]vThe value to insert.

◆ info()

template<typename T_Int, typename T_Scalar>
std::string cla3p::coo::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.

Parameters
[in]headerOptional header string to prepend to the information.
Returns
A string containing matrix information.

◆ toStream()

template<typename T_Int, typename T_Scalar>
void cla3p::coo::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.

Parameters
[in,out]osThe output stream to write to.
[in]precThe output precision (default: 0 for default precision).

◆ toCsc()

template<typename T_Int, typename T_Scalar>
csc::XxMatrix< T_Int, T_Scalar > cla3p::coo::XxMatrix< T_Int, T_Scalar >::toCsc ( dup_t duplicatePolicy = dup_t::Sum) const

Convert to compressed sparse column (CSC) format.

Converts the coordinate format sparse matrix to CSC format.

Parameters
[in]duplicatePolicyThe policy for handling duplicate entries (default: Sum).
Returns
A sparse matrix in CSC format.

◆ toCsr()

template<typename T_Int, typename T_Scalar>
csr::XxMatrix< T_Int, T_Scalar > cla3p::coo::XxMatrix< T_Int, T_Scalar >::toCsr ( dup_t duplicatePolicy = dup_t::Sum) const

Convert to compressed sparse row (CSR) format.

Converts the coordinate format sparse matrix to CSR format.

Parameters
[in]duplicatePolicyThe policy for handling duplicate entries (default: Sum).
Returns
A sparse matrix in CSR format.