aimstil  5.0.5
sparse_vector_operators.h File Reference
#include <boost/call_traits.hpp>
Include dependency graph for sparse_vector_operators.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 til
 Belongs to package Box Do not include directly, include til/Box.h instead.
 

Macros

#define TIL_DEFINE_SPARSE_OP(op)
 

Functions

 til::TIL_DEFINE_SPARSE_OP (+)
 
 til::TIL_DEFINE_SPARSE_OP (-)
 

Macro Definition Documentation

◆ TIL_DEFINE_SPARSE_OP

#define TIL_DEFINE_SPARSE_OP (   op)
Value:
template < typename T > \
sparse_vector<T> \
operator op (const sparse_vector<T> & a, typename boost::call_traits<T>::param_type value) \
{ \
sparse_vector<T> res(a.size()); \
typename sparse_vector<T>::Map::const_iterator i = a.getMap().begin(); \
typename sparse_vector<T>::Map::const_iterator end = a.getMap().end(); \
for (; i != end; ++i) \
{ \
res[i->first] = i->second op value; \
} \
return res; \
} \
\
template < typename T > \
sparse_vector<T> \
operator op (typename boost::call_traits<T>::param_type value, const sparse_vector<T> & a) \
{ \
sparse_vector<T> res(a.size()); \
typename sparse_vector<T>::Map::const_iterator i = a.getMap().begin(); \
typename sparse_vector<T>::Map::const_iterator end = a.getMap().end(); \
for (; i != end; ++i) \
{ \
res[i->first] = value op i->second; \
} \
return res; \
} \

Definition at line 14 of file sparse_vector_operators.h.