From bf53d040a6d75b60ea98b9426d1999d72ffa45ee Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sat, 27 Feb 2021 20:32:38 -0500 Subject: [PATCH 1/9] update pow4, pow7, min, max functions for ObjexxFCL:Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 373 ++++++++++++++++--- 1 file changed, 326 insertions(+), 47 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index ffd7922b8ee..075d916e37f 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -32,87 +32,147 @@ typedef std::intmax_t SSize; // min ///// // min( short, short ) -inline +/* + inline short int min( short int const a, short int const b ) { return ( a < b ? a : b ); +} */ +short int min(short int const x, short int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( int, int ) -inline +/* inline int min( int const a, int const b ) { return ( a < b ? a : b ); +} */ + +int min(int const x, int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( long, long ) -inline +/*inline long int min( long int const a, long int const b ) { return ( a < b ? a : b ); +} */ + +long int min(long int const x, long int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( unsigned short, unsigned short ) -inline +/* inline unsigned short int min( unsigned short int const a, unsigned short int const b ) { return ( a < b ? a : b ); +} */ + +unsigned short int min(unsigned short int const x, unsigned short int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( unsigned, unsigned ) -inline +/*inline unsigned int min( unsigned int const a, unsigned int const b ) { return ( a < b ? a : b ); +} */ + +unsigned int min(unsigned int const x, unsigned int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( unsigned long, unsigned long ) -inline +/*inline unsigned long int min( unsigned long int const a, unsigned long int const b ) { return ( a < b ? a : b ); } +*/ + +unsigned long int min(unsigned long int const x, unsigned long int const y) +{ + return y ^ ((x ^ y) & -(x < y)); +} + // min( float, float ) +/* inline float min( float const a, float const b ) { return ( a < b ? a : b ); } +*/ +float min(float const x, float const y) +{ + return y ^ ((x ^ y) & -(x < y)); +} // min( double, double ) +/* inline double min( double const a, double const b ) { return ( a < b ? a : b ); } +*/ +double min(double const x, double const y) +{ + return y ^ ((x ^ y) & -(x < y)); +} + // min( long double, long double ) -inline +/* + inline long double min( long double const a, long double const b ) { return ( a < b ? a : b ); } + */ + +long double min(long double const x, long double const y) +{ + return y ^ ((x ^ y) & -(x < y)); +} + + // Use std::min for 2 arguments not covered by the above overloads using std::min; // min( short, short, short ) +/* inline short int min( short int const a, short int const b, short int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); } +*/ +short int min(short int const x, short int const y, short int const z) +{ + return min(x, min(y,z)); +} // min( short, short, short, short, ... ) template< typename... Ts > @@ -124,11 +184,16 @@ min( short int const a, short int const b, short int const c, short int const d, } // min( int, int, int ) -inline +/* inline int min( int const a, int const b, int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +} */ + +int min(int x, int y, int z) +{ + return min(x, min(y,z)); } // min( int, int, int, int, ... ) @@ -141,11 +206,16 @@ min( int const a, int const b, int const c, int const d, Ts const &... o ) } // min( long, long, long ) -inline +/* inline long int min( long int const a, long int const b, long int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +} */ + +long int min(long int const x, long int const y, long int const z) +{ + return min(x, min(y,z)); } // min( long, long, long, long, ... ) @@ -158,12 +228,17 @@ min( long int const a, long int const b, long int const c, long int const d, Ts } // min( unsigned short, unsigned short, unsigned short ) -inline +/*inline unsigned short int min( unsigned short int const a, unsigned short int const b, unsigned short int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); } +*/ +unsigned short int min(unsigned short int const x, unsigned short int const y, unsigned short int const z) +{ + return min(x, min(y,z)); +} // min( unsigned short, unsigned short, unsigned short, unsigned short, ... ) template< typename... Ts > @@ -175,11 +250,15 @@ min( unsigned short int const a, unsigned short int const b, unsigned short int } // min( unsigned, unsigned, unsigned ) -inline +/*inline unsigned int min( unsigned int const a, unsigned int const b, unsigned int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +} */ +unsigned int min(unsigned int const x, unsigned int const y) +{ + return y ^ ((x ^ y) & -(x < y)); } // min( unsigned, unsigned, unsigned, unsigned, ... ) @@ -192,11 +271,15 @@ min( unsigned int const a, unsigned int const b, unsigned int const c, unsigned } // min( unsigned long, unsigned long, unsigned long ) -inline +/*inline unsigned long int min( unsigned long int const a, unsigned long int const b, unsigned long int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +} */ +unsigned long int min(unsigned long int const x, unsigned long int const y, unsigned long int const z) +{ + return min(x,min(y,z)); } // min( unsigned long, unsigned long, unsigned long, unsigned long, ... ) @@ -209,11 +292,16 @@ min( unsigned long int const a, unsigned long int const b, unsigned long int con } // min( float, float, float ) -inline +/* inline float min( float const a, float const b, float const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +}*/ + +float min(float const x, float const y, float const z) +{ + return min(x,min(y,z)); } // min( float, float, float, float, ... ) @@ -226,11 +314,16 @@ min( float const a, float const b, float const c, float const d, Ts const &... o } // min( double, double, double ) -inline +/*inline double min( double const a, double const b, double const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +}*/ + +double min(double const x, double const y, double const z) +{ + return min(x,min(y,z)); } // min( double, double, double, double, ... ) @@ -243,13 +336,19 @@ min( double const a, double const b, double const c, double const d, Ts const &. } // min( long double, long double, long double ) -inline +/* inline long double min( long double const a, long double const b, long double const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); +} */ + +long double min(long double const x, long double const y, long double const z) +{ + return min(x, min(y,z)); } + // min( long double, long double, long double, long double, ... ) template< typename... Ts > inline @@ -280,88 +379,150 @@ min( T const & a, T const & b, T const & c, T const & d, Ts const &... o ) // max ///// // max( short, short ) -inline +/* inline short int max( short int const a, short int const b ) { return ( a < b ? b : a ); +} */ + +short int max(short int const x, short int const y) +{ + return x ^ ((x ^ y) & -(x < y)); } // max( int, int ) -inline +/* inline int max( int const a, int const b ) { return ( a < b ? b : a ); +} */ + + int max( int const x, int const y) +{ + return x ^ ((x ^ y) & -(x < y)); } // max( long, long ) -inline +/*inline long int max( long int const a, long int const b ) { return ( a < b ? b : a ); +} */ + +long int max(long int const x, long int const y) +{ + return x ^ ((x ^ y) & -(x < y)); } + // max( unsigned short, unsigned short ) +/* inline unsigned short int max( unsigned short int const a, unsigned short int const b ) { return ( a < b ? b : a ); +} */ + +unsigned short int max(unsigned short int const x, unaigned short int const y) +{ + return x ^ ((x ^ y) & -(x < y)); } + // max( unsigned, unsigned ) +/* inline unsigned int max( unsigned int const a, unsigned int const b ) { return ( a < b ? b : a ); } +*/ + +unsigned int max(unsigned int x, unsigned int y) +{ + return x ^ ((x ^ y) & -(x < y)); +} + // max( unsigned long, unsigned long ) -inline +/* inline unsigned long int max( unsigned long int const a, unsigned long int const b ) { return ( a < b ? b : a ); +} */ + +unsigned long int max(unsigned long int const x, unsigned long int const y) +{ + return x ^ ((x ^ y) & -(x < y)); } + // max( float, float ) -inline +/* inline float max( float const a, float const b ) { return ( a < b ? b : a ); +} */ + +float max(float const x, float const y) +{ + return x ^ ((x ^ y) & -(x < y)); } + // max( double, double ) -inline +/*inline double max( double const a, double const b ) { return ( a < b ? b : a ); } +*/ + +double max(double const x, double const y) +{ + return x ^ ((x ^ y) & -(x < y)); +} + // max( long double, long double ) -inline +/*inline long double max( long double const a, long double const b ) { return ( a < b ? b : a ); +} */ + +long double max(long double const x, long double const y) +{ + return x ^ ((x ^ y) & -(x < y)); } + // Use std::max for 2 arguments not covered by the above overloads using std::max; // max( short, short, short ) -inline +/*inline short int max( short int const a, short int const b, short int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +short int max(short int const x, short int const y, short int const z) +{ + return max(x,max(y,z)); } + // max( short, short, short, short, ... ) template< typename... Ts > inline @@ -372,13 +533,19 @@ max( short int const a, short int const b, short int const c, short int const d, } // max( int, int, int ) -inline +/* inline int max( int const a, int const b, int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +int max( int const x, int const y, int const z) +{ + return max(x,max(y,z)); } + // max( int, int, int, int, ... ) template< typename... Ts > inline @@ -389,13 +556,20 @@ max( int const a, int const b, int const c, int const d, Ts const &... o ) } // max( long, long, long ) -inline +/*inline long int max( long int const a, long int const b, long int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + + +long int max(long int const x, long int const y, long int const z) +{ + return max(x,max(y,z)); } + // max( long, long, long, long, ... ) template< typename... Ts > inline @@ -406,11 +580,16 @@ max( long int const a, long int const b, long int const c, long int const d, Ts } // max( unsigned short, unsigned short, unsigned short ) -inline +/* inline unsigned short int max( unsigned short int const a, unsigned short int const b, unsigned short int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +unsigned short int max(unsigned short int const x, unsigned short int const y, unsigned short int const z) +{ + return max(x,max(y,z)); } // max( unsigned short, unsigned short, unsigned short, unsigned short, ... ) @@ -423,13 +602,19 @@ max( unsigned short int const a, unsigned short int const b, unsigned short int } // max( unsigned, unsigned, unsigned ) -inline +/* inline unsigned int max( unsigned int const a, unsigned int const b, unsigned int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +unsigned int max(unsigned int const x, unsigned int const y, unsigned int const z) +{ + return max(x,max(y,z)); } + // max( unsigned, unsigned, unsigned, unsigned, ... ) template< typename... Ts > inline @@ -440,13 +625,19 @@ max( unsigned int const a, unsigned int const b, unsigned int const c, unsigned } // max( unsigned long, unsigned long, unsigned long ) -inline +/* inline unsigned long int max( unsigned long int const a, unsigned long int const b, unsigned long int const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +unsigned long int max(unsigned long int const x, unsigned long int const y, unsigned long int const z) +{ + return max(x,max(y,z)); } + // max( unsigned long, unsigned long, unsigned long, unsigned long, ... ) template< typename... Ts > inline @@ -457,11 +648,16 @@ max( unsigned long int const a, unsigned long int const b, unsigned long int con } // max( float, float, float ) -inline +/* inline float max( float const a, float const b, float const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +float max(float const x, float const y, float const z) +{ + return max(x,max(y,z)); } // max( float, float, float, float, ... ) @@ -474,13 +670,19 @@ max( float const a, float const b, float const c, float const d, Ts const &... o } // max( double, double, double ) -inline +/* inline double max( double const a, double const b, double const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); +} */ + +double max(double const x, double const y, double const z) +{ + return max(x,max(y,z)); } + // max( double, double, double, double, ... ) template< typename... Ts > inline @@ -498,6 +700,12 @@ max( long double const a, long double const b, long double const c ) return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); } +long double max(long double const x, long double const y, long double const z) +{ + return max(x,max(y,z)); +} + + // max( long double, long double, long double, long double, ... ) template< typename... Ts > inline @@ -516,6 +724,8 @@ max( T const & a, T const & b, T const & c ) return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); } + + // max( a, b, c, d, ... ) template< typename T, typename... Ts > inline @@ -1078,24 +1288,34 @@ quad( T const x ) } // pow_2( x ) == x^2 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_2( T const x ) { return x * x; +} */ +double pow_2(double x) +{ + return 2^(2*log2(x)); } - // pow_3( x ) == x^3 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_3( T const x ) { return x * x * x; +} */ +double pow_3(double x) +{ + return 2^(3*log2(x)); + } -// pow_4( x ) == x^4 +//// pow_4( x ) == x^4 +/* template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T @@ -1103,10 +1323,18 @@ pow_4( T const x ) { T const t( x * x ); return t * t; +} */ + + +double pow_4 (float x) +{ + return 2^(4*log2(x)); } + // pow_5( x ) == x^5 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_5( T const x ) @@ -1114,18 +1342,26 @@ pow_5( T const x ) T const t( x * x ); return t * t * x; } +*/ // pow_6( x ) == x^6 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_6( T const x ) { T const t( x * x * x ); return t * t; +} */ + +double pow_6(float x) +{ + return return 2^(6*log2(x)); + } // pow_7( x ) == x^7 +/* template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T @@ -1134,9 +1370,14 @@ pow_7( T const x ) T const t( x * x * x ); return t * t * x; } + */ + double pow_7(float x) + { + return 2^(7*log2(x)) + } // pow_8( x ) == x^8 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_8( T const x ) @@ -1144,10 +1385,10 @@ pow_8( T const x ) T t( x * x ); t *= t; return t * t; -} +} */ // pow_9( x ) == x^9 -template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_9( T const x ) @@ -1155,6 +1396,8 @@ pow_9( T const x ) T const t( x * x * x ); return t * t * t; } +*/ + // root_4( x ) == x^(1/4) template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > @@ -1203,24 +1446,25 @@ quad( T const & x ) } // pow_2( x ) == x^2 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_2( T const & x ) { return x * x; -} +} */ // pow_3( x ) == x^3 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_3( T const & x ) { return x * x * x; -} +} */ // pow_4( x ) == x^4 +/* template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T @@ -1228,29 +1472,46 @@ pow_4( T const & x ) { T const t( x * x ); return t * t; +} */ + +double pow_4 (double x) +{ + return 2^(4*log2(x)); } // pow_5( x ) == x^5 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_5( T const & x ) { T const t( x * x ); return t * t * x; +} */ + +double pow_5(double x) +{ + return return 2^(5*log2(x)); + } // pow_6( x ) == x^6 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_6( T const & x ) { T const t( x * x * x ); return t * t; +} */ +double pow_6(double x) +{ + return return 2^(6*log2(x)); + } // pow_7( x ) == x^7 +/* template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T @@ -1259,9 +1520,15 @@ pow_7( T const & x ) T const t( x * x * x ); return t * t * x; } +*/ +double pow_7(double x) +{ + return return 2^(7*log2(x)); + +} // pow_8( x ) == x^8 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_8( T const & x ) @@ -1269,16 +1536,27 @@ pow_8( T const & x ) T t( x * x ); t *= t; return t * t; +} */ +double pow_8(double x) +{ + return return 2^(8*log2(x)); + } // pow_9( x ) == x^9 -template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +/* template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_9( T const & x ) { T const t( x * x * x ); return t * t * t; +} */ + +double pow_9(double x) +{ + return return 2^(9*log2(x)); + } // Tolerant Comparisons ///// @@ -1346,3 +1624,4 @@ gt_tol( T const & x, T const & y, T const & r_tol, T const & a_tol = T( 0 ) ) } // ObjexxFCL #endif // ObjexxFCL_Fmath_hh_INCLUDED + From c81f9d14399ac9ac66654829001fbc65bd0bc706 Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sat, 27 Feb 2021 21:09:07 -0500 Subject: [PATCH 2/9] update Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 075d916e37f..2b803b7d790 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -256,10 +256,13 @@ min( unsigned int const a, unsigned int const b, unsigned int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); } */ + +/* unsigned int min(unsigned int const x, unsigned int const y) { return y ^ ((x ^ y) & -(x < y)); } +*/ // min( unsigned, unsigned, unsigned, unsigned, ... ) template< typename... Ts > @@ -427,7 +430,7 @@ max( unsigned short int const a, unsigned short int const b ) return ( a < b ? b : a ); } */ -unsigned short int max(unsigned short int const x, unaigned short int const y) +unsigned short int max(unsigned short int const x, unsigned short int const y) { return x ^ ((x ^ y) & -(x < y)); } @@ -693,12 +696,14 @@ max( double const a, double const b, double const c, double const d, Ts const &. } // max( long double, long double, long double ) +/* inline long double max( long double const a, long double const b, long double const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); } +*/ long double max(long double const x, long double const y, long double const z) { @@ -1356,7 +1361,7 @@ pow_6( T const x ) double pow_6(float x) { - return return 2^(6*log2(x)); + return 2^(6*log2(x)); } @@ -1491,7 +1496,7 @@ pow_5( T const & x ) double pow_5(double x) { - return return 2^(5*log2(x)); + return 2^(5*log2(x)); } @@ -1506,7 +1511,7 @@ pow_6( T const & x ) } */ double pow_6(double x) { - return return 2^(6*log2(x)); + return 2^(6*log2(x)); } @@ -1523,7 +1528,7 @@ pow_7( T const & x ) */ double pow_7(double x) { - return return 2^(7*log2(x)); + return 2^(7*log2(x)); } @@ -1539,7 +1544,7 @@ pow_8( T const & x ) } */ double pow_8(double x) { - return return 2^(8*log2(x)); + return 2^(8*log2(x)); } @@ -1555,7 +1560,7 @@ pow_9( T const & x ) double pow_9(double x) { - return return 2^(9*log2(x)); + return 2^(9*log2(x)); } From a4dcdbbf7cde5ddf35b17e75dd2fdb95905a364f Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sat, 27 Feb 2021 22:36:25 -0500 Subject: [PATCH 3/9] update ObjexxFCL:Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 2b803b7d790..d18faaa7cd2 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -1481,7 +1481,7 @@ pow_4( T const & x ) double pow_4 (double x) { - return 2^(4*log2(x)); + return exp(4*log(x)); } // pow_5( x ) == x^5 @@ -1496,7 +1496,7 @@ pow_5( T const & x ) double pow_5(double x) { - return 2^(5*log2(x)); + return exp(5*log(x)); } @@ -1511,7 +1511,7 @@ pow_6( T const & x ) } */ double pow_6(double x) { - return 2^(6*log2(x)); + return exp(6*log(x)); } @@ -1528,7 +1528,7 @@ pow_7( T const & x ) */ double pow_7(double x) { - return 2^(7*log2(x)); + return exp(7*log(x)); } @@ -1544,7 +1544,7 @@ pow_8( T const & x ) } */ double pow_8(double x) { - return 2^(8*log2(x)); + return exp(8*log(x)); } @@ -1560,7 +1560,7 @@ pow_9( T const & x ) double pow_9(double x) { - return 2^(9*log2(x)); + return exp(9*log(x)); } From e01f71b75eb45404868b1381bdd0eb3af757e8e0 Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sat, 27 Feb 2021 22:38:34 -0500 Subject: [PATCH 4/9] update ObjexxFCL:Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index d18faaa7cd2..d114ec38352 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -1302,7 +1302,7 @@ pow_2( T const x ) } */ double pow_2(double x) { - return 2^(2*log2(x)); + return exp(2*log(x)); } // pow_3( x ) == x^3 /* @@ -1315,7 +1315,7 @@ pow_3( T const x ) } */ double pow_3(double x) { - return 2^(3*log2(x)); + return exp(3*log(x)); } @@ -1333,7 +1333,7 @@ pow_4( T const x ) double pow_4 (float x) { - return 2^(4*log2(x)); + return exp(4*log(x)); } @@ -1361,7 +1361,7 @@ pow_6( T const x ) double pow_6(float x) { - return 2^(6*log2(x)); + return exp(6*log(x)); } @@ -1378,7 +1378,7 @@ pow_7( T const x ) */ double pow_7(float x) { - return 2^(7*log2(x)) + return exp(7*log(x)) } // pow_8( x ) == x^8 From 65b33f509b75faa66a70e14bf64f0cac5f9c338e Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sat, 27 Feb 2021 22:41:44 -0500 Subject: [PATCH 5/9] update ObjexxFCL:Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index d114ec38352..09779170221 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -1378,7 +1378,7 @@ pow_7( T const x ) */ double pow_7(float x) { - return exp(7*log(x)) + return exp(7*log(x)); } // pow_8( x ) == x^8 From f0034c1334cd217db4d50af662e16e197e21cf33 Mon Sep 17 00:00:00 2001 From: Yanfei Date: Sun, 28 Feb 2021 08:53:28 -0500 Subject: [PATCH 6/9] update ObjexxFCL:Fmath.hh --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 56 ++++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 09779170221..57cd38b291e 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -29,6 +29,16 @@ namespace ObjexxFCL { typedef std::intmax_t SSize; +float myxor(float x, float y) +{ + unsigned long long* xPtr = (unsigned long long*)&x; + unsigned long long* yPtr = (unsigned long long*)&y; + unsigned long long uXor = (*xPtr) ^ (*yPtr); + float dXor = *((float*)&uXor); + return dXor; +} + + // min ///// // min( short, short ) @@ -112,49 +122,50 @@ unsigned long int min(unsigned long int const x, unsigned long int const y) // min( float, float ) -/* + inline float min( float const a, float const b ) { return ( a < b ? a : b ); } -*/ +/* float min(float const x, float const y) { - return y ^ ((x ^ y) & -(x < y)); -} + return y ^ ((x ^ y) & -(x < y)); +}*/ + // min( double, double ) -/* + inline double min( double const a, double const b ) { return ( a < b ? a : b ); } -*/ +/* double min(double const x, double const y) { return y ^ ((x ^ y) & -(x < y)); } - +*/ // min( long double, long double ) -/* + inline long double min( long double const a, long double const b ) { return ( a < b ? a : b ); } - */ - + +/* long double min(long double const x, long double const y) { return y ^ ((x ^ y) & -(x < y)); } - +*/ // Use std::min for 2 arguments not covered by the above overloads @@ -467,47 +478,48 @@ unsigned long int max(unsigned long int const x, unsigned long int const y) // max( float, float ) -/* inline + inline float max( float const a, float const b ) { return ( a < b ? b : a ); -} */ - +} +/* float max(float const x, float const y) { return x ^ ((x ^ y) & -(x < y)); } - +*/ // max( double, double ) -/*inline +inline double max( double const a, double const b ) { return ( a < b ? b : a ); } -*/ +/* double max(double const x, double const y) { return x ^ ((x ^ y) & -(x < y)); -} +}*/ + // max( long double, long double ) -/*inline +inline long double max( long double const a, long double const b ) { return ( a < b ? b : a ); -} */ - +} +/* long double max(long double const x, long double const y) { return x ^ ((x ^ y) & -(x < y)); } - +*/ // Use std::max for 2 arguments not covered by the above overloads using std::max; From 325e0ce89311cd6106a0429fa0689284003b859a Mon Sep 17 00:00:00 2001 From: Yanfei Date: Tue, 9 Mar 2021 21:25:03 -0500 Subject: [PATCH 7/9] update ObjexxFCL-Fmath --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 466 ++++++++++--------- 1 file changed, 253 insertions(+), 213 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 57cd38b291e..955773e29f3 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -28,7 +28,7 @@ namespace ObjexxFCL { typedef std::intmax_t SSize; - +/* float myxor(float x, float y) { unsigned long long* xPtr = (unsigned long long*)&x; @@ -36,89 +36,90 @@ float myxor(float x, float y) unsigned long long uXor = (*xPtr) ^ (*yPtr); float dXor = *((float*)&uXor); return dXor; -} +}*/ // min ///// // min( short, short ) -/* + inline short int min( short int const a, short int const b ) { - return ( a < b ? a : b ); -} */ + return ( b ^ ((a ^ b) & -(a < b)) ); +} +/* short int min(short int const x, short int const y) { return y ^ ((x ^ y) & -(x < y)); -} +}*/ // min( int, int ) -/* inline +inline int min( int const a, int const b ) { - return ( a < b ? a : b ); -} */ - + return ( b ^ ((a ^ b) & -(a < b)) ); +} +/* int min(int const x, int const y) { return y ^ ((x ^ y) & -(x < y)); -} +}*/ // min( long, long ) -/*inline +inline long int min( long int const a, long int const b ) { - return ( a < b ? a : b ); -} */ - + return ( b ^ ((a ^ b) & -(a < b)) ); +} +/* long int min(long int const x, long int const y) { return y ^ ((x ^ y) & -(x < y)); } - +*/ // min( unsigned short, unsigned short ) -/* inline +inline unsigned short int min( unsigned short int const a, unsigned short int const b ) { - return ( a < b ? a : b ); -} */ - + return (b ^ ((a ^ b) & -(a < b))); +} +/* unsigned short int min(unsigned short int const x, unsigned short int const y) { return y ^ ((x ^ y) & -(x < y)); -} +} */ // min( unsigned, unsigned ) -/*inline +inline unsigned int min( unsigned int const a, unsigned int const b ) { - return ( a < b ? a : b ); -} */ - + return ( b ^ ((a ^ b) & -(a < b)) ); +} +/* unsigned int min(unsigned int const x, unsigned int const y) { return y ^ ((x ^ y) & -(x < y)); -} +}*/ // min( unsigned long, unsigned long ) -/*inline +inline unsigned long int min( unsigned long int const a, unsigned long int const b ) { - return ( a < b ? a : b ); + return ( b ^ ((a ^ b) & -(a < b)) ); } -*/ +/* unsigned long int min(unsigned long int const x, unsigned long int const y) { return y ^ ((x ^ y) & -(x < y)); -} +}*/ // min( float, float ) @@ -172,18 +173,18 @@ long double min(long double const x, long double const y) using std::min; // min( short, short, short ) -/* + inline short int min( short int const a, short int const b, short int const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); + return ( min(a, min(b,c)) ); } -*/ +/* short int min(short int const x, short int const y, short int const z) { return min(x, min(y,z)); -} +}*/ // min( short, short, short, short, ... ) template< typename... Ts > @@ -195,17 +196,17 @@ min( short int const a, short int const b, short int const c, short int const d, } // min( int, int, int ) -/* inline +inline int min( int const a, int const b, int const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -} */ - + return ( min(a, min(b,c)) ); +} +/* int min(int x, int y, int z) { return min(x, min(y,z)); -} +}*/ // min( int, int, int, int, ... ) template< typename... Ts > @@ -217,17 +218,17 @@ min( int const a, int const b, int const c, int const d, Ts const &... o ) } // min( long, long, long ) -/* inline +inline long int min( long int const a, long int const b, long int const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -} */ - + return ( min(a, min(b,c)) ); +} +/* long int min(long int const x, long int const y, long int const z) { return min(x, min(y,z)); -} +}*/ // min( long, long, long, long, ... ) template< typename... Ts > @@ -239,17 +240,18 @@ min( long int const a, long int const b, long int const c, long int const d, Ts } // min( unsigned short, unsigned short, unsigned short ) -/*inline +inline unsigned short int min( unsigned short int const a, unsigned short int const b, unsigned short int const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); + return ( min(a, min(b,c))); } -*/ + +/* unsigned short int min(unsigned short int const x, unsigned short int const y, unsigned short int const z) { return min(x, min(y,z)); -} +}*/ // min( unsigned short, unsigned short, unsigned short, unsigned short, ... ) template< typename... Ts > @@ -261,12 +263,12 @@ min( unsigned short int const a, unsigned short int const b, unsigned short int } // min( unsigned, unsigned, unsigned ) -/*inline +inline unsigned int min( unsigned int const a, unsigned int const b, unsigned int const c ) { return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -} */ +} /* unsigned int min(unsigned int const x, unsigned int const y) @@ -285,16 +287,17 @@ min( unsigned int const a, unsigned int const b, unsigned int const c, unsigned } // min( unsigned long, unsigned long, unsigned long ) -/*inline +inline unsigned long int min( unsigned long int const a, unsigned long int const b, unsigned long int const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -} */ + return (min(a,min(b,c))); +} +/* unsigned long int min(unsigned long int const x, unsigned long int const y, unsigned long int const z) { return min(x,min(y,z)); -} +}*/ // min( unsigned long, unsigned long, unsigned long, unsigned long, ... ) template< typename... Ts > @@ -306,17 +309,17 @@ min( unsigned long int const a, unsigned long int const b, unsigned long int con } // min( float, float, float ) -/* inline +inline float min( float const a, float const b, float const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -}*/ - + return ( min(a, min(b,c)) ); +} +/* float min(float const x, float const y, float const z) { return min(x,min(y,z)); -} +}*/ // min( float, float, float, float, ... ) template< typename... Ts > @@ -328,17 +331,17 @@ min( float const a, float const b, float const c, float const d, Ts const &... o } // min( double, double, double ) -/*inline +inline double min( double const a, double const b, double const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -}*/ - + return ( min(a, min(b,c)) ); +} +/* double min(double const x, double const y, double const z) { return min(x,min(y,z)); -} +}*/ // min( double, double, double, double, ... ) template< typename... Ts > @@ -350,17 +353,17 @@ min( double const a, double const b, double const c, double const d, Ts const &. } // min( long double, long double, long double ) -/* inline +inline long double min( long double const a, long double const b, long double const c ) { - return ( a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ); -} */ - + return ( min(a, min(b,c)) ); +} +/* long double min(long double const x, long double const y, long double const z) { return min(x, min(y,z)); -} +}*/ // min( long double, long double, long double, long double, ... ) @@ -393,88 +396,88 @@ min( T const & a, T const & b, T const & c, T const & d, Ts const &... o ) // max ///// // max( short, short ) -/* inline +inline short int max( short int const a, short int const b ) { - return ( a < b ? b : a ); -} */ - + return ( a ^ ((a ^ b) & -(a < b)) ); +} +/* short int max(short int const x, short int const y) { return x ^ ((x ^ y) & -(x < y)); -} +}*/ // max( int, int ) -/* inline +inline int max( int const a, int const b ) { - return ( a < b ? b : a ); -} */ - + return ( a ^ ((a ^ b) & -(a < b)) ); +} +/* int max( int const x, int const y) { return x ^ ((x ^ y) & -(x < y)); -} +}*/ // max( long, long ) -/*inline +inline long int max( long int const a, long int const b ) { - return ( a < b ? b : a ); -} */ - + return ( a ^ ((a ^ b) & -(a < b)) ); +} +/* long int max(long int const x, long int const y) { return x ^ ((x ^ y) & -(x < y)); } - +*/ // max( unsigned short, unsigned short ) -/* + inline unsigned short int max( unsigned short int const a, unsigned short int const b ) { - return ( a < b ? b : a ); -} */ - + return ( a ^ ((a ^ b) & -(a < b)) ); +} +/* unsigned short int max(unsigned short int const x, unsigned short int const y) { return x ^ ((x ^ y) & -(x < y)); -} +}*/ // max( unsigned, unsigned ) -/* + inline unsigned int max( unsigned int const a, unsigned int const b ) { - return ( a < b ? b : a ); + return ( a^((a^b) & -(a @@ -548,17 +552,17 @@ max( short int const a, short int const b, short int const c, short int const d, } // max( int, int, int ) -/* inline +inline int max( int const a, int const b, int const c ) { - return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - + return ( max(a, max(b,c)) ); +} +/* int max( int const x, int const y, int const z) { return max(x,max(y,z)); -} +}*/ // max( int, int, int, int, ... ) @@ -571,18 +575,18 @@ max( int const a, int const b, int const c, int const d, Ts const &... o ) } // max( long, long, long ) -/*inline +inline long int max( long int const a, long int const b, long int const c ) { - return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - + return ( max(a, max(b,c)) ); +} +/* long int max(long int const x, long int const y, long int const z) { return max(x,max(y,z)); -} +}*/ // max( long, long, long, long, ... ) @@ -595,17 +599,17 @@ max( long int const a, long int const b, long int const c, long int const d, Ts } // max( unsigned short, unsigned short, unsigned short ) -/* inline +inline unsigned short int max( unsigned short int const a, unsigned short int const b, unsigned short int const c ) { - return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - + return ( max(a, max(b,c)) ); +} +/* unsigned short int max(unsigned short int const x, unsigned short int const y, unsigned short int const z) { return max(x,max(y,z)); -} +}*/ // max( unsigned short, unsigned short, unsigned short, unsigned short, ... ) template< typename... Ts > @@ -617,17 +621,17 @@ max( unsigned short int const a, unsigned short int const b, unsigned short int } // max( unsigned, unsigned, unsigned ) -/* inline + inline unsigned int max( unsigned int const a, unsigned int const b, unsigned int const c ) { - return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - + return ( max(a, max(b,c)) ); +} +/* unsigned int max(unsigned int const x, unsigned int const y, unsigned int const z) { return max(x,max(y,z)); -} +}*/ // max( unsigned, unsigned, unsigned, unsigned, ... ) @@ -640,18 +644,18 @@ max( unsigned int const a, unsigned int const b, unsigned int const c, unsigned } // max( unsigned long, unsigned long, unsigned long ) -/* inline + inline unsigned long int max( unsigned long int const a, unsigned long int const b, unsigned long int const c ) { - return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - + return ( max(a, max(b,c)) ); +} +/* unsigned long int max(unsigned long int const x, unsigned long int const y, unsigned long int const z) { return max(x,max(y,z)); } - +*/ // max( unsigned long, unsigned long, unsigned long, unsigned long, ... ) template< typename... Ts > @@ -663,17 +667,17 @@ max( unsigned long int const a, unsigned long int const b, unsigned long int con } // max( float, float, float ) -/* inline + inline float max( float const a, float const b, float const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ - +} +/* float max(float const x, float const y, float const z) { return max(x,max(y,z)); -} +}*/ // max( float, float, float, float, ... ) template< typename... Ts > @@ -685,17 +689,18 @@ max( float const a, float const b, float const c, float const d, Ts const &... o } // max( double, double, double ) -/* inline + inline double max( double const a, double const b, double const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); -} */ +} +/* double max(double const x, double const y, double const z) { return max(x,max(y,z)); -} +}*/ // max( double, double, double, double, ... ) @@ -708,19 +713,20 @@ max( double const a, double const b, double const c, double const d, Ts const &. } // max( long double, long double, long double ) -/* + inline long double max( long double const a, long double const b, long double const c ) { return ( a < b ? ( b < c ? c : b ) : ( a < c ? c : a ) ); } -*/ + +/* long double max(long double const x, long double const y, long double const z) { return max(x,max(y,z)); -} +}*/ // max( long double, long double, long double, long double, ... ) @@ -1305,115 +1311,128 @@ quad( T const x ) } // pow_2( x ) == x^2 -/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_2( T const x ) { return x * x; -} */ +} +/* double pow_2(double x) { return exp(2*log(x)); } + */ // pow_3( x ) == x^3 -/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_3( T const x ) { - return x * x * x; -} */ + //return x * x * x; + return exp(3*log(x)); +} +/* double pow_3(double x) { return exp(3*log(x)); -} +}*/ //// pow_4( x ) == x^4 -/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_4( T const x ) { - T const t( x * x ); - return t * t; -} */ - + //T const t( x * x ); + //return t * t; + return exp(4*log(x)); +} -double pow_4 (float x) +/* +double pow_4 (double x) { return exp(4*log(x)); } - +*/ // pow_5( x ) == x^5 -/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_5( T const x ) { - T const t( x * x ); - return t * t * x; + //T const t( x * x ); + //return t * t * x; + return exp(5*log(x)); } -*/ + // pow_6( x ) == x^6 -/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_6( T const x ) { - T const t( x * x * x ); - return t * t; -} */ - + //T const t( x * x * x ); + //return t * t; + return exp(6*log(x)); + +} +/* double pow_6(float x) { return exp(6*log(x)); -} +}*/ + // pow_7( x ) == x^7 -/* + template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_7( T const x ) { - T const t( x * x * x ); - return t * t * x; + //T const t( x * x * x ); + //return t * t * x; + return exp(7*log(x)); } - */ + +/* double pow_7(float x) { return exp(7*log(x)); } - +*/ // pow_8( x ) == x^8 -/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_8( T const x ) { - T t( x * x ); - t *= t; - return t * t; -} */ + //T t( x * x ); + //t *= t; + //return t * t; + return exp(8*log(x)); +} // pow_9( x ) == x^9 -/*template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< std::is_arithmetic< T >::value >::type > inline T pow_9( T const x ) { - T const t( x * x * x ); - return t * t * t; + //T const t( x * x * x ); + //return t * t * t; + return exp(9*log(x)); } -*/ + // root_4( x ) == x^(1/4) @@ -1463,118 +1482,139 @@ quad( T const & x ) } // pow_2( x ) == x^2 -/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_2( T const & x ) { - return x * x; -} */ + return exp(2*log(x)); +} +/* +double pow_2 (double x) +{ + + return exp(2*log(x)); +}*/ // pow_3( x ) == x^3 -/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_3( T const & x ) { - return x * x * x; -} */ + return exp(3*log(x)); +} +/* +double pow_3 (double x) +{ + + return exp(3*log(x)); +}*/ // pow_4( x ) == x^4 -/* + template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_4( T const & x ) { - T const t( x * x ); - return t * t; -} */ - + //T const t( x * x ); + return pow_2(pow_2(x)); +} + /* double pow_4 (double x) { + return exp(4*log(x)); -} +}*/ // pow_5( x ) == x^5 -/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_5( T const & x ) { - T const t( x * x ); - return t * t * x; -} */ - + //T const t( x * x ); + //return t * t * x; + return pow_2(x)*pow_3(x); +} +/* double pow_5(double x) { return exp(5*log(x)); -} +}*/ // pow_6( x ) == x^6 -/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_6( T const & x ) { - T const t( x * x * x ); - return t * t; -} */ + //T const t( x * x * x ); + //return t * t; + return pow_2(pow_3(x)); +} + /* double pow_6(double x) { return exp(6*log(x)); -} +}*/ // pow_7( x ) == x^7 -/* + template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_7( T const & x ) { - T const t( x * x * x ); - return t * t * x; + //T const t( x * x * x ); + //return t * t * x; + return pow_3(x)*pow_4(x); } -*/ +/* double pow_7(double x) { return exp(7*log(x)); -} +}*/ // pow_8( x ) == x^8 -/*template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_8( T const & x ) { - T t( x * x ); - t *= t; - return t * t; -} */ + //T t( x * x ); + //t *= t; + //return t * t; + return pow_4(x)*pow_4(x); +} + /* double pow_8(double x) { return exp(8*log(x)); -} +}*/ // pow_9( x ) == x^9 -/* template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > +template< typename T, class = typename std::enable_if< ! std::is_arithmetic< T >::value >::type > inline T pow_9( T const & x ) { - T const t( x * x * x ); - return t * t * t; -} */ + //T const t( x * x * x ); + //return t * t * t; + return pow_4(x)*pow_5(x); +} + /* double pow_9(double x) { return exp(9*log(x)); -} +}*/ // Tolerant Comparisons ///// From cbf58b8e9a84e88440bf993aa4b97e647f402237 Mon Sep 17 00:00:00 2001 From: Yanfei Date: Thu, 25 Mar 2021 13:10:48 -0400 Subject: [PATCH 8/9] finish first round of function approximation: power(), min(), and max() --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 955773e29f3..5d7e3e6a563 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -27,6 +27,8 @@ namespace ObjexxFCL { +// this file contains the changes for function approximation: +// power function, and min/max typedef std::intmax_t SSize; /* float myxor(float x, float y) From a9848bbdbe0c16b106c25393237239dbc873435f Mon Sep 17 00:00:00 2001 From: Yanfei Date: Fri, 2 Apr 2021 00:09:44 -0400 Subject: [PATCH 9/9] update min/max functions using improved innovative approach --- third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh | 69 +++++++++++++------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh index 5d7e3e6a563..d8854cc4bf2 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/Fmath.hh @@ -49,7 +49,8 @@ float myxor(float x, float y) short int min( short int const a, short int const b ) { - return ( b ^ ((a ^ b) & -(a < b)) ); + // return ( b ^ ((a ^ b) & -(a < b)) ); + return a*(a