35 #include "SparseMatrix.hpp"
36 #include "HilbertTriplet.hpp"
37 #include "HilbertTripletCompare.hpp"
38 #include "Triplet.hpp"
43 #define _HILBERT_COMPRESSED_BICRS
49 #ifdef _HILBERT_COMPRESSED_BICRS
58 template<
typename T >
69 std::vector< HilbertTriplet< T > >
ds;
76 #ifdef _HILBERT_COMPRESSED_BICRS
115 load( input, m, n, zero );
123 this->
nnz = input.size();
124 for( ULI i=0; i<this->
nnz; i++ ) {
126 ds[ i ].calculateHilbertCoordinate();
129 std::sort(
ds.begin(),
ds.end(), compare );
131 for( ULI i=0; i<this->
nnz; i++ )
132 std::cout <<
ds[i].getMostSignificantHilbertBits() <<
" " <<
ds[i].getLeastSignificantHilbertBits() << std::endl;
135 std::vector< Triplet< T > > tds;
136 typename std::vector< HilbertTriplet< T > >::iterator it =
ds.begin();
137 for( ; it!=
ds.end(); ++it )
138 tds.push_back(
Triplet< T >( it->i(), it->j(), it->value ) );
156 virtual void zxa(
const T* x, T* z ) {
167 virtual void zax(
const T* x, T* z ) {
173 return ads->bytesUsed();
186 std::cerr <<
"Warning: assuming binary file was saved by a HTS scheme, i.e., that it is pre-ordered using Hilbert coordinates." << std::endl;
ULI nnz
Number of non-zeros.
Definition: SparseMatrix.hpp:58
static std::vector< Triplet< T > > load(const std::string fn, ULI &m, ULI &n)
Loads an array of triplets from a binary file.
Definition: Triplet.hpp:123
virtual void zxa(const T *x, T *z)
Calculates z=xA.
Definition: Hilbert.hpp:156
Hilbert-coordinate-aware triplet.
Definition: HilbertTriplet.hpp:46
void saveBinary(const std::string fn)
Saves the current Hilbert structure in binary triplet form.
Definition: Hilbert.hpp:180
Bi-directional Incremental Compressed Row Storage scheme.
Definition: BICRS.hpp:58
virtual unsigned long int m()
Queries the number of rows this matrix contains.
Definition: SparseMatrix.hpp:107
virtual void load(std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero)
Definition: Hilbert.hpp:119
Class-comparator of HilbertTriplet.
Definition: HilbertTripletCompare.hpp:41
The Hilbert scheme backed by (C)BICRS.
Definition: Hilbert.hpp:59
static Matrix< T > * getDataStructure(std::vector< Triplet< T > > &tds, const ULI m, const ULI n, T zero)
Gets the data structure.
Definition: Hilbert.hpp:75
static Matrix< _t_value > * getCBICRS(std::string file, _t_value zero=0)
Factory function for row-based compressed BICRS functions, file-based.
Definition: CBICRS.hpp:842
static void save(std::string fn, HilbertTriplet< T > *toWrite, const unsigned long int m, const unsigned long int n, const size_t s)
Saves an array of Hilbert triplets to a file, in binary format.
Definition: HilbertTriplet.hpp:121
virtual void zax(const T *x, T *z)
Calculates z=Ax.
Definition: Hilbert.hpp:167
void loadFromFile(const std::string file, const T zero=0)
Function which loads a matrix from a matrix market file.
Definition: SparseMatrix.hpp:89
std::vector< HilbertTriplet< T > > ds
Vector storing the non-zeros and their locations.
Definition: Hilbert.hpp:69
Interface common to all sparse matrix storage schemes.
Definition: SparseMatrix.hpp:46
virtual size_t bytesUsed()
Gets the number of bytes used by this storage scheme.
Definition: Hilbert.hpp:172
ULI noc
Number of columns.
Definition: SparseMatrix.hpp:55
Hilbert(std::vector< Triplet< T > > &input, ULI m, ULI n, T zero)
Base constructor.
Definition: Hilbert.hpp:113
Matrix< T > * ads
Actual data structure.
Definition: Hilbert.hpp:72
Defines operations common to all matrices, which are implemented in this library. ...
Definition: Matrix.hpp:70
Hilbert(std::string file, T zero=0)
Base constructor.
Definition: Hilbert.hpp:100
void loadBinary(const std::string fn)
Loads from binary triplets, assumes Hilbert ordering already done.
Definition: Hilbert.hpp:185
ULI nor
Number of rows.
Definition: SparseMatrix.hpp:52
T zero_element
The element considered to be zero.
Definition: SparseMatrix.hpp:63
virtual ~Hilbert()
Base deconstructor.
Definition: Hilbert.hpp:86
virtual unsigned long int n()
Queries the number of columns this matrix contains.
Definition: SparseMatrix.hpp:115
A single triplet value.
Definition: Triplet.hpp:52
Hilbert()
Base constructor.
Definition: Hilbert.hpp:92
virtual void getFirstIndexPair(ULI &row, ULI &col)
Returns the first nonzero index, per reference.
Definition: Hilbert.hpp:144
ULI minexp
Minimum number of expansions.
Definition: Hilbert.hpp:66