aimstil  5.0.5
sparse_vector_tools.h
Go to the documentation of this file.
1 #ifndef SPARSE_VECTOR_TOOLS_H_
2 #define SPARSE_VECTOR_TOOLS_H_
3 
6 
7 namespace til
8 {
14 // template < typename T >
15 // bool is_nan(const sparse_vector<T> & a)
16 // {
17 // typename sparse_vector<T>::Map::const_iterator i = a.getMap().begin();
18 // typename sparse_vector<T>::Map::const_iterator end = a.getMap().end();
19 // for (; i != end; ++i)
20 // {
21 // if (is_nan(i->second)) return true;
22 // }
23 // return false;
24 // }
25 // template < typename T >
26  inline bool is_nan(const sparse_vector<double> & a)
27  {
28  for (sparse_vector<double>::Map::const_iterator i = a.getMap().begin(); i != a.getMap().end(); ++i)
29  {
30  if (is_nan(i->second)) return true;
31  }
32  return false;
33  }
34 } // namespace til
35 
36 #endif /*SPARSE_VECTOR_TOOLS_H_*/
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
A class that mimic the behavior of std::vector but with a storage policy focused on sparse data...
Map & getMap()
Returns the internal data.
bool is_nan(const numeric_array< T, D > &a)
Check that numeric_array does not contain any NAN TODO: Actually, is_nan should be a functor...