INMOST
A toolkit for distributed mathematical modeling
|
Class to store the sparse matrix row. More...
#include <inmost_sparse.h>
Classes | |
struct | entry_s |
Entry of the sparse matrix row. More... | |
Public Types | |
typedef struct INMOST::Sparse::Row::entry_s | entry |
Entry of the sparse matrix row. | |
typedef Entries::iterator | iterator |
Iterator over pairs of index and value. | |
typedef Entries::const_iterator | const_iterator |
Iterator over constant pairs of index and value. | |
typedef Entries::reverse_iterator | reverse_iterator |
Iterator over pairs of index and value running in backward direction. | |
typedef Entries::const_reverse_iterator | const_reverse_iterator |
Iterator over constant pairs of index and value running in backward direction. | |
Public Member Functions | |
Row () | |
Construct an empty row. | |
Row (const Row &other) | |
Copy all data from another row. More... | |
Row (entry *pbegin, entry *pend) | |
Construct a row from array of pairs of indices and values. More... | |
~Row () | |
Release all data. | |
Row & | operator= (Row const &other) |
Copy all data from another row. More... | |
INMOST_DATA_REAL_TYPE & | operator[] (INMOST_DATA_ENUM_TYPE i) |
Finds and returns value with specified index. More... | |
INMOST_DATA_REAL_TYPE | operator[] (INMOST_DATA_ENUM_TYPE i) const |
Finds and returns value with specified index. More... | |
INMOST_DATA_REAL_TYPE | get_safe (INMOST_DATA_ENUM_TYPE i) const |
Finds and returns value with specified index. More... | |
void | Clear () |
Clear all data of the current row. | |
void | Swap (Row &other) |
Exchange all the data with another row. More... | |
INMOST_DATA_ENUM_TYPE | Size () const |
The size of the sparse row, i.e. the total number of nonzero elements. | |
bool | Empty () const |
Checks are there any nonzero entries in the row. | |
INMOST_DATA_ENUM_TYPE & | GetIndex (INMOST_DATA_ENUM_TYPE k) |
Retrieve an index corresponding to certain position in the array of pairs of index and value. More... | |
INMOST_DATA_REAL_TYPE & | GetValue (INMOST_DATA_ENUM_TYPE k) |
Retrieve a value corresponding to certain position in the array of pairs of index and value. More... | |
INMOST_DATA_ENUM_TYPE | GetIndex (INMOST_DATA_ENUM_TYPE k) const |
Retrieve an index corresponding to certain position in the array of pairs of index and value. More... | |
INMOST_DATA_REAL_TYPE | GetValue (INMOST_DATA_ENUM_TYPE k) const |
Retrieve a value corresponding to certain position in the array of pairs of index and value. More... | |
iterator | Begin () |
Retrive interval of nonzeroes. More... | |
iterator | End () |
An iterator pointing behind the last position in the array of pairs of index and value. | |
const_iterator | Begin () const |
An iterator pointing to the first position in the array of constant pairs of index and value. | |
const_iterator | End () const |
An iterator pointing behind the last position in the array of constant pairs of index and value. | |
reverse_iterator | rBegin () |
An iterator pointing to the last position in the array of pairs of index and value. | |
reverse_iterator | rEnd () |
An iterator pointing before the first position in the array of pairs of index and value. | |
const_reverse_iterator | rBegin () const |
An iterator pointing to the last position in the array of constant pairs of index and value. | |
const_reverse_iterator | rEnd () const |
An iterator pointing before the first position in the array of constant pairs of index and value. | |
INMOST_DATA_REAL_TYPE | RowVec (Vector &x) const |
Return the scalar product of the current sparse row by a dense Vector. | |
void | MoveRow (Row &source) |
An optimized assignment of the row, when the content of the source row may not be preserved. More... | |
void | Zero () |
Set the vector entries by zeroes. | |
void | Push (INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_REAL_TYPE val) |
Push specified element into sparse row. More... | |
void | Pop () |
Remove last element. | |
void | Resize (INMOST_DATA_ENUM_TYPE size) |
Resize row to specified size. More... | |
void | Print (double eps=-1, std::ostream &sout=std::cout) const |
Output all entries of the row. | |
void | Sort () |
Sort row. | |
bool | isSorted () const |
Check whether the row is sorted. | |
Static Public Member Functions | |
static __INLINE entry | make_entry (INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_REAL_TYPE val) |
Assemble an entry of entry_s type. More... | |
static void | MergeSortedRows (INMOST_DATA_REAL_TYPE alpha, const Row &left, INMOST_DATA_REAL_TYPE beta, const Row &right, Row &output) |
Add up two rows. More... | |
Class to store the sparse matrix row.
Represents a sparse vector and facilitates access to individual entries. This class is used in expressions of automatic differentiation.
Definition at line 161 of file inmost_sparse.h.
|
inline |
Copy all data from another row.
other | Another row. |
Definition at line 201 of file inmost_sparse.h.
Construct a row from array of pairs of indices and values.
pbegin | Pointer to the first position in array. |
pend | Pointer behind the last position of array. |
Definition at line 205 of file inmost_sparse.h.
|
inline |
Retrive interval of nonzeroes.
An iterator pointing to the first position in the array of pairs of index and value.
Definition at line 275 of file inmost_sparse.h.
|
inline |
Finds and returns value with specified index.
Returns zero if no entry was found.
i | Index. |
Definition at line 242 of file inmost_sparse.h.
|
inline |
Retrieve an index corresponding to certain position in the array of pairs of index and value.
k | Position in the array of pairs of index and value. |
Definition at line 259 of file inmost_sparse.h.
|
inline |
Retrieve an index corresponding to certain position in the array of pairs of index and value.
k | Position in the array of pairs of index and value. |
Definition at line 267 of file inmost_sparse.h.
|
inline |
Retrieve a value corresponding to certain position in the array of pairs of index and value.
k | Position in the array of pairs of index and value. |
Definition at line 263 of file inmost_sparse.h.
|
inline |
Retrieve a value corresponding to certain position in the array of pairs of index and value.
k | Position in the array of pairs of index and value. |
Definition at line 271 of file inmost_sparse.h.
|
inlinestatic |
Assemble an entry of entry_s type.
ind | Index. |
val | Value. |
Definition at line 180 of file inmost_sparse.h.
|
static |
Add up two rows.
Performs operation output=alpha*left+beta*right.
alpha | Coefficient to multiply the left row. |
left | The left row. |
beta | Coefficient to multiply the right row. |
right | The right row. |
output | Record result in this vector. |
|
inline |
An optimized assignment of the row, when the content of the source row may not be preserved.
source | Source raw where to get the contents. |
Definition at line 296 of file inmost_sparse.h.
Copy all data from another row.
other | Another row. |
Definition at line 210 of file inmost_sparse.h.
|
inline |
Finds and returns value with specified index.
Adds a new entry if index was not found.
i | Index. |
Definition at line 217 of file inmost_sparse.h.
|
inline |
Finds and returns value with specified index.
Rises exception on debug and returns extra large value on release if index was not found.
i | Index. |
Definition at line 231 of file inmost_sparse.h.
|
inline |
Push specified element into sparse row.
This function should be used only if the index is not repeated in the row.
Definition at line 301 of file inmost_sparse.h.
|
inline |
Resize row to specified size.
It is intended to be used together with non-const Row::GetIndex and Row::GetValue that allow for the modification of individual entries.
size | New size of the row. |
Definition at line 308 of file inmost_sparse.h.
|
inline |
Exchange all the data with another row.
other | Another row. |
Definition at line 251 of file inmost_sparse.h.