Public Member Functions | |
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 () |
const SparseVector & | operator= (const SparseVector &vec) |
double | operator() (int idx) const |
void | copy_raw (int *indices, double *values) const |
void | append (int idx, const double val=0.) |
bool | set (int idx, const double val=0.) |
bool | set (int idx, const Eigen::VectorXd &vals) |
void | remove (int idx) |
int | first () const |
int | last () const |
void | add_entries (int num, int pos) |
void | print () const |
int | nnz () const |
Friends | |
class | SparseVectorIter |
Definition at line 36 of file SparseVector.h.
Standard constructor.
Definition at line 114 of file SparseVector.cpp.
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::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.
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. |