Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:58:43

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/util/detail/less_with_sign.hpp
0004 
0005  [begin_description]
0006  Helper function to compare times taking into account the sign of dt
0007  [end_description]
0008 
0009  Copyright 2012-2015 Mario Mulansky
0010  Copyright 2012 Karsten Ahnert
0011 
0012  Distributed under the Boost Software License, Version 1.0.
0013  (See accompanying file LICENSE_1_0.txt or
0014  copy at http://www.boost.org/LICENSE_1_0.txt)
0015  */
0016 
0017 #ifndef BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_LESS_WITH_SIGN_HPP_INCLUDED
0018 #define BOOST_NUMERIC_ODEINT_INTEGRATE_DETAIL_LESS_WITH_SIGN_HPP_INCLUDED
0019 
0020 #include <limits>
0021 
0022 #include <boost/numeric/odeint/util/unit_helper.hpp>
0023 
0024 namespace boost {
0025 namespace numeric {
0026 namespace odeint {
0027 namespace detail {
0028 
0029 /**
0030  * return t1 < t2 if dt > 0 and t1 > t2 if dt < 0 with epsilon accuracy
0031  */
0032 template< typename T >
0033 bool less_with_sign( T t1 , T t2 , T dt )
0034 {
0035     if( get_unit_value(dt) > 0 )
0036         //return t1 < t2;
0037         return t2-t1 > std::numeric_limits<T>::epsilon();
0038     else
0039         //return t1 > t2;
0040         return t1-t2 > std::numeric_limits<T>::epsilon();
0041 }
0042 
0043 /**
0044  * return t1 <= t2 if dt > 0 and t1 => t2 if dt < 0 with epsilon accuracy
0045  */
0046 template< typename T >
0047 bool less_eq_with_sign( T t1 , T t2 , T dt )
0048 {
0049     if( get_unit_value(dt) > 0 )
0050         return t1-t2 <= std::numeric_limits<T>::epsilon();
0051     else
0052         return t2-t1 <= std::numeric_limits<T>::epsilon();
0053 }
0054 
0055 template< typename T >
0056 T min_abs( T t1 , T t2 )
0057 {
0058     BOOST_USING_STD_MIN();
0059     BOOST_USING_STD_MAX();
0060     if( get_unit_value(t1)>0 )
0061         return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
0062     else
0063         return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
0064 }
0065 
0066 template< typename T >
0067 T max_abs( T t1 , T t2 )
0068 {
0069     BOOST_USING_STD_MIN();
0070     BOOST_USING_STD_MAX();
0071     if( get_unit_value(t1)>0 )
0072         return max BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
0073     else
0074         return min BOOST_PREVENT_MACRO_SUBSTITUTION ( t1 , t2 );
0075 }
0076 } } } }
0077 
0078 #endif