Changeset 1789 for trunk/yat/utility/utility.h
- Timestamp:
- Feb 10, 2009, 5:11:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/utility.h
r1500 r1789 34 34 #include "deprecate.h" 35 35 36 #include <cmath> 36 37 #include <limits> 37 38 #include <string> … … 45 46 namespace utility { 46 47 47 class Matrix; 48 /** 49 For each element in resulting range assign it to 0.0 if 50 corresponding element in input range is NaN else assign it to 51 1.0. 52 53 \since New in yat 0.5 54 */ 55 struct BinaryWeight 56 { 57 /** 58 \return true if there is at least one NaN in input range 59 [first, last). 60 */ 61 template<typename InputIterator, typename OutputIterator> 62 bool operator()(InputIterator first, InputIterator last, 63 OutputIterator result) const; 64 }; 65 48 66 49 67 /** … … 99 117 bool is_nan(const std::string& s); 100 118 119 120 template<typename InputIterator, typename OutputIterator> 121 bool BinaryWeight::operator()(InputIterator first, InputIterator last, 122 OutputIterator result) const 123 { 124 bool nan=false; 125 while (first!=last) { 126 if (std::isnan(*first)) { 127 *result=0; 128 nan=true; 129 } 130 else 131 *result = 1.0; 132 ++first; 133 ++result; 134 } 135 return nan; 136 } 137 138 101 139 // template implementations 102 140 template<typename T>
Note: See TracChangeset
for help on using the changeset viewer.