 Timestamp:
 Apr 25, 2008, 12:07:57 AM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/stl_utility.h
r1275 r1288 37 37 38 38 #include <algorithm> 39 #include <cmath> 39 40 #include <functional> 40 41 #include <ostream> … … 117 118 return compose_f_gx_hy<F,G,H>(f,g,h); 118 119 } 120 121 /** 122 Functor class to exponentiate values using std::exp 123 */ 124 template<typename T> 125 struct Exp : std::unary_function<T, T> 126 { 127 /** 128 \return absolute value 129 */ 130 inline T operator()(T x) const 131 { return std::exp(x); } 132 }; 133 134 /** 135 Functor class to take logarithm 136 */ 137 template<typename T> 138 class Log : std::unary_function<T, T> 139 { 140 public: 141 /** 142 Default constructor using natural base \f$ e \f$ 143 */ 144 Log(void) 145 : log_base_(1.0) {} 146 147 /** 148 \param base Taking logarithm in which base, e.g. 2 or 10. 149 */ 150 explicit Log(double base) : log_base_(std::log(base)) {} 151 152 /** 153 \return absolute value 154 */ 155 inline T operator()(T x) const 156 { return std::log(x)/log_base_; } 157 158 private: 159 double log_base_; 160 }; 119 161 120 162 /**
Note: See TracChangeset
for help on using the changeset viewer.