1 #ifndef _utl_SparseMatrix_h_
2 #define _utl_SparseMatrix_h_
7 #include <boost/lambda/lambda.hpp>
35 template<
typename T =
double>
79 typedef std::map<IndexKeyType, T>
MapType;
86 template<
class IteratorType,
typename ValueType>
120 (*
this)(
it.GetRow(),
it.GetColumn()) =
it();
165 unsigned int erased = 0;
246 (*
this)(it.GetRow(), it.GetColumn()) +=
it();
257 (*
this)(it.GetRow(), it.GetColumn()) -=
it();
289 template<
typename T,
typename U>
290 typename boost::lambda::return_type_2<
291 boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
297 typedef typename boost::lambda::return_type_2<
298 boost::lambda::arithmetic_action<boost::lambda::multiply_action>,
301 >::type ResultMatrix;
314 c(i, j) += aIt() * bIt();
325 template<
class Stream,
typename T>
327 operator<<(Stream& s, const SparseMatrix<T>&
m)
344 template<
class Stream,
typename T,
typename SparseType>
350 const char separator,
const SparseType& sparse)
353 for (Index i = 0; i < rows; ++i) {
358 for (Index j = 1; j < columns; ++j) {
371 template<
class Stream,
typename T>
383 template<
class Stream,
typename T>
390 const char separator =
' ')
404 template<
typename T,
typename U>
405 class plain_return_type_2<
406 arithmetic_action<multiply_action>,
407 utl::SparseMatrix<T>,
414 arithmetic_action<multiply_action>,
428 #include <utl/SparseMatrixVectorOp.h>
Stream & OutputSparse(Stream &s, const SparseMatrix< T > &m, const typename SparseMatrix< T >::IndexType rows, const typename SparseMatrix< T >::IndexType columns, const char separator, const SparseType &sparse)
bool operator==(const SparseMatrix &m) const
be sure to call Reclaim() first
ConstIterator SparseEnd() const
IteratorTransformer< MapConstIterator, const T > ConstIterator
SparseMatrix & operator-=(const SparseMatrix< U > &m)
matrix subtraction
bool operator==(const Index &i) const
unsigned int GetNonEmptySize() const
friend class SparseMatrix
const T & operator[](const IndexType column) const
void Transpose()
in-situ transpose
MapType::value_type MapValueType
IteratorTransformer< MapIterator, T > Iterator
Sparse container class for matrix data.
IndexType GetColumn() const
Row(const SparseMatrix &m, const IndexType row)
const T & operator()(const IndexType row, const IndexType column) const
noncreational () access for const
SparseMatrix & operator*=(const U &value)
multiplication with scalar
MapType::const_iterator MapConstIterator
SparseMatrix::Row operator[](const IndexType row) const
noncreational [] access trough proxy
T & operator()(const IndexType row, const IndexType column)
creational () access
ConstIterator Find(const IndexType row, const IndexType column) const
Vector operator*(const double d, const Vector &v)
Index(const IndexType row, const IndexType column)
utl::SparseMatrix< res_type > type
void Erase(const MapIterator it)
bool operator!=(const SparseMatrix< U > &m) const
MapType::iterator MapIterator
std::map< IndexKeyType, T > MapType
SparseMatrix< T >::Index IndexKeyType
bool operator!=(const SparseMatrix &m) const
be sure to call Reclaim() first
const SparseMatrix & fSparseMatrix
Iterator Find(const IndexType row, const IndexType column)
SparseMatrix & operator+=(const SparseMatrix< U > &m)
matrix addition
return_type_2< arithmetic_action< multiply_action >, T, U >::type res_type
ConstIterator SparseBegin() const
Stream & Output(Stream &s, const SparseMatrix< T > &m, const typename SparseMatrix< T >::IndexType rows, const typename SparseMatrix< T >::IndexType columns, const char separator= ' ')
bool operator<(const Index &i) const
const T & GetInitializer() const
bool operator==(const SparseMatrix< U > &m) const