]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/math_test.cpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / qvm / test / math_test.cpp
1 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
2
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifdef BOOST_QVM_TEST_SINGLE_HEADER
7 # include BOOST_QVM_TEST_SINGLE_HEADER
8 #else
9 # include <boost/qvm/math.hpp>
10 #endif
11
12 #include <boost/core/lightweight_test.hpp>
13 #include <stdlib.h>
14
15 namespace
16 {
17 template <class T>
18 void
19 test1( T (*f1)(T), T (*f2)(T) )
20 {
21 for( int i=0; i!=100; ++i )
22 {
23 T a = T(rand()) / T(RAND_MAX);
24 BOOST_TEST_EQ(f1(a), f2(a));
25 }
26 }
27 template <class T,class U>
28 void
29 test2( T (*f1)(T,U), T (*f2)(T,U) )
30 {
31 for( int i=0; i!=100; ++i )
32 {
33 T a = T(rand()) / T(RAND_MAX);
34 T b = T(rand()) / T(RAND_MAX);
35 BOOST_TEST_EQ(f1(a,b), f2(a,b));
36 }
37 }
38 }
39
40 int
41 main()
42 {
43 test1<float>(&boost::qvm::acos<float>, &::acosf);
44 test1<float>(&boost::qvm::asin<float>, &::asinf);
45 test1<float>(&boost::qvm::atan<float>, &::atanf);
46 test2<float,float>(&boost::qvm::atan2<float>, &::atan2f);
47 test1<float>(&boost::qvm::cos<float>, &::cosf);
48 test1<float>(&boost::qvm::sin<float>, &::sinf);
49 test1<float>(&boost::qvm::tan<float>, &::tanf);
50 test1<float>(&boost::qvm::cosh<float>, &::coshf);
51 test1<float>(&boost::qvm::sinh<float>, &::sinhf);
52 test1<float>(&boost::qvm::tanh<float>, &::tanhf);
53 test1<float>(&boost::qvm::exp<float>, &::expf);
54 test1<float>(&boost::qvm::log<float>, &::logf);
55 test1<float>(&boost::qvm::log10<float>, &::log10f);
56 test2<float,float>(&boost::qvm::mod<float>, &::fmodf);
57 test2<float,float>(&boost::qvm::pow<float>, &::powf);
58 test1<float>(&boost::qvm::sqrt<float>, &::sqrtf);
59 test1<float>(&boost::qvm::ceil<float>, &::ceilf);
60 test1<float>(&boost::qvm::abs<float>, &::fabsf);
61 test1<float>(&boost::qvm::floor<float>, &::floorf);
62 test2<float, int>(&boost::qvm::ldexp<float>, &::ldexpf);
63
64 test1<double>(&boost::qvm::acos<double>, &::acos);
65 test1<double>(&boost::qvm::asin<double>, &::asin);
66 test1<double>(&boost::qvm::atan<double>, &::atan);
67 test2<double,double>(&boost::qvm::atan2<double>, &::atan2);
68 test1<double>(&boost::qvm::cos<double>, &::cos);
69 test1<double>(&boost::qvm::sin<double>, &::sin);
70 test1<double>(&boost::qvm::tan<double>, &::tan);
71 test1<double>(&boost::qvm::cosh<double>, &::cosh);
72 test1<double>(&boost::qvm::sinh<double>, &::sinh);
73 test1<double>(&boost::qvm::tanh<double>, &::tanh);
74 test1<double>(&boost::qvm::exp<double>, &::exp);
75 test1<double>(&boost::qvm::log<double>, &::log);
76 test1<double>(&boost::qvm::log10<double>, &::log10);
77 test2<double,double>(&boost::qvm::mod<double>, &::fmod);
78 test2<double,double>(&boost::qvm::pow<double>, &::pow);
79 test1<double>(&boost::qvm::sqrt<double>, &::sqrt);
80 test1<double>(&boost::qvm::ceil<double>, &::ceil);
81 test1<double>(&boost::qvm::abs<double>, &::fabs);
82 test1<double>(&boost::qvm::floor<double>, &::floor);
83 test2<double, int>(&boost::qvm::ldexp<double>, &::ldexp);
84
85 test1<long double>(&boost::qvm::acos<long double>, &::acosl);
86 test1<long double>(&boost::qvm::asin<long double>, &::asinl);
87 test1<long double>(&boost::qvm::atan<long double>, &::atanl);
88 test2<long double,long double>(&boost::qvm::atan2<long double>, &::atan2l);
89 test1<long double>(&boost::qvm::cos<long double>, &::cosl);
90 test1<long double>(&boost::qvm::sin<long double>, &::sinl);
91 test1<long double>(&boost::qvm::tan<long double>, &::tanl);
92 test1<long double>(&boost::qvm::cosh<long double>, &::coshl);
93 test1<long double>(&boost::qvm::sinh<long double>, &::sinhl);
94 test1<long double>(&boost::qvm::tanh<long double>, &::tanhl);
95 test1<long double>(&boost::qvm::exp<long double>, &::expl);
96 test1<long double>(&boost::qvm::log<long double>, &::logl);
97 test1<long double>(&boost::qvm::log10<long double>, &::log10l);
98 test2<long double,long double>(&boost::qvm::mod<long double>, &::fmodl);
99 test2<long double,long double>(&boost::qvm::pow<long double>, &::powl);
100 test1<long double>(&boost::qvm::sqrt<long double>, &::sqrtl);
101 test1<long double>(&boost::qvm::ceil<long double>, &::ceill);
102 test1<long double>(&boost::qvm::abs<long double>, &::fabsl);
103 test1<long double>(&boost::qvm::floor<long double>, &::floorl);
104 test2<long double, int>(&boost::qvm::ldexp<long double>, &::ldexpl);
105
106 return boost::report_errors();
107 }