34 #include "Matrix2HilbertCoordinates.hpp"
39 #ifndef _H_HILBERT_TRIPLET
40 #define _H_HILBERT_TRIPLET
45 template<
typename T >
65 unsigned long int i()
const {
return row; }
68 unsigned long int j()
const {
return column; }
121 static void save( std::string fn,
HilbertTriplet< T >* toWrite,
const unsigned long int m,
const unsigned long int n,
const size_t s ) {
122 std::fstream myFile ( fn.c_str(), std::ios::out | std::ios::binary);
123 myFile.write( (
char*) &m,
sizeof(
unsigned long int ) );
124 myFile.write( (
char*) &n,
sizeof(
unsigned long int ) );
125 for(
size_t i = 0;
i<s;
i++ ) {
126 const unsigned long int wi = toWrite[
i ].
i();
127 const unsigned long int wj = toWrite[
i ].
j();
128 const double wv = toWrite[
i ].
value;
130 std::cout <<
"Wrote: ( " << wi <<
" , " << wj <<
" , " << wv <<
" ) " << std::endl;
132 myFile.write( (
char*) &( wi ),
sizeof(
unsigned long int ) );
133 myFile.write( (
char*) &( wj ),
sizeof(
unsigned long int ) );
134 myFile.write( (
char*) &( wv ),
sizeof( T ) );
148 static void save( std::string fn, std::vector<
HilbertTriplet< T > > &toWrite,
const unsigned long int m,
const unsigned long int n ) {
149 save( fn, &( toWrite[ 0 ] ), m, n, toWrite.size() );
Hilbert-coordinate-aware triplet.
Definition: HilbertTriplet.hpp:46
static void save(std::string fn, std::vector< HilbertTriplet< T > > &toWrite, const unsigned long int m, const unsigned long int n)
Saves a std::vector of Hilbert triplets to a file, in binary format.
Definition: HilbertTriplet.hpp:148
size_t getLeastSignificantHilbertBits()
Definition: HilbertTriplet.hpp:107
HilbertTriplet(unsigned long int i, unsigned long int j, T val)
Base constructor.
Definition: HilbertTriplet.hpp:78
T value
Value stored at this triplet.
Definition: HilbertTriplet.hpp:71
static void IntegerToHilbert(const size_t i, const size_t j, size_t &h1, size_t &h2)
New method, October 2010.
Definition: Matrix2HilbertCoordinates.cpp:48
size_t getMostSignificantHilbertBits()
Definition: HilbertTriplet.hpp:102
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
size_t column
The column coordinate of this triplet.
Definition: HilbertTriplet.hpp:54
size_t hilbert1
Most significant part of a 128-bits Hilbert coordinate, for one-shot, non-iterative, calculation.
Definition: HilbertTriplet.hpp:57
void getHilbertCoordinate(size_t &h1, size_t &h2)
Gets the Hilbert coordinates.
Definition: HilbertTriplet.hpp:96
size_t row
The row coordinate of this triplet.
Definition: HilbertTriplet.hpp:51
unsigned long int i() const
Definition: HilbertTriplet.hpp:65
HilbertTriplet()
Base constructor.
Definition: HilbertTriplet.hpp:81
void calculateHilbertCoordinate()
Calculates the full Hilbert coordinate.
Definition: HilbertTriplet.hpp:84
size_t hilbert2
Least significant part of a 128-bits Hilbert coordinate, for one-shot, non-iterative, calculation.
Definition: HilbertTriplet.hpp:60
unsigned long int j() const
Definition: HilbertTriplet.hpp:68