SparseLibrary  Version 1.6.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HTS< T > Class Template Reference

The Hilbert triplet scheme. More...

#include <HTS.hpp>

Inheritance diagram for HTS< T >:
Inheritance graph
[legend]
Collaboration diagram for HTS< T >:
Collaboration graph
[legend]

Public Member Functions

 HTS ()
 Base constructor. More...
 
 HTS (std::string file, T zero=0)
 Base constructor. More...
 
 HTS (std::vector< Triplet< T > > &input, ULI m, ULI n, T zero)
 Base constructor. More...
 
virtual void load (std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero)
 
virtual void getFirstIndexPair (ULI &row, ULI &col)
 Returns the first nonzero index, per reference. More...
 
virtual void zxa (const T *x, T *z)
 Calculates z=xA. More...
 
virtual void zax (const T *x, T *z)
 Calculates z=Ax. More...
 
virtual size_t bytesUsed ()
 Function to query the amount of storage required by this sparse matrix. More...
 
void saveBinary (const std::string fn)
 Saves the current HTS. More...
 
void loadBinary (const std::string fn)
 Loads from binary triplets, assumes Hilbert ordering already done.
 
- Public Member Functions inherited from SparseMatrix< T, ULI >
 SparseMatrix ()
 Base constructor. More...
 
 SparseMatrix (const ULInzs, const ULInr, const ULInc, const T zero)
 Base constructor. More...
 
virtual ~SparseMatrix ()
 Base deconstructor. More...
 
void loadFromFile (const std::string file, const T zero=0)
 Function which loads a matrix from a matrix market file. More...
 
virtual unsigned long int m ()
 Queries the number of rows this matrix contains. More...
 
virtual unsigned long int n ()
 Queries the number of columns this matrix contains. More...
 
virtual unsigned long int nzs ()
 Queries the number of nonzeroes stored in this matrix. More...
 
virtual T * mv (const T *x)
 Calculates and returns z=Ax. More...
 
virtual void zax (const T *__restrict__ x, T *__restrict__ z)=0
 In-place z=Ax function. More...
 
virtual void zxa (const T *__restrict__ x, T *__restrict__ z)=0
 In-place z=xA function. More...
 
- Public Member Functions inherited from Matrix< T >
 Matrix ()
 Base constructor. More...
 
virtual ~Matrix ()
 Base deconstructor. More...
 
virtual void zax (const T *__restrict__ x, T *__restrict__ z, const size_t k, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zax kernel multiple times successively, while timing the duration of the operation. More...
 
template<size_t k>
void ZaX (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
 In-place Z=AX function, where A is m x n, Z = m x k, and X is n x k. More...
 
template<size_t k>
void ZXa (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
 In-place Z=XA function, where A is m x n, Z = k x n, and X is k x m. More...
 
virtual void zxa (const T *__restrict__ x, T *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zxa kernel multiple times successively, while timing the operation duration. More...
 

Protected Member Functions

bool cmp (HilbertTriplet< T > &left, HilbertTriplet< T > &right)
 HilbertCoordinate comparison function. More...
 
unsigned long int find (HilbertTriplet< T > &x, ULI &left, ULI &right)
 Binary search for finding a given triplet in a given range. More...
 

Protected Attributes

ULI minexp
 Minimum number of expansions.
 
std::vector< HilbertTriplet< T > > ds
 Vector storing the non-zeros and their locations. More...
 
- Protected Attributes inherited from SparseMatrix< T, ULI >
ULI nor
 Number of rows. More...
 
ULI noc
 Number of columns.
 
ULI nnz
 Number of non-zeros. More...
 

Additional Inherited Members

- Public Attributes inherited from SparseMatrix< T, ULI >
zero_element
 The element considered to be zero. More...
 

Detailed Description

template<typename T>
class HTS< T >

The Hilbert triplet scheme.

In effect similar to the triplet scheme (TS), but uses Hilbert coordinates to determine the order of storage.

Constructor & Destructor Documentation

template<typename T>
HTS< T >::HTS ( )
inline

Base constructor.

template<typename T>
HTS< T >::HTS ( std::string  file,
zero = 0 
)
inline

Base constructor.

Will read in from Matrix Market file.

See also
SparseMatrix::SparseMatrix( file, zero )

References SparseMatrix< T, ULI >::loadFromFile().

template<typename T>
HTS< T >::HTS ( std::vector< Triplet< T > > &  input,
ULI  m,
ULI  n,
zero 
)
inline

Base constructor.

Warning: the zero parameter is currently NOT USED!

Parameters
inputRaw input of normal triplets.
mTotal number of rows.
nTotal number of columns.
zeroWhat elements is considered to-be zero.

References HTS< T >::load().

Member Function Documentation

template<typename T>
virtual size_t HTS< T >::bytesUsed ( )
inlinevirtual

Function to query the amount of storage required by this sparse matrix.

Returns
The size of the sparse matrix in bytes.

Implements Matrix< T >.

References SparseMatrix< T, ULI >::nnz.

template<typename T>
bool HTS< T >::cmp ( HilbertTriplet< T > &  left,
HilbertTriplet< T > &  right 
)
inlineprotected

HilbertCoordinate comparison function.

References HilbertTriplet< T >::i(), HilbertTriplet< T >::j(), SparseMatrix< T, ULI >::noc, and SparseMatrix< T, ULI >::nor.

Referenced by HTS< T >::find().

template<typename T>
unsigned long int HTS< T >::find ( HilbertTriplet< T > &  x,
ULI &  left,
ULI &  right 
)
inlineprotected

Binary search for finding a given triplet in a given range.

Parameters
xtriplet to-be found.
leftLeft bound of the range to search in.
rightRight bound of the range to search in.
Returns
Index of the triplet searched.

References HTS< T >::cmp(), HTS< T >::ds, and HTS< T >::minexp.

template<typename T>
virtual void HTS< T >::getFirstIndexPair ( ULI &  row,
ULI &  col 
)
inlinevirtual

Returns the first nonzero index, per reference.

Implements SparseMatrix< T, ULI >.

References HTS< T >::ds.

template<typename T>
virtual void HTS< T >::load ( std::vector< Triplet< T > > &  input,
const ULI  m,
const ULI  n,
const T  zero 
)
inlinevirtual
template<typename T>
void HTS< T >::saveBinary ( const std::string  fn)
inline

Saves the current HTS.

Parameters
fnFilename to save to.
See also
HilbertTriplet< T >::save `

References HTS< T >::ds, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, and HilbertTriplet< T >::save().

template<typename T>
virtual void HTS< T >::zax ( const T *  x,
T *  z 
)
inlinevirtual

Calculates z=Ax.

z is not set to 0 at the start of this method!

Parameters
xThe (initialised) input vector.
zThe (initialised) output vector.

References HTS< T >::ds, and SparseMatrix< T, ULI >::nnz.

template<typename T>
virtual void HTS< T >::zxa ( const T *  x,
T *  z 
)
inlinevirtual

Calculates z=xA.

z is not set to 0 at the start of this method!

Parameters
xThe (initialised) input vector.
zThe (initialised) output vector.

References HTS< T >::ds, and SparseMatrix< T, ULI >::nnz.

Member Data Documentation

template<typename T>
std::vector< HilbertTriplet< T > > HTS< T >::ds
protected

The documentation for this class was generated from the following file: