]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | [auto_generated] | |
3 | boost/numeric/odeint/util/detail/less_with_sign.hpp | |
4 | ||
5 | [begin_description] | |
6 | Helper function to compare times taking into account the sign of dt | |
7 | [end_description] | |
8 | ||
9 | Copyright 2012-2015 Mario Mulansky | |
10 | Copyright 2012 Karsten Ahnert | |
11 | ||
12 | Distributed under the Boost Software License, Version 1.0. | |
13 | (See accompanying file LICENSE_1_0.txt or | |
14 | copy at http://www.boost.org/LICENSE_1_0.txt) | |
15 | */ | |
16 | ||
17 | #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_LESS_WITH_SIGN_HPP_INCLUDED | |
18 | #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_LESS_WITH_SIGN_HPP_INCLUDED | |
19 | ||
20 | #include <limits> | |
21 | ||
22 | #include <boost/numeric/odeint/util/unit_helper.hpp> | |
23 | ||
24 | namespace boost { | |
25 | namespace numeric { | |
26 | namespace odeint { | |
27 | namespace detail { | |
28 | ||
29 | /** | |
30 | * return t1 < t2 if dt > 0 and t1 > t2 if dt < 0 with epsilon accuracy | |
31 | */ | |
32 | template< typename T > | |
33 | bool less_with_sign( T t1 , T t2 , T dt ) | |
34 | { | |
35 | if( get_unit_value(dt) > 0 ) | |
36 | //return t1 < t2; | |
37 | return t2-t1 > std::numeric_limits<T>::epsilon(); | |
38 | else | |
39 | //return t1 > t2; | |
40 | return t1-t2 > std::numeric_limits<T>::epsilon(); | |
41 | } | |
42 | ||
43 | /** | |
44 | * return t1 <= t2 if dt > 0 and t1 => t2 if dt < 0 with epsilon accuracy | |
45 | */ | |
46 | template< typename T > | |
47 | bool less_eq_with_sign( T t1 , T t2 , T dt ) | |
48 | { | |
49 | if( get_unit_value(dt) > 0 ) | |
50 | return t1-t2 <= std::numeric_limits<T>::epsilon(); | |
51 | else | |
52 | return t2-t1 <= std::numeric_limits<T>::epsilon(); | |
53 | } | |
54 | ||
55 | template< typename T > | |
56 | T min_abs( T t1 , T t2 ) | |
57 | { | |
58 | BOOST_USING_STD_MIN(); | |
59 | BOOST_USING_STD_MAX(); | |
60 | if( get_unit_value(t1)>0 ) | |
61 | return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 ); | |
62 | else | |
63 | return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 ); | |
64 | } | |
65 | ||
66 | template< typename T > | |
67 | T max_abs( T t1 , T t2 ) | |
68 | { | |
69 | BOOST_USING_STD_MIN(); | |
70 | BOOST_USING_STD_MAX(); | |
71 | if( get_unit_value(t1)>0 ) | |
72 | return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 ); | |
73 | else | |
74 | return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 ); | |
75 | } | |
76 | } } } } | |
77 | ||
78 | #endif |