INMOST
A toolkit for distributed mathematical modeling
INMOST::Sparse::RowMerger Class Reference

This class may be used to sum multiple sparse rows. More...

#include <inmost_sparse.h>

Classes

class  iterator
 

Public Member Functions

 RowMerger ()
 Default constructor without size specified.
 
 ~RowMerger ()
 Constructor with size specified. More...
 
void Resize (INMOST_DATA_ENUM_TYPE size)
 Resize linked list for new interval. More...
 
 RowMerger (const Matrix &A)
 Constructor that gets sizes from the matrix, including non-local mapping. More...
 
void Resize (const Matrix &A)
 Resize linked list for new matrix, including non-local mapping. More...
 
void Clear ()
 Clear linked list.
 
void PushRow (INMOST_DATA_REAL_TYPE coef, const Row &r)
 Add a row with a coefficient into empty linked list. More...
 
void AddRow (INMOST_DATA_REAL_TYPE coef, const Row &r)
 Add a row with a coefficient into non-empty linked list. More...
 
void Multiply (INMOST_DATA_REAL_TYPE coef)
 Multiply all entries of linked list by a coefficient. More...
 
void RetrieveRow (Row &r) const
 Place entries from linked list into row. More...
 
INMOST_DATA_ENUM_TYPE Size () const
 Get current number of nonzeros from linked list.
 
bool Empty () const
 Check if linked list is empty.
 
INMOST_DATA_REAL_TYPE & operator[] (INMOST_DATA_ENUM_TYPE pos)
 Retrive/add an entry from/to linked list. More...
 
INMOST_DATA_REAL_TYPE operator[] (INMOST_DATA_ENUM_TYPE pos) const
 Retrive an entry from linked list. More...
 
void Merge (Row &c, INMOST_DATA_REAL_TYPE alpha, const Row &a, INMOST_DATA_REAL_TYPE beta, const Row &b)
 Operation of the form c = alpha a + beta b. More...
 
iterator Begin ()
 Retrive iterator for the first element.
 
iterator End ()
 Retrive iterator for the position beyond the last element.
 

Public Attributes

const INMOST_DATA_ENUM_TYPE EOL = ENUMUNDEF-1
 End of linked list.
 

Detailed Description

This class may be used to sum multiple sparse rows.

Warning
In parallel column indices of the matrix may span wider then local row indices, to prevent any problem you can safely set total size of the matrix as interval of the RowMerger.

Definition at line 637 of file inmost_sparse.h.

Constructor & Destructor Documentation

◆ ~RowMerger()

INMOST::Sparse::RowMerger::~RowMerger ( )

Constructor with size specified.

Parameters
interval_beginFirst index in linked list.
interval_endLast index in linked list.
SortedResult should be sorted or not. Destructor.

◆ RowMerger()

INMOST::Sparse::RowMerger::RowMerger ( const Matrix A)

Constructor that gets sizes from the matrix, including non-local mapping.

Parameters
AMatrix to get sizes from.
SortedResult should be sorted.

Member Function Documentation

◆ AddRow()

void INMOST::Sparse::RowMerger::AddRow ( INMOST_DATA_REAL_TYPE  coef,
const Row r 
)

Add a row with a coefficient into non-empty linked list.

Use RowMerger::PushRow for empty linked list.

Parameters
coefCoefficient to multiply row values.
rA row to be added.

◆ Merge()

void INMOST::Sparse::RowMerger::Merge ( Row c,
INMOST_DATA_REAL_TYPE  alpha,
const Row a,
INMOST_DATA_REAL_TYPE  beta,
const Row b 
)
inline

Operation of the form c = alpha a + beta b.

Warning
Linked list must be clear before operation.
Parameters
cRow c. This will be overwritten.
alphaMultiplier for row a.
aRow a.
betaMultiplier for row b.
bRow b.

Definition at line 773 of file inmost_sparse.h.

◆ Multiply()

void INMOST::Sparse::RowMerger::Multiply ( INMOST_DATA_REAL_TYPE  coef)

Multiply all entries of linked list by a coefficient.

Parameters
coefA coefficient for multiplication.

◆ operator[]() [1/2]

INMOST_DATA_REAL_TYPE& INMOST::Sparse::RowMerger::operator[] ( INMOST_DATA_ENUM_TYPE  pos)
inline

Retrive/add an entry from/to linked list.

Parameters
posPosition in the list.

Definition at line 759 of file inmost_sparse.h.

◆ operator[]() [2/2]

INMOST_DATA_REAL_TYPE INMOST::Sparse::RowMerger::operator[] ( INMOST_DATA_ENUM_TYPE  pos) const
inline

Retrive an entry from linked list.

Warning
Will fire an exception if there is no entry.
Parameters
posPosition in the list.

Definition at line 764 of file inmost_sparse.h.

◆ PushRow()

void INMOST::Sparse::RowMerger::PushRow ( INMOST_DATA_REAL_TYPE  coef,
const Row r 
)

Add a row with a coefficient into empty linked list.

This routine should be a bit faster then RowMerger::AddRow for empty linked list. It may result in an unexpected behavior for non-empty linked list, asserts will fire in debug mode.

Parameters
coefCoefficient to multiply row values.
rA row to be added.

◆ Resize() [1/2]

void INMOST::Sparse::RowMerger::Resize ( const Matrix A)

Resize linked list for new matrix, including non-local mapping.

Warning
All contents of linked list will be lost after resize.
Parameters
AMatrix to get sizes from.
SortedResult should be sorted or not.

◆ Resize() [2/2]

void INMOST::Sparse::RowMerger::Resize ( INMOST_DATA_ENUM_TYPE  size)

Resize linked list for new interval.

Warning
All contents of linked list will be lost after resize.
Parameters
interval_beginFirst index in linked list.
interval_endLast index in linked list.
SortedResult should be sorted or not.

◆ RetrieveRow()

void INMOST::Sparse::RowMerger::RetrieveRow ( Row r) const

Place entries from linked list into row.

Warning
All contents of the row will be overwritten. If you want contents of the row to be added use AddRow with this row in advance.
Parameters
rA row to be filled.

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