INMOST
Mathematical Modelling Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Attributes | List of all members
INMOST::Sparse::RowMerger Class Reference

#include <inmost_sparse.h>

Collaboration diagram for INMOST::Sparse::RowMerger:

Classes

class  iterator
 

Public Member Functions

 RowMerger ()
 Default constructor without size specified. More...
 
 RowMerger (INMOST_DATA_ENUM_TYPE interval_begin, INMOST_DATA_ENUM_TYPE interval_end, bool Sorted=true)
 
 RowMerger (Matrix &A, bool Sorted=true)
 
 ~RowMerger ()
 Destructor. More...
 
void Resize (INMOST_DATA_ENUM_TYPE interval_begin, INMOST_DATA_ENUM_TYPE interval_end, bool Sorted=true)
 
void Resize (Matrix &A, bool Sorted=true)
 
void Clear ()
 Clear linked list. More...
 
void PushRow (INMOST_DATA_REAL_TYPE coef, Row &r, bool PreSortRow=false)
 
void AddRow (INMOST_DATA_REAL_TYPE coef, Row &r, bool PreSortRow=false)
 
void Multiply (INMOST_DATA_REAL_TYPE coef)
 
void RetriveRow (Row &r)
 
INMOST_DATA_ENUM_TYPE Size ()
 Get current number of nonzeros from linked list. More...
 
INMOST_DATA_REAL_TYPEoperator[] (INMOST_DATA_ENUM_TYPE pos)
 
INMOST_DATA_REAL_TYPE operator[] (INMOST_DATA_ENUM_TYPE pos) const
 
void Merge (Row &c, INMOST_DATA_REAL_TYPE alpha, Row &a, INMOST_DATA_REAL_TYPE beta, Row &b)
 
iterator Begin ()
 
iterator End ()
 

Static Public Attributes

static const INMOST_DATA_ENUM_TYPE EOL = ENUMUNDEF-1
 End of linked list. More...
 
static const INMOST_DATA_ENUM_TYPE UNDEF = ENUMUNDEF
 Value not defined in linked list. More...
 

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 are currently advised to set total size of the matrix as interval of the RowMerger. In future this may change, see todo 2 below.
Todo:
  1. (testing!) Add iterators over entries.
  2. Implement multiple intervals for distributed computation, then in parallel the user may specify additional range of indexes for elements that lay on the borders between each pair of processors.

Or even better implement mapping that will remap nonlocal entries to the end of current linked list when added and put them back in correct places when retrived. May use algorithm from class OrderInfo.

Definition at line 332 of file inmost_sparse.h.

Constructor & Destructor Documentation

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

Default constructor without size specified.

INMOST::Sparse::RowMerger::RowMerger ( INMOST_DATA_ENUM_TYPE  interval_begin,
INMOST_DATA_ENUM_TYPE  interval_end,
bool  Sorted = true 
)

Constructor with size specified.

Parameters
interval_beginFirst index in linked list.
interval_endLast index in linked list.
SortedResult should be sorted or not.
INMOST::Sparse::RowMerger::RowMerger ( Matrix A,
bool  Sorted = true 
)

Constructor that gets sizes from the matrix.

Parameters
AMatrix to get sizes from.
SortedResult should be sorted.
INMOST::Sparse::RowMerger::~RowMerger ( )

Destructor.

Member Function Documentation

void INMOST::Sparse::RowMerger::AddRow ( INMOST_DATA_REAL_TYPE  coef,
Row r,
bool  PreSortRow = false 
)

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.
PreSortRowSort values of the row before adding. Will be activated only for sorted linked lists.

Here is the caller graph for this function:

iterator INMOST::Sparse::RowMerger::Begin ( )
inline

Definition at line 446 of file inmost_sparse.h.

void INMOST::Sparse::RowMerger::Clear ( )

Clear linked list.

Here is the caller graph for this function:

iterator INMOST::Sparse::RowMerger::End ( )
inline

Definition at line 447 of file inmost_sparse.h.

void INMOST::Sparse::RowMerger::Merge ( Row c,
INMOST_DATA_REAL_TYPE  alpha,
Row a,
INMOST_DATA_REAL_TYPE  beta,
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 439 of file inmost_sparse.h.

Here is the call graph for this function:

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

Multiply all entries of linked list by a coefficient.

Parameters
coefA coefficient for multiplication.
INMOST_DATA_REAL_TYPE& INMOST::Sparse::RowMerger::operator[] ( INMOST_DATA_ENUM_TYPE  pos)

Retrive/add an entry from/to linked list.

Parameters
posPosition in the list.
INMOST_DATA_REAL_TYPE INMOST::Sparse::RowMerger::operator[] ( INMOST_DATA_ENUM_TYPE  pos) const

Retrive an entry from linked list.

Warning
Will fire an exception if there is no entry.
Parameters
posPosition in the list.
void INMOST::Sparse::RowMerger::PushRow ( INMOST_DATA_REAL_TYPE  coef,
Row r,
bool  PreSortRow = false 
)

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.
PreSortRowSort values of the row before adding. Will be activated only for sorted linked lists.

Here is the caller graph for this function:

void INMOST::Sparse::RowMerger::Resize ( INMOST_DATA_ENUM_TYPE  interval_begin,
INMOST_DATA_ENUM_TYPE  interval_end,
bool  Sorted = true 
)

Resize linked list for new interval.

Warning
All contents of linked list will be lost after resize. This behavior may be changed in future.
Parameters
interval_beginFirst index in linked list.
interval_endLast index in linked list.
SortedResult should be sorted or not.
void INMOST::Sparse::RowMerger::Resize ( Matrix A,
bool  Sorted = true 
)

Resize linked list for new matrix.

Warning
All contents of linked list will be lost after resize. This behavior may be changed in future.
Parameters
AMatrix to get sizes from.
SortedResult should be sorted or not.
void INMOST::Sparse::RowMerger::RetriveRow ( Row r)

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.

Here is the caller graph for this function:

INMOST_DATA_ENUM_TYPE INMOST::Sparse::RowMerger::Size ( )
inline

Get current number of nonzeros from linked list.

Definition at line 422 of file inmost_sparse.h.

Member Data Documentation

const INMOST_DATA_ENUM_TYPE INMOST::Sparse::RowMerger::EOL = ENUMUNDEF-1
static

End of linked list.

Definition at line 335 of file inmost_sparse.h.

const INMOST_DATA_ENUM_TYPE INMOST::Sparse::RowMerger::UNDEF = ENUMUNDEF
static

Value not defined in linked list.

Definition at line 336 of file inmost_sparse.h.


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