]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/reporting/performance/test_kv.cpp
1 // Copyright John Maddock 2015.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 # pragma warning (disable : 4224)
10 #include <boost/math/special_functions/bessel.hpp>
11 #include <boost/array.hpp>
12 #include <boost/lexical_cast.hpp>
13 #include "../../test/table_type.hpp"
14 #include "table_helper.hpp"
15 #include "performance.hpp"
19 #define SC_(x) static_cast<double>(x)
20 static const boost :: array
< boost :: array
< T
, 3 >, 11 > kv_data
= { {
21 { { SC_ ( 0.5 ), SC_ ( 0.875 ), SC_ ( 0.558532231646608646115729767013630967055657943463362504577189 ) } },
22 { { SC_ ( 0.5 ), SC_ ( 1.125 ), SC_ ( 0.383621010650189547146769320487006220295290256657827220786527 ) } },
23 { { SC_ ( 2.25 ), T ( std :: ldexp ( 1.0 , - 30 )), SC_ ( 5.62397392719283271332307799146649700147907612095185712015604 e20
) } },
24 { { SC_ ( 5.5 ), T ( 3217 ) / 1024 , SC_ ( 1.30623288775012596319554857587765179889689223531159532808379 ) } },
25 { { SC_ (- 5.5 ), SC_ ( 10.0 ), SC_ ( 0.0000733045300798502164644836879577484533096239574909573072142667 ) } },
26 { { SC_ (- 5.5 ), SC_ ( 100.0 ), SC_ ( 5.41274555306792267322084448693957747924412508020839543293369e-45 ) } },
27 { { T ( 10240 ) / 1024 , T ( 1 ) / 1024 , SC_ ( 2.35522579263922076203415803966825431039900000000993410734978 e38
) } },
28 { { T ( 10240 ) / 1024 , SC_ ( 10.0 ), SC_ ( 0.00161425530039067002345725193091329085443750382929208307802221 ) } },
29 { { T ( 144793 ) / 1024 , SC_ ( 100.0 ), SC_ ( 1.39565245860302528069481472855619216759142225046370312329416e-6 ) } },
30 { { T ( 144793 ) / 1024 , SC_ ( 200.0 ), SC_ ( 9.11950412043225432171915100042647230802198254567007382956336e-68 ) } },
31 { { T (- 144793 ) / 1024 , SC_ ( 50.0 ), SC_ ( 1.30185229717525025165362673848737761549946548375142378172956 e42
) } },
33 static const boost :: array
< boost :: array
< T
, 3 >, 5 > kv_large_data
= { {
34 // Bug report https://svn.boost.org/trac/boost/ticket/5560:
35 { { SC_ (- 1.0 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 2.68156158598851941991480499964116922549587316411847867554471 e154
) } },
36 { { SC_ ( 1.0 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 2.68156158598851941991480499964116922549587316411847867554471 e154
) } },
37 { { SC_ (- 1.125 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 5.53984048006472105611199242328122729730752165907526178753978 e173
) } },
38 { { SC_ ( 1.125 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 5.53984048006472105611199242328122729730752165907526178753978 e173
) } },
39 { { SC_ ( 0.5 ), static_cast < T
>( ldexp ( 0.5 , - 683 )), SC_ ( 1.12284149973980088540335945247019177715948513804063794284101 e103
) } },
44 #include "bessel_k_data.ipp"
47 add_data ( kv_large_data
);
48 add_data ( bessel_k_data
);
50 unsigned data_total
= data
. size ();
52 std :: cout
<< "Screening boost data: \n " ;
53 screen_data ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_k ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
55 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
56 std :: cout
<< "Screening libstdc++ data: \n " ;
57 screen_data ([]( const std :: vector
< double >& v
){ return std :: tr1 :: cyl_bessel_k ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
59 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
60 std :: cout
<< "Screening libstdc++ data: \n " ;
61 screen_data ([]( const std :: vector
< double >& v
){ return gsl_sf_bessel_Knu ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
63 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
64 std :: cout
<< "Screening libstdc++ data: \n " ;
65 screen_data ([]( const std :: vector
< double >& v
){ return bessel_k ( v
[ 1 ], v
[ 0 ], 1 ); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
68 unsigned data_used
= data
. size ();
69 std :: string function
= "cyl_bessel_k[br](" + boost :: lexical_cast
< std :: string
>( data_used
) + "/" + boost :: lexical_cast
< std :: string
>( data_total
) + " tests selected)" ;
70 std :: string function_short
= "cyl_bessel_k" ;
74 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_k ( v
[ 0 ], v
[ 1 ]); });
75 std :: cout
<< time
<< std :: endl
;
76 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
77 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, boost_name ());
79 report_execution_time ( time
, std :: string ( "Compiler Comparison on " ) + std :: string ( platform_name ()), function_short
, compiler_name () + std :: string ( "[br]" ) + boost_name ());
81 // Boost again, but with promotion to long double turned off:
83 #if !defined(COMPILER_COMPARISON_TABLES)
84 if ( sizeof ( long double ) != sizeof ( double ))
86 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_k ( v
[ 0 ], v
[ 1 ], boost :: math :: policies :: make_policy ( boost :: math :: policies :: promote_double
< false >())); });
87 std :: cout
<< time
<< std :: endl
;
88 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
89 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, boost_name () + "[br]promote_double<false>" );
91 report_execution_time ( time
, std :: string ( "Compiler Comparison on " ) + std :: string ( platform_name ()), function_short
, compiler_name () + std :: string ( "[br]" ) + boost_name () + "[br]promote_double<false>" );
96 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
97 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return std :: tr1 :: cyl_bessel_k ( v
[ 0 ], v
[ 1 ]); });
98 std :: cout
<< time
<< std :: endl
;
99 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "tr1/cmath" );
101 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
102 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return gsl_sf_bessel_Knu ( v
[ 0 ], v
[ 1 ]); });
103 std :: cout
<< time
<< std :: endl
;
104 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "GSL " GSL_VERSION
);
106 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
107 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return bessel_k ( v
[ 1 ], v
[ 0 ], 1 ); });
108 std :: cout
<< time
<< std :: endl
;
109 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "Rmath " R_VERSION_STRING
);