36 #include "Triplet.hpp"
37 #include "SparseMatrix.hpp"
48 template<
typename T,
typename SparseMatrixType,
typename IND >
66 typename std::vector< Triplet< T > >::iterator it = input.begin();
67 for( ; it != input.end(); ++it )
81 ds =
new SparseMatrixType( nnz, noc, nor, zero );
86 load( input, m, n, zero );
91 if (
ds != NULL )
delete ds;
97 ds =
new SparseMatrixType( input, n, m, zero );
101 virtual void loadFromFile(
const std::string file,
const T zero = 0 ) {
104 load( VT, m, n, zero );
108 virtual ULI
m() {
return ds->n(); }
111 virtual ULI
n() {
return ds->m(); }
114 virtual ULI
nzs() {
return ds->nzs(); }
120 virtual T*
mv(
const T* x ) {
121 T *
const ret =
new T[
m() ];
122 for(
unsigned long int i = 0; i <
m(); i ++ ) ret[ i ] =
ds->zero_element;
128 virtual void zax(
const T*__restrict__ x, T*__restrict__ z ) {
133 virtual void zxa(
const T*__restrict__ x, T*__restrict__ z ) {
139 return ds->bytesUsed();
IND nnz
Number of non-zeros.
Definition: SparseMatrix.hpp:58
static std::vector< Triplet< double > > parse(std::string filename)
Parses a matrix-market input file.
Definition: FileToVT.cpp:36
Automatically transforms a row-major scheme into an column-major scheme.
Definition: CCSWrapper.hpp:49
CCSWrapper()
Default constructor (initialises with invalid data).
Definition: CCSWrapper.hpp:74
virtual ULI n()
Returns the number of matrix columns (taking into account transposition).
Definition: CCSWrapper.hpp:111
CCSWrapper(std::string file, T zero=0)
Base file-based constructor.
Definition: CCSWrapper.hpp:77
virtual size_t bytesUsed()
Definition: CCSWrapper.hpp:138
virtual T * mv(const T *x)
Definition: CCSWrapper.hpp:120
virtual ~CCSWrapper()
Base destructor.
Definition: CCSWrapper.hpp:90
Interface common to all sparse matrix storage schemes.
Definition: SparseMatrix.hpp:46
SparseMatrixType * ds
Pointer to the underlying data structure.
Definition: CCSWrapper.hpp:55
virtual void zxa(const T *__restrict__ x, T *__restrict__ z)
Definition: CCSWrapper.hpp:133
IND noc
Number of columns.
Definition: SparseMatrix.hpp:55
virtual void load(std::vector< Triplet< T > > &input, IND m, IND n, T zero)
Triplet-based loader; first transposes, then calls nested constructor.
Definition: CCSWrapper.hpp:95
virtual ULI m()
Returns the number of matrix rows (taking into account transposition).
Definition: CCSWrapper.hpp:108
virtual void zax(const T *__restrict__ x, T *__restrict__ z)
Definition: CCSWrapper.hpp:128
virtual ULI nzs()
Returns the number of nonzeroes.
Definition: CCSWrapper.hpp:114
CCSWrapper(const IND nnz, const IND nor, const IND noc, T zero)
Base empty matrix constructor (sets nnz, rows, columns only).
Definition: CCSWrapper.hpp:80
IND nor
Number of rows.
Definition: SparseMatrix.hpp:52
void transposeVector(std::vector< Triplet< T > > &input)
Helper function that transposes an input matrix in Triplet format, in-place.
Definition: CCSWrapper.hpp:65
virtual void getFirstIndexPair(IND &row, IND &col)
Definition: CCSWrapper.hpp:117
CCSWrapper(std::vector< Triplet< T > > &input, IND m, IND n, T zero)
Base Triplet-based constructor.
Definition: CCSWrapper.hpp:85
A single triplet value.
Definition: Triplet.hpp:52
virtual void loadFromFile(const std::string file, const T zero=0)
File-based loader; reads file, then passes to Triplet-based loader.
Definition: CCSWrapper.hpp:101