NTPoly
Public Member Functions | List of all members
NTPoly::SparseMatrix Class Reference

A datatype for storing a CSR matrix. More...

#include <SparseMatrix.h>

Public Member Functions

 SparseMatrix (int columns, int rows)
 
 SparseMatrix (std::string file_name)
 
 SparseMatrix (const NTPoly::TripletList &list, int rows, int columns)
 
 SparseMatrix (const NTPoly::SparseMatrix &matB)
 
int GetRows () const
 Get the number of rows in a matrix.
 
int GetColumns () const
 Get the number of columns in a matrix.
 
void ExtractRow (int row_number, SparseMatrix &row_out) const
 
void ExtractColumn (int column_number, SparseMatrix &column_out) const
 
void Scale (double constant)
 
void Increment (const NTPoly::SparseMatrix &matB, double alpha, double threshold)
 
double Dot (const NTPoly::SparseMatrix &matB) const
 
void PairwiseMultiply (const NTPoly::SparseMatrix &matA, const NTPoly::SparseMatrix &matB)
 
void Gemm (const NTPoly::SparseMatrix &matA, const NTPoly::SparseMatrix &matB, bool isATransposed, bool isBTransposed, double alpha, double beta, double threshold, NTPoly::MatrixMemoryPool &memory_pool)
 
void Transpose (const NTPoly::SparseMatrix &matA)
 Transpose a sparse matrix.
 
void Print ()
 Print the sparse matrix to the console.
 
void WriteToMatrixMarket (std::string file_name)
 
void MatrixToTripletList (NTPoly::TripletList &triplet_list)
 
 ~SparseMatrix ()
 Standard destructor.
 

Detailed Description

A datatype for storing a CSR matrix.

Constructor & Destructor Documentation

◆ SparseMatrix() [1/4]

NTPoly::SparseMatrix::SparseMatrix ( int  columns,
int  rows 
)

Basic constructor.

Parameters
columnsnumber of columns for the matrix.
rowsnumber of rows for the matrix.

◆ SparseMatrix() [2/4]

NTPoly::SparseMatrix::SparseMatrix ( std::string  file_name)

Construct from a matrix market file.

Parameters
file_namematrix market file name.

◆ SparseMatrix() [3/4]

NTPoly::SparseMatrix::SparseMatrix ( const NTPoly::TripletList list,
int  rows,
int  columns 
)

Construct from a triplet list.

Parameters
lista list of triplet values to set in the matrix.
columnsnumber of columns for the matrix.
rowsnumber of rows for the matrix.

◆ SparseMatrix() [4/4]

NTPoly::SparseMatrix::SparseMatrix ( const NTPoly::SparseMatrix matB)

Copy constructor.

Parameters
matBthe matrix to copy from.

Member Function Documentation

◆ Dot()

double NTPoly::SparseMatrix::Dot ( const NTPoly::SparseMatrix matB) const

Matrix dot product.

Parameters
matBmatrix to dot with.
Returns
the dot product of this and matB.

◆ ExtractColumn()

void NTPoly::SparseMatrix::ExtractColumn ( int  column_number,
SparseMatrix column_out 
) const

Extract a column from the matrix into the compressed vector representation.

Parameters
column_numberthe column to extract
column_outthe matrix representing that column

◆ ExtractRow()

void NTPoly::SparseMatrix::ExtractRow ( int  row_number,
SparseMatrix row_out 
) const

Extract a row from the matrix into the compressed vector representation.

Parameters
row_numberthe row to extract
row_outthe matrix representing that row

◆ Gemm()

void NTPoly::SparseMatrix::Gemm ( const NTPoly::SparseMatrix matA,
const NTPoly::SparseMatrix matB,
bool  isATransposed,
bool  isBTransposed,
double  alpha,
double  beta,
double  threshold,
NTPoly::MatrixMemoryPool memory_pool 
)

This := alpha*matA*op( matB ) + beta*this

Parameters
matA
matB
isATransposedtrue if A is already transposed.
isBTransposedtrue if B is already transposed.
alphascaling value.
betascaling value.
thresholdfor flushing small values.
memory_poola memory pool to use for storing intermediates.

◆ Increment()

void NTPoly::SparseMatrix::Increment ( const NTPoly::SparseMatrix matB,
double  alpha,
double  threshold 
)

This = alpha*MatrixB + This(AXPY).

Parameters
matBmatrix to add.
alphascale for the matrix.
thresholdfor flushing small values.

◆ MatrixToTripletList()

void NTPoly::SparseMatrix::MatrixToTripletList ( NTPoly::TripletList triplet_list)

Compute a triplet list from the entries in a matrix.

Parameters
triplet_listoutput.

◆ PairwiseMultiply()

void NTPoly::SparseMatrix::PairwiseMultiply ( const NTPoly::SparseMatrix matA,
const NTPoly::SparseMatrix matB 
)

Pairwise multiply two sparse matrices.

Parameters
matA
matB

◆ Scale()

void NTPoly::SparseMatrix::Scale ( double  constant)

Scale the matrix by a constant.

Parameters
constantvalue to scale by.

◆ WriteToMatrixMarket()

void NTPoly::SparseMatrix::WriteToMatrixMarket ( std::string  file_name)

Write the sparse matrix to file.

Parameters
file_namefile to print to.

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