]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/reporting/performance/test_iv.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 >, 10 > iv_data
= { {
21 { { SC_ ( 2.25 ), T ( 1 ) / ( 1024 * 1024 ), SC_ ( 2.34379212133481347189068464680335815256364262507955635911656e-15 ) } },
22 { { SC_ ( 5.5 ), SC_ ( 3.125 ), SC_ ( 0.0583514045989371500460946536220735787163510569634133670181210 ) } },
23 { { T (- 5 ) + T ( 1 ) / 1024 , SC_ ( 2.125 ), SC_ ( 0.0267920938009571023702933210070984416052633027166975342895062 ) } },
24 { { SC_ (- 5.5 ), SC_ ( 10.0 ), SC_ ( 597.577606961369169607937419869926705730305175364662688426534 ) } },
25 { { SC_ (- 5.5 ), SC_ ( 100.0 ), SC_ ( 9.22362906144706871737354069133813819358704200689067071415379 e41
) } },
26 { { T (- 10486074 ) / ( 1024 * 1024 ), T ( 1 ) / 1024 , SC_ ( 1.41474005665181350367684623930576333542989766867888186478185 e35
) } },
27 { { T (- 10486074 ) / ( 1024 * 1024 ), SC_ ( 50.0 ), SC_ ( 1.07153277202900671531087024688681954238311679648319534644743 e20
) } },
28 { { T ( 144794 ) / 1024 , SC_ ( 100.0 ), SC_ ( 2066.27694757392660413922181531984160871678224178890247540320 ) } },
29 { { T ( 144794 ) / 1024 , SC_ ( 200.0 ), SC_ ( 2.23699739472246928794922868978337381373643889659337595319774 e64
) } },
30 { { T (- 144794 ) / 1024 , SC_ ( 100.0 ), SC_ ( 2066.27694672763190927440969155740243346136463461655104698748 ) } },
32 static const boost :: array
< boost :: array
< T
, 3 >, 5 > iv_large_data
= { {
33 // Bug report https://svn.boost.org/trac/boost/ticket/5560:
34 { { SC_ (- 1.0 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 1.86458518280005168582274132886573345934411788365010172356788e-155 ) } },
35 { { SC_ ( 1.0 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 1.86458518280005168582274132886573345934411788365010172356788e-155 ) } },
36 { { SC_ (- 1.125 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ (- 1.34963720853101363690381585556234820027343435206156667634081 e173
) } },
37 { { SC_ ( 1.125 ), static_cast < T
>( ldexp ( 0.5 , - 512 )), SC_ ( 8.02269390325932403421158766283366891170783955777638875887348e-175 ) } },
38 { { SC_ ( 0.5 ), static_cast < T
>( ldexp ( 0.5 , - 683 )), SC_ ( 8.90597649117647254543282704099383321071493400182381039079219e-104 ) } },
43 #include "bessel_i_data.ipp"
46 add_data ( iv_large_data
);
47 add_data ( bessel_i_data
);
49 unsigned data_total
= data
. size ();
51 std :: cout
<< "Screening boost data: \n " ;
52 screen_data ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_i ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
54 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
55 std :: cout
<< "Screening libstdc++ data: \n " ;
56 screen_data ([]( const std :: vector
< double >& v
){ return std :: tr1 :: cyl_bessel_i ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
58 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
59 std :: cout
<< "Screening GSL data: \n " ;
60 screen_data ([]( const std :: vector
< double >& v
){ return gsl_sf_bessel_Inu ( v
[ 0 ], v
[ 1 ]); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
62 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
63 std :: cout
<< "Screening GSL data: \n " ;
64 screen_data ([]( const std :: vector
< double >& v
){ return bessel_i ( v
[ 1 ], v
[ 0 ], 1 ); }, []( const std :: vector
< double >& v
){ return v
[ 2 ]; });
67 unsigned data_used
= data
. size ();
68 std :: string function
= "cyl_bessel_i[br](" + boost :: lexical_cast
< std :: string
>( data_used
) + "/" + boost :: lexical_cast
< std :: string
>( data_total
) + " tests selected)" ;
69 std :: string function_short
= "cyl_bessel_i" ;
73 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_i ( v
[ 0 ], v
[ 1 ]); });
74 std :: cout
<< time
<< std :: endl
;
75 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
76 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, boost_name ());
78 report_execution_time ( time
, std :: string ( "Compiler Comparison on " ) + std :: string ( platform_name ()), function_short
, compiler_name () + std :: string ( "[br]" ) + boost_name ());
80 // Boost again, but with promotion to long double turned off:
82 #if !defined(COMPILER_COMPARISON_TABLES)
83 if ( sizeof ( long double ) != sizeof ( double ))
85 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return boost :: math :: cyl_bessel_i ( v
[ 0 ], v
[ 1 ], boost :: math :: policies :: make_policy ( boost :: math :: policies :: promote_double
< false >())); });
86 std :: cout
<< time
<< std :: endl
;
87 #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX))
88 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>" );
90 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>" );
95 #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES)
96 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return std :: tr1 :: cyl_bessel_i ( v
[ 0 ], v
[ 1 ]); });
97 std :: cout
<< time
<< std :: endl
;
98 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "tr1/cmath" );
100 #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES)
101 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return gsl_sf_bessel_Inu ( v
[ 0 ], v
[ 1 ]); });
102 std :: cout
<< time
<< std :: endl
;
103 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "GSL " GSL_VERSION
);
105 #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES)
106 time
= exec_timed_test ([]( const std :: vector
< double >& v
){ return bessel_i ( v
[ 1 ], v
[ 0 ], 1 ); });
107 std :: cout
<< time
<< std :: endl
;
108 report_execution_time ( time
, std :: string ( "Library Comparison with " ) + std :: string ( compiler_name ()) + std :: string ( " on " ) + platform_name (), function
, "Rmath " R_VERSION_STRING
);