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

A single triplet value. More...

#include <Triplet.hpp>

Collaboration diagram for Triplet< T >:
Collaboration graph
[legend]

Public Member Functions

ULI i () const
 
ULI j () const
 
void rowOffset (ULI offset)
 Subtracts a given value from this nonzero row index. More...
 
void setPosition (const unsigned long int i, const unsigned long int j)
 Set the coordinates of this nonzero. More...
 
void setRowPosition (const unsigned long int i)
 Set the row coordinate of this nonzero. More...
 
void setColumnPosition (const unsigned long int j)
 Set the column coordinate of this nonzero. More...
 
 Triplet (ULI ii, ULI ij, T val)
 Base constructor. More...
 
 Triplet ()
 Base constructor. More...
 
 Triplet (const Triplet< T > &toCopy)
 Copy constructor. More...
 
void transpose ()
 Transposes this triplet, i.e., swapping the row and column value. More...
 

Static Public Member Functions

static std::vector< Triplet< T > > load (const std::string fn, ULI &m, ULI &n)
 Loads an array of triplets from a binary file. More...
 
static std::vector< Triplet< T > > loadCRS (const std::string fn, ULI &m, ULI &n)
 Loads a CRS text file and transforms it into a vector of Triplets. More...
 
static void save (std::string fn, Triplet< T > *toWrite, const ULI m, const ULI n, const ULI s)
 Saves an array of triplets to a file, in binary format. More...
 
static void save (std::string fn, std::vector< Triplet< T > > &toWrite, const ULI m, const ULI n)
 Saves a std::vector of triplets to a file, in binary format. More...
 

Public Attributes

value
 Value stored at this triplet. More...
 

Protected Attributes

ULI row
 The row coordinate of this triplet. More...
 
ULI column
 The column coordinate of this triplet. More...
 

Detailed Description

template<typename T>
class Triplet< T >

A single triplet value.

Stores, at minimum, a row position, a column position, and a value of the template type.

Constructor & Destructor Documentation

template<typename T>
Triplet< T >::Triplet ( ULI  ii,
ULI  ij,
val 
)
inline

Base constructor.

Parameters
iirow index.
ijcolumn index.
valnonzero value.
template<typename T>
Triplet< T >::Triplet ( )
inline

Base constructor.

Sets all values to zero.

template<typename T>
Triplet< T >::Triplet ( const Triplet< T > &  toCopy)
inline

Copy constructor.

Member Function Documentation

template<typename T>
ULI Triplet< T >::i ( ) const
inline
template<typename T>
ULI Triplet< T >::j ( ) const
inline
template<typename T>
static std::vector< Triplet< T > > Triplet< T >::load ( const std::string  fn,
ULI &  m,
ULI &  n 
)
inlinestatic

Loads an array of triplets from a binary file.

Warning: there is a difference between 32 and 64 bits files!

Parameters
fnFilename of the file to load from.
mReference to where the total number of rows is to-be stored.
nReference to where the total number of columns is to-be stored.
Returns
A std::vector containing the triplets in the order they were loaded in.

References Triplet< T >::i(), and Triplet< T >::j().

Referenced by Hilbert< T >::loadBinary(), HTS< T >::loadBinary(), and SparseMatrix< double, size_t >::loadFromFile().

template<typename T>
static std::vector< Triplet< T > > Triplet< T >::loadCRS ( const std::string  fn,
ULI &  m,
ULI &  n 
)
inlinestatic

Loads a CRS text file and transforms it into a vector of Triplets.

Parameters
fnFilename of the file to load from.
mReference to where to store the number of rows of this matrix.
nReference to where to store the number of columns of this matrix.
Returns
A std::vector containing the read and converted triplets.

References Triplet< T >::i(), and Triplet< T >::j().

Referenced by SparseMatrix< double, size_t >::loadFromFile().

template<typename T>
void Triplet< T >::rowOffset ( ULI  offset)
inline

Subtracts a given value from this nonzero row index.

References Triplet< T >::row.

template<typename T>
static void Triplet< T >::save ( std::string  fn,
Triplet< T > *  toWrite,
const ULI  m,
const ULI  n,
const ULI  s 
)
inlinestatic

Saves an array of triplets to a file, in binary format.

Parameters
fnFilename to save to (overwrite mode).
toWriteArray of triplets to write.
mTotal number of rows in the matrix.+
nTotal number of columns in the matrix.
sSize of the array toWrite.

References Triplet< T >::i(), Triplet< T >::j(), and Triplet< T >::value.

Referenced by Triplet< T >::save().

template<typename T>
static void Triplet< T >::save ( std::string  fn,
std::vector< Triplet< T > > &  toWrite,
const ULI  m,
const ULI  n 
)
inlinestatic

Saves a std::vector of triplets to a file, in binary format.

Parameters
fnFilename to save to (overwrite mode).
toWriteVector of triplets to write.
mTotal number of rows in the matrix.
nTotal number of columns in the matrix.

References Triplet< T >::save().

template<typename T>
void Triplet< T >::setColumnPosition ( const unsigned long int  j)
inline

Set the column coordinate of this nonzero.

References Triplet< T >::row, and Triplet< T >::setPosition().

template<typename T>
void Triplet< T >::setPosition ( const unsigned long int  i,
const unsigned long int  j 
)
inline
template<typename T>
void Triplet< T >::setRowPosition ( const unsigned long int  i)
inline

Set the row coordinate of this nonzero.

References Triplet< T >::column, and Triplet< T >::setPosition().

template<typename T>
void Triplet< T >::transpose ( )
inline

Transposes this triplet, i.e., swapping the row and column value.

References Triplet< T >::column, and Triplet< T >::row.

Member Data Documentation

template<typename T>
ULI Triplet< T >::column
protected

The column coordinate of this triplet.

Referenced by Triplet< T >::j(), Triplet< T >::setPosition(), Triplet< T >::setRowPosition(), and Triplet< T >::transpose().

template<typename T>
ULI Triplet< T >::row
protected
template<typename T>
T Triplet< T >::value

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