Public Member Functions | Private Member Functions | Private Attributes | Friends
isam::SparseVector Class Reference

#include <SparseVector.h>

List of all members.

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

Detailed Description

Definition at line 36 of file SparseVector.h.


Constructor & Destructor Documentation

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.

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::_copy_from ( const SparseVector vec) [private]

Copy data from one sparse vector to a new one - private

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

Parameters:
new_nnz_maxNew size of vector.

Definition at line 102 of file SparseVector.cpp.

int isam::SparseVector::_search ( int  idx) const [private]

Search for an index - private;

Returns:
Index of entry, or if not in list, index of preceding entry + 1.

Definition at line 69 of file SparseVector.cpp.

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.

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.

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

Friends And Related Function Documentation

friend class SparseVectorIter [friend]

Definition at line 196 of file SparseVector.h.


Member Data Documentation

Definition at line 39 of file SparseVector.h.

int isam::SparseVector::_nnz [private]

Definition at line 37 of file SparseVector.h.

Definition at line 38 of file SparseVector.h.

double* isam::SparseVector::_values [private]

Definition at line 40 of file SparseVector.h.


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


demo_rgbd
Author(s): Ji Zhang
autogenerated on Tue Mar 3 2015 18:01:08