HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
 All Classes Files Functions Variables Typedefs Friends Macros
SparseMatrix_CCS Class Reference

#include <SparseMatrix_CCS.h>

Public Member Functions

 SparseMatrix_CCS (unsigned int n, unsigned int m)
 
 SparseMatrix_CCS (const SparseMatrix_CCS &)
 
virtual ~SparseMatrix_CCS ()
 
SparseMatrix_CCSoperator= (const SparseMatrix_CCS &)
 
double operator() (unsigned int i, unsigned int j) const
 
unsigned int gn () const
 
unsigned int gm () const
 
void ConvertFromMatrix (const matrix &dense)
 
void ConvertToMatrix (matrix &dense) const
 
void PrintRaw () const
 
void PushToCol (unsigned int j, double value)
 
void NewCol ()
 
void mvprod (const matrix &, matrix &) const
 
unsigned int NumOfElInCol (unsigned int idx) const
 
double GetElementInCol (unsigned int col_index, unsigned int element_index) const
 
unsigned int GetElementRowIndexInCol (unsigned int col_index, unsigned int element_index) const
 
void prod (const matrix &, const SparseMatrix_CCS &)
 

Private Attributes

std::vector< double > data
 Array that holds the non zero values. More...
 
std::vector< unsigned int > col
 Array that holds the column indexes. More...
 
std::vector< unsigned int > row
 Array that holds the row index of data. More...
 
unsigned int n
 dimension of the matrix (number of rows) More...
 
unsigned int m
 dimension of the matrix (number of columns) More...
 

Friends

ostream & operator<< (ostream &output, SparseMatrix_CCS &matrix_p)
 

Detailed Description

Author
Ward Poelmans
Date
09-08-2013

This is a class written for sparse n x m matrices to use on the gpu. It uses the CCS format to store a matrix.

Definition at line 35 of file SparseMatrix_CCS.h.

Constructor & Destructor Documentation

SparseMatrix_CCS::SparseMatrix_CCS ( unsigned int  n,
unsigned int  m 
)

Construct SparseMatrix_CCS object for n x m matrix

Parameters
nthe number of rows
mthe number of columns

Definition at line 29 of file SparseMatrix_CCS.cpp.

SparseMatrix_CCS::SparseMatrix_CCS ( const SparseMatrix_CCS origin)

Copy constructor

Parameters
originthe object to copy

Definition at line 39 of file SparseMatrix_CCS.cpp.

SparseMatrix_CCS::~SparseMatrix_CCS ( )
virtual

Definition at line 48 of file SparseMatrix_CCS.cpp.

Member Function Documentation

void SparseMatrix_CCS::ConvertFromMatrix ( const matrix dense)

Convert a dense matrix to CCS format

Parameters
densethe matrix to convert

Definition at line 103 of file SparseMatrix_CCS.cpp.

+ Here is the call graph for this function:

void SparseMatrix_CCS::ConvertToMatrix ( matrix dense) const

Convert this CCS matrix to a dense matrix (only works for square matrices)

Parameters
densethe matrix to fill

Definition at line 133 of file SparseMatrix_CCS.cpp.

+ Here is the call graph for this function:

double SparseMatrix_CCS::GetElementInCol ( unsigned int  col_index,
unsigned int  element_index 
) const

Gives an element in from a column

Parameters
col_indexthe column from whiche to select an element
element_indexthe index of the element in column col_index
Returns
the value of the element element_index in column col_index

Definition at line 252 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

unsigned int SparseMatrix_CCS::GetElementRowIndexInCol ( unsigned int  col_index,
unsigned int  element_index 
) const

Get the row index of a element in a certain column

Parameters
col_indexthe column index to use
element_indexthe index of the element
Returns
the row number of the element

Definition at line 265 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

unsigned int SparseMatrix_CCS::gm ( ) const
Returns
the number of columns

Definition at line 78 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

unsigned int SparseMatrix_CCS::gn ( ) const
Returns
the number of rows

Definition at line 70 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

void SparseMatrix_CCS::mvprod ( const matrix ,
matrix  
) const
void SparseMatrix_CCS::NewCol ( )

Adds the next col to the sparsematrix

Definition at line 227 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

unsigned int SparseMatrix_CCS::NumOfElInCol ( unsigned int  idx) const

Number of elements in a column

Parameters
idxthe number of the column
Returns
the number of elements in column idx

Definition at line 240 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

double SparseMatrix_CCS::operator() ( unsigned int  i,
unsigned int  j 
) const

Read only access operator

Parameters
ithe row number
jthe column number
Returns
the matrix element

Definition at line 58 of file SparseMatrix_CCS.cpp.

SparseMatrix_CCS & SparseMatrix_CCS::operator= ( const SparseMatrix_CCS origin)

Copy operator

Parameters
originthe object to copy
Returns
this object

Definition at line 88 of file SparseMatrix_CCS.cpp.

void SparseMatrix_CCS::PrintRaw ( ) const

Print the raw CCS data to stdout

Definition at line 149 of file SparseMatrix_CCS.cpp.

void SparseMatrix_CCS::prod ( const matrix A,
const SparseMatrix_CCS B 
)

Matrix-Matrix product of A and B: AB Stores the result in this object, destroying any matrix in it. The size is adjusted to the result of AB.

Parameters
Adense matrix
Bsparse matrix

Definition at line 279 of file SparseMatrix_CCS.cpp.

+ Here is the call graph for this function:

void SparseMatrix_CCS::PushToCol ( unsigned int  j,
double  value 
)

Adds a new row element to the current column. To use this, first call NewCol() to start a column and then use PushToCol() to add elements to that col. Always end with calling NewCol() again.

Parameters
jrow
valuethe matrix element value

Definition at line 191 of file SparseMatrix_CCS.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

ostream& operator<< ( ostream &  output,
SparseMatrix_CCS matrix_p 
)
friend

Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:

object << matrix << endl;

For output onto the screen type:

cout << matrix << endl;

Parameters
outputThe stream to which you are writing (e.g. cout)
matrix_pde SparseMatrix_CCS you want to print

Print sparse matrix to output

Parameters
outputthe ostream to print to
matrix_pthe matrix to print
Returns
the filled ostream (with the matrix)

Definition at line 174 of file SparseMatrix_CCS.cpp.

Member Data Documentation

std::vector<unsigned int> SparseMatrix_CCS::col
private

Array that holds the column indexes.

Definition at line 97 of file SparseMatrix_CCS.h.

std::vector<double> SparseMatrix_CCS::data
private

Array that holds the non zero values.

Definition at line 95 of file SparseMatrix_CCS.h.

unsigned int SparseMatrix_CCS::m
private

dimension of the matrix (number of columns)

Definition at line 104 of file SparseMatrix_CCS.h.

unsigned int SparseMatrix_CCS::n
private

dimension of the matrix (number of rows)

Definition at line 102 of file SparseMatrix_CCS.h.

std::vector<unsigned int> SparseMatrix_CCS::row
private

Array that holds the row index of data.

Definition at line 99 of file SparseMatrix_CCS.h.


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