forward declarations
Class SparseVector. This class is designed to present an interface nearly identical to class Vector, but more efficiently handle sparse vectors, in which most of the elements are zero. The class stores only non-zero elements in a map with key = index; it also stores a nominal length. The class uses a proxy class, SVecProxy, to access elements; this allows rvalues and lvalues to be treated separately.
Definition at line 60 of file SparseVector.hpp.
#include <SparseVector.hpp>
Public Member Functions | |
void | addScaledSparseVector (const T &a, const SparseVector< T > &SV) |
void | clear () |
clear - set all data to 0 (i.e. remove all data); leave length alone More... | |
unsigned int | datasize () const |
datasize - number of non-zero data More... | |
double | density () const |
density - ratio of number of non-zero element to size() More... | |
std::string | dump (const int p=3, bool dosci=false) const |
Dump only non-zero values, with indexes (i,value) More... | |
bool | isEmpty () const |
is this SV empty? NB may have to call zeroize() to get a yes. More... | |
bool | isFilled (const unsigned int i) const |
true if the element is non-zero More... | |
operator Vector< T > () const | |
cast to Vector or implicit conversion to Matrix<T> More... | |
SparseVector< T > & | operator*= (const T &value) |
SparseVector< T > & | operator+= (const SparseVector< T > &SV) |
SparseVector< T > & | operator+= (const Vector< T > &SV) |
SparseVector< T > | operator- () const |
SparseVector< T > & | operator-= (const SparseVector< T > &SV) |
SparseVector< T > & | operator-= (const Vector< T > &SV) |
SparseVector< T > & | operator/= (const T &value) |
SVecProxy< T > | operator[] (unsigned int in) |
operator[] for non-const, but SVecProxy does all the work More... | |
const SVecProxy< T > | operator[] (unsigned int in) const |
operator[] for const, but SVecProxy does all the work More... | |
void | resize (const unsigned int newlen) |
resize - remove elements (truncate) and change nominal length len More... | |
unsigned int | size () const |
size - of the real Vector, not the data array More... | |
SparseVector () | |
empty constructor More... | |
SparseVector (const SparseVector< T > &SV, const unsigned int &ind, const unsigned int &len) | |
SparseVector (const unsigned int N) | |
constructor with length More... | |
SparseVector (const Vector< T > &V) | |
constructor from regular Vector<T> More... | |
T | sum (const SparseVector< T > &SV) const |
Sum of elements. More... | |
void | truncate (const unsigned int n) |
void | zeroize (const T tol=static_cast< T >(zeroTolerance)) |
Static Public Attributes | |
static const double | zeroTolerance = 1.0e-14 |
Private Member Functions | |
std::vector< unsigned int > | getIndexes () const |
Private Attributes | |
unsigned int | len |
std::map< unsigned int, T > | vecMap |
map of index,value pairs; vecMap[index in real vector] = data element More... | |
|
inline |
empty constructor
Definition at line 348 of file SparseVector.hpp.
|
inline |
constructor with length
Definition at line 351 of file SparseVector.hpp.
gnsstk::SparseVector< T >::SparseVector | ( | const Vector< T > & | V | ) |
constructor from regular Vector<T>
Definition at line 592 of file SparseVector.hpp.
gnsstk::SparseVector< T >::SparseVector | ( | const SparseVector< T > & | SV, |
const unsigned int & | ind, | ||
const unsigned int & | len | ||
) |
subvector constructor
SV | SparseVector to copy |
ind | starting index for the copy |
len | length of new SparseVector |
Definition at line 611 of file SparseVector.hpp.
void gnsstk::SparseVector< T >::addScaledSparseVector | ( | const T & | a, |
const SparseVector< T > & | SV | ||
) |
Definition at line 1061 of file SparseVector.hpp.
|
inline |
clear - set all data to 0 (i.e. remove all data); leave length alone
Definition at line 415 of file SparseVector.hpp.
|
inline |
datasize - number of non-zero data
Definition at line 374 of file SparseVector.hpp.
|
inline |
density - ratio of number of non-zero element to size()
Definition at line 383 of file SparseVector.hpp.
|
inline |
Dump only non-zero values, with indexes (i,value)
Definition at line 458 of file SparseVector.hpp.
|
inlineprivate |
return a vector containing all the indexes, in order, of non-zero elements.
Definition at line 518 of file SparseVector.hpp.
|
inline |
is this SV empty? NB may have to call zeroize() to get a yes.
Definition at line 377 of file SparseVector.hpp.
|
inline |
true if the element is non-zero
Definition at line 426 of file SparseVector.hpp.
gnsstk::SparseVector< T >::operator Vector< T > |
cast to Vector or implicit conversion to Matrix<T>
Definition at line 640 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator*= | ( | const T & | value | ) |
Definition at line 1095 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator+= | ( | const SparseVector< T > & | SV | ) |
Definition at line 1004 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator+= | ( | const Vector< T > & | SV | ) |
Definition at line 1030 of file SparseVector.hpp.
|
inline |
Definition at line 492 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator-= | ( | const SparseVector< T > & | SV | ) |
Definition at line 948 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator-= | ( | const Vector< T > & | SV | ) |
Definition at line 974 of file SparseVector.hpp.
SparseVector< T > & gnsstk::SparseVector< T >::operator/= | ( | const T & | value | ) |
Definition at line 1115 of file SparseVector.hpp.
|
inline |
operator[] for non-const, but SVecProxy does all the work
Definition at line 445 of file SparseVector.hpp.
|
inline |
operator[] for const, but SVecProxy does all the work
Definition at line 433 of file SparseVector.hpp.
|
inline |
resize - remove elements (truncate) and change nominal length len
Definition at line 408 of file SparseVector.hpp.
|
inline |
size - of the real Vector, not the data array
Definition at line 371 of file SparseVector.hpp.
|
inline |
Sum of elements.
Definition at line 472 of file SparseVector.hpp.
|
inline |
truncate - removes elements, if necessary, at and beyond column index j same as resize(n) but does not change the nominal length len.
Definition at line 392 of file SparseVector.hpp.
void gnsstk::SparseVector< T >::zeroize | ( | const T | tol = static_cast<T>(zeroTolerance) | ) |
zeroize - remove elements that are less than or equal to tolerance in abs value. Called with a non-zero tolerance only by the user. NB this class and SparseMatrix call this when constructing a new object, e.g. after matrix multiply, but ONLY with the tolerance T(0).
Definition at line 656 of file SparseVector.hpp.
|
friend |
Definition at line 736 of file SparseVector.hpp.
|
friend |
Definition at line 758 of file SparseVector.hpp.
|
friend |
Definition at line 780 of file SparseVector.hpp.
|
friend |
dot (SparseVector, SparseVector)
Definition at line 789 of file SparseVector.hpp.
|
friend |
dot (SparseVector, Vector)
Definition at line 858 of file SparseVector.hpp.
|
friend |
dot (Vector, SparseVector)
Definition at line 874 of file SparseVector.hpp.
|
friend |
dot (SparseVector, SparseVector) but only use indexes k=kb, k<ke
Definition at line 820 of file SparseVector.hpp.
|
friend |
Compute the identity matrix of dimension dim x dim
dim | dimension of desired identity matrix (dim x dim) |
Definition at line 1776 of file SparseMatrix.hpp.
|
friend |
inverse (via Gauss-Jordan)
Exception | inverse via Gauss-Jordan; NB GJ involves only row operations. NB not the best numerically; for high condition number, use inverseViaCholesky, or cast to Matrix, use either LUD or SVD, then cast back to SparseMatrix. |
Exception |
Definition at line 1890 of file SparseMatrix.hpp.
|
friend |
Compute inverse of lower-triangular SparseMatrix.
inverseLT
Definition at line 2154 of file SparseMatrix.hpp.
|
friend |
Exception | Compute lower triangular square root of a symmetric positive definite matrix (Cholesky decomposition) Crout algorithm. |
A | SparseMatrix to be decomposed; symmetric and positive definite, const |
if | input SparseMatrix is not square |
if | input SparseMatrix is not positive definite |
Exception |
Definition at line 2065 of file SparseMatrix.hpp.
|
friend |
Definition at line 895 of file SparseVector.hpp.
|
friend |
Definition at line 927 of file SparseVector.hpp.
|
friend |
Definition at line 879 of file SparseVector.hpp.
|
friend |
Definition at line 911 of file SparseVector.hpp.
|
friend |
Definition at line 705 of file SparseVector.hpp.
|
friend |
lots of friends
|
friend |
Matrix multiply: SparseMatrix = Matrix * SparseMatrix.
Definition at line 1270 of file SparseMatrix.hpp.
|
friend |
Matrix multiply: SparseMatrix = SparseMatrix * Matrix.
Definition at line 1225 of file SparseMatrix.hpp.
|
friend |
Matrix multiply: SparseMatrix = SparseMatrix * SparseMatrix.
Definition at line 1186 of file SparseMatrix.hpp.
|
friend |
Matrix,Vector multiply: SparseVector = SparseMatrix * SparseVector.
Definition at line 996 of file SparseMatrix.hpp.
|
friend |
Matrix,Vector multiply: SparseVector = SparseMatrix * Vector.
Definition at line 1056 of file SparseMatrix.hpp.
|
friend |
Definition at line 1182 of file SparseVector.hpp.
|
friend |
Definition at line 1198 of file SparseVector.hpp.
|
friend |
Definition at line 1214 of file SparseVector.hpp.
|
friend |
Definition at line 1133 of file SparseVector.hpp.
|
friend |
Definition at line 1149 of file SparseVector.hpp.
|
friend |
Definition at line 1165 of file SparseVector.hpp.
|
friend |
Definition at line 1343 of file SparseMatrix.hpp.
|
friend |
Concatenation SparseMatrix || Vector TD the rest of them...
Definition at line 1313 of file SparseMatrix.hpp.
|
friend |
Householder transformation of a matrix.
Exception |
Definition at line 2297 of file SparseMatrix.hpp.
|
friend |
Definition at line 273 of file SparseVector.hpp.
|
friend |
Exception | Square root information measurement update, with new data in the form of a single SparseMatrix concatenation of H and D: A = H || D. See doc for the overloaded SrifMU(). |
Definition at line 2467 of file SparseMatrix.hpp.
|
friend |
Exception |
Definition at line 2627 of file SparseMatrix.hpp.
|
friend |
Proxy needs access to vecMap.
Definition at line 272 of file SparseVector.hpp.
|
friend |
Exception |
|
friend |
Compute diagonal of P*C*P^T, ie diagonal of transform of square Matrix C.
diag of P * C * PT
Exception |
Definition at line 1836 of file SparseMatrix.hpp.
|
friend |
transpose
Definition at line 829 of file SparseMatrix.hpp.
|
private |
length of the "real" vector (not the number of data stored = vecMap.size())
Definition at line 509 of file SparseVector.hpp.
|
private |
map of index,value pairs; vecMap[index in real vector] = data element
Definition at line 512 of file SparseVector.hpp.
|
static |
tolerance in considering element to be zero is std::abs(elem) < tolerance see zeroize(), where this is the default input value
Definition at line 345 of file SparseVector.hpp.