CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
ex06b_sparse_matrix_fill.cpp
#include <iostream>
#include <cla3p/sparse.hpp>
int main()
{
/*
* Reserve space for insertions (optional)
*/
A.reserve(10);
/*
* Insert values in A.
*/
A.insert(0,0,1.0); // insert a '1' in A(0,0)
A.insert(1,1,2.0); // insert a '2' in A(1,1)
A.insert(2,1,3.0); // insert a '3' in A(2,1)
A.insert(1,3,4.0); // insert a '4' in A(1,3)
A.insert(0,0,5.0); // insert a '5' in A(0,0)
std::cout << A.info("A") << A << "\n";
/*
* Create a CSC matrix from the COO matrix.
* (double entries will be added together)
*/
std::cout << B.info("B") << B << "\n";
/*
* Create a CSC matrix from the COO matrix.
* (the absolute maximum of double entries will be kept)
*/
std::cout << C.info("C") << C << "\n";
return 0;
}
csc::XxMatrix< T_Int, T_Scalar > toCsc(dup_t duplicatePolicy=dup_t::Sum) const
Convert to compressed sparse column (CSC) format.
std::string info(const std::string &header="") const
Get information about 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.
std::string info(const std::string &header="") const
Get information about the sparse matrix.
@ Amax
Definition enums.hpp:114
XxMatrix< int_t, real_t > RdMatrix
Double precision real COO (Coordinate) matrix.
Definition sparse.hpp:111
XxMatrix< int_t, real_t > RdMatrix
Double precision real CSC (Compressed Sparse Column) matrix.
Definition sparse.hpp:73