iSAM
isam::SparseVector Class Reference

List of all members.

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 SparseVectoroperator= (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

Detailed Description

Definition at line 36 of file SparseVector.h.


Constructor & Destructor Documentation

Standard constructor.

Definition at line 114 of file SparseVector.cpp.

Copy constructor - note that overwriting operator= is also necessary!

Parameters:
vecSparseVector 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.

Parameters:
vecSparseVector to copy from.
numNumber of entries to copy (note sparse - most will not exist!)
firstIndex 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.

Parameters:
indicesArray of row indices.
valuesArray of values.
nnzLength of vector.

Definition at line 151 of file SparseVector.cpp.

Destructor.

Definition at line 162 of file SparseVector.cpp.


Member Function Documentation

void isam::SparseVector::add_entries ( int  num,
int  pos 
)

Shift indices starting at pos by offset.

Parameters:
numNumber of new entries.
posFirst 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().

Parameters:
idxIndex of entry to add, has to be greater than last_idx().
valValue 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.

Parameters:
indicesDestination for row indices.
valuesDestination for values.

Definition at line 192 of file SparseVector.cpp.

Find index of first non-zero entry.

Returns:
Index of first non-zero entry, or -1 if vector is empty.

Definition at line 271 of file SparseVector.cpp.

int isam::SparseVector::last ( ) const

Find index of last non-zero entry

Returns:
Index of last non-zero entry, or -1 if vector is empty.

Definition at line 279 of file SparseVector.cpp.

double isam::SparseVector::operator() ( int  idx) const

Access value of an entry.

Parameters:
idxIndex of entry to access.
Returns:
Value of entry.

Definition at line 182 of file SparseVector.cpp.

const SparseVector & isam::SparseVector::operator= ( const SparseVector vec)

Assignment operator (see also copy constructor).

Parameters:
vecRight-hand-side vector in assignment
Returns:
self.

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.

Parameters:
idxIndex 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.

Parameters:
idxIndex of entry to assign to.
valValue to assign.
Returns:
True if new entry had to be created (needed to update row index)

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.

Parameters:
idxIndex of entry to assign to.
valsVector of values to assign.
cNumber of values in double array val.
Returns:
True if new entries had to be created

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables