#include <SparseVector.h>
Public Member Functions | |
| void | add_entries (int num, int pos) |
| void | append (int idx, const double val=0.) |
| void | copy_raw (int *indices, double *values) const |
| int | first () const |
| int | last () const |
| int | nnz () const |
| double | operator() (int idx) const |
| const SparseVector & | operator= (const SparseVector &vec) |
| void | print () const |
| void | remove (int idx) |
| bool | set (int idx, const double val=0.) |
| bool | set (int idx, const Eigen::VectorXd &vals) |
| SparseVector () | |
| SparseVector (int nnz_max) | |
| SparseVector (const SparseVector &vec) | |
| SparseVector (const SparseVector &vec, int num, int first=0) | |
| SparseVector (int *indices, double *values, int nnz) | |
| virtual | ~SparseVector () |
Private Member Functions | |
| void | _copy_from (const SparseVector &vec) |
| void | _dealloc () |
| void | _resize (int new_nnz_max) |
| int | _search (int idx) const |
Private Attributes | |
| int * | _indices |
| int | _nnz |
| int | _nnz_max |
| double * | _values |
Friends | |
| class | SparseVectorIter |
Definition at line 36 of file SparseVector.h.
Standard constructor.
Definition at line 114 of file SparseVector.cpp.
| isam::SparseVector::SparseVector | ( | int | nnz_max | ) | [inline] |
Definition at line 71 of file SparseVector.h.
| isam::SparseVector::SparseVector | ( | const SparseVector & | vec | ) |
Copy constructor - note that overwriting operator= is also necessary!
| vec | SparseVector to initialize from. |
Definition at line 122 of file SparseVector.cpp.
| isam::SparseVector::SparseVector | ( | const SparseVector & | vec, |
| int | num, | ||
| int | first = 0 |
||
| ) |
Subvector copy constructor.
| vec | SparseVector to copy from. |
| num | Number of entries to copy (note sparse - most will not exist!) |
| first | Index of first entry of new vector. |
Definition at line 126 of file SparseVector.cpp.
| isam::SparseVector::SparseVector | ( | int * | indices, |
| double * | values, | ||
| int | nnz | ||
| ) |
Construct from raw data.
| indices | Array of row indices. |
| values | Array of values. |
| nnz | Length of vector. |
Definition at line 151 of file SparseVector.cpp.
| isam::SparseVector::~SparseVector | ( | ) | [virtual] |
Destructor.
Definition at line 162 of file SparseVector.cpp.
| void isam::SparseVector::_copy_from | ( | const SparseVector & | vec | ) | [private] |
Copy data from one sparse vector to a new one - private
| vec | Existing sparse vector to copy from. |
Definition at line 48 of file SparseVector.cpp.
| void isam::SparseVector::_dealloc | ( | ) | [private] |
Deallocate memory - private.
Definition at line 58 of file SparseVector.cpp.
| void isam::SparseVector::_resize | ( | int | new_nnz_max | ) | [private] |
Resize the sparse vector - dangerous, only used internally - private.
| new_nnz_max | New size of vector. |
Definition at line 102 of file SparseVector.cpp.
| int isam::SparseVector::_search | ( | int | idx | ) | const [private] |
Search for an index - private;
Definition at line 69 of file SparseVector.cpp.
| void isam::SparseVector::add_entries | ( | int | num, |
| int | pos | ||
| ) |
Shift indices starting at pos by offset.
| num | Number of new entries. |
| pos | First index that should be shifted. |
Definition at line 287 of file SparseVector.cpp.
| void isam::SparseVector::append | ( | int | idx, |
| const double | val = 0. |
||
| ) | [inline] |
Create a new entry at the end of the sparse vector. Used for efficient incremental creation of SparseVector in apply_givens().
| idx | Index of entry to add, has to be greater than last_idx(). |
| val | Value of new entry. |
Definition at line 130 of file SparseVector.h.
| void isam::SparseVector::copy_raw | ( | int * | indices, |
| double * | values | ||
| ) | const |
Copy raw data, useful for converting to Matlab format.
| indices | Destination for row indices. |
| values | Destination for values. |
Definition at line 192 of file SparseVector.cpp.
| int isam::SparseVector::first | ( | ) | const |
Find index of first non-zero entry.
Definition at line 271 of file SparseVector.cpp.
| int isam::SparseVector::last | ( | ) | const |
Find index of last non-zero entry
Definition at line 279 of file SparseVector.cpp.
| int isam::SparseVector::nnz | ( | ) | const [inline] |
Definition at line 192 of file SparseVector.h.
| double isam::SparseVector::operator() | ( | int | idx | ) | const |
Access value of an entry.
| idx | Index of entry to access. |
Definition at line 182 of file SparseVector.cpp.
| const SparseVector & isam::SparseVector::operator= | ( | const SparseVector & | vec | ) |
Assignment operator (see also copy constructor).
| vec | Right-hand-side vector in assignment |
Definition at line 166 of file SparseVector.cpp.
| void isam::SparseVector::print | ( | ) | const |
Prints contents of vector as a list of tuples.
Definition at line 295 of file SparseVector.cpp.
| void isam::SparseVector::remove | ( | int | idx | ) |
Remove an entry; simply ignores non-existing entries.
| idx | Index of entry to remove. |
Definition at line 247 of file SparseVector.cpp.
| bool isam::SparseVector::set | ( | int | idx, |
| const double | val = 0. |
||
| ) |
Assign a value to a specific entry.
| idx | Index of entry to assign to. |
| val | Value to assign. |
Definition at line 197 of file SparseVector.cpp.
| bool isam::SparseVector::set | ( | int | idx, |
| const Eigen::VectorXd & | vals | ||
| ) |
Assign a value to a specific entry.
| idx | Index of entry to assign to. |
| vals | Vector of values to assign. |
| c | Number of values in double array val. |
friend class SparseVectorIter [friend] |
Definition at line 196 of file SparseVector.h.
int* isam::SparseVector::_indices [private] |
Definition at line 39 of file SparseVector.h.
int isam::SparseVector::_nnz [private] |
Definition at line 37 of file SparseVector.h.
int isam::SparseVector::_nnz_max [private] |
Definition at line 38 of file SparseVector.h.
double* isam::SparseVector::_values [private] |
Definition at line 40 of file SparseVector.h.