Changeset 2867
- Timestamp:
- Nov 12, 2012, 1:40:23 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/utility.cc
r2857 r2867 196 196 197 197 test_compose_functors(suite); 198 199 double x = 8.0; 200 suite.add(suite.equal(utility::log2(x), 3.0)); 201 float xf = x; 202 suite.add(suite.equal(utility::log2(xf), 3.0)); 203 long double xld = 8.0; 204 suite.add(suite.equal(utility::log2(xld), 3.0)); 198 205 199 206 return suite.return_value(); -
trunk/yat/utility/utility.h
r2820 r2867 1 1 #ifndef _theplu_yat_utility_utility_ 2 #define _theplu_yat_utility_utility_ 2 #define _theplu_yat_utility_utility_ 3 3 4 4 // $Id$ … … 35 35 #include "Exception.h" 36 36 #include "yat_assert.h" 37 38 #include <gsl/gsl_math.h> 37 39 38 40 #include <algorithm> … … 194 196 template<typename T> 195 197 void load(std::istream& is, std::vector<T>& vec, char sep='\0'); 196 198 199 /** 200 \return base-2 logarithm of x 201 202 \since New in yat 0.10 203 */ 204 // c++11 provides std::log2 so perhaps we should call that one if 205 // availalable (but a bit tricky since this is a public header) 206 template<typename T> 207 T log2(T x) { return std::log(x)/M_LN2; } 208 197 209 // private namespace 198 210 namespace detail {
Note: See TracChangeset
for help on using the changeset viewer.