diff options
author | Edward Smith-Rowland <3dw4rd@verizon.net> | 2016-01-14 18:12:43 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2016-01-14 18:12:43 +0000 |
commit | 2be75957b80b640c0aac4356ab861edd0c2f1b9d (patch) | |
tree | 0455764930d231084ffd7ab299b1d5fc734f1c33 /libstdc++-v3/testsuite/special_functions/17_legendre | |
parent | 00083992a68feb592575464d5be98e281e8a2d8e (diff) | |
download | gcc-2be75957b80b640c0aac4356ab861edd0c2f1b9d.tar.gz |
Implement TR29124 C++ special Math Functions.
2016-01-14 Edward Smith-Rowland <3dw4rd@verizon.net>
Jonathan Wakely <jwakely@redhat.com>
Florian Goth <CaptainSifff@gmx.de>
Implement TR29124 C++ special Math Functions.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/bits/specfun.h: New.
* include/c_global/cmath: Adjust for both tr1 and tr29124 maths.
* include/tr1/bessel_function.tcc: Ditto.
* include/tr1/beta_function.tcc: Ditto.
* include/tr1/cmath: Ditto.
* include/tr1/ell_integral.tcc: Ditto.
* include/tr1/exp_integral.tcc: Ditto.
* include/tr1/gamma.tcc: Ditto.
* include/tr1/hypergeometric.tcc: Ditto.
* include/tr1/legendre_function.tcc: Ditto.
* include/tr1/modified_bessel_func.tcc: Ditto.
* include/tr1/poly_hermite.tcc: Ditto.
* include/tr1/poly_laguerre.tcc: Ditto.
* include/tr1/riemann_zeta.tcc: Ditto.
* include/tr1/special_function_util.h: Ditto.
* testsuite/ext/special_functions/conf_hyperg: New.
* testsuite/ext/special_functions/conf_hyperg/check_nan.cc: New.
* testsuite/ext/special_functions/conf_hyperg/check_value.cc: New.
* testsuite/ext/special_functions/conf_hyperg/compile.cc: New.
* testsuite/ext/special_functions/hyperg: New.
* testsuite/ext/special_functions/hyperg/check_nan.cc: New.
* testsuite/ext/special_functions/hyperg/check_value.cc: New.
* testsuite/ext/special_functions/hyperg/compile.cc: New.
* testsuite/libstdc++-dg/conformance.exp: Add special_functions directory.
* testsuite/special_functions/01_assoc_laguerre/check_nan.cc: New.
* testsuite/special_functions/01_assoc_laguerre/check_value.cc: New.
* testsuite/special_functions/01_assoc_laguerre/compile.cc: New.
* testsuite/special_functions/01_assoc_laguerre/compile_2.cc: New.
* testsuite/special_functions/02_assoc_legendre/check_nan.cc: New.
* testsuite/special_functions/02_assoc_legendre/check_value.cc: New.
* testsuite/special_functions/02_assoc_legendre/compile.cc: New.
* testsuite/special_functions/02_assoc_legendre/compile_2.cc: New.
* testsuite/special_functions/03_beta/check_nan.cc: New.
* testsuite/special_functions/03_beta/check_value.cc: New.
* testsuite/special_functions/03_beta/compile.cc: New.
* testsuite/special_functions/03_beta/compile_2.cc: New.
* testsuite/special_functions/04_comp_ellint_1/check_nan.cc: New.
* testsuite/special_functions/04_comp_ellint_1/check_value.cc: New.
* testsuite/special_functions/04_comp_ellint_1/compile.cc: New.
* testsuite/special_functions/04_comp_ellint_1/compile_2.cc: New.
* testsuite/special_functions/05_comp_ellint_2/check_nan.cc: New.
* testsuite/special_functions/05_comp_ellint_2/check_value.cc: New.
* testsuite/special_functions/05_comp_ellint_2/compile.cc: New.
* testsuite/special_functions/05_comp_ellint_2/compile_2.cc: New.
* testsuite/special_functions/06_comp_ellint_3/check_nan.cc: New.
* testsuite/special_functions/06_comp_ellint_3/check_value.cc: New.
* testsuite/special_functions/06_comp_ellint_3/compile.cc: New.
* testsuite/special_functions/06_comp_ellint_3/compile_2.cc: New.
* testsuite/special_functions/07_cyl_bessel_i/check_nan.cc: New.
* testsuite/special_functions/07_cyl_bessel_i/check_value.cc: New.
* testsuite/special_functions/07_cyl_bessel_i/compile.cc: New.
* testsuite/special_functions/07_cyl_bessel_i/compile_2.cc: New.
* testsuite/special_functions/07_cyl_bessel_i/pr56216.cc: New.
* testsuite/special_functions/08_cyl_bessel_j/check_nan.cc: New.
* testsuite/special_functions/08_cyl_bessel_j/check_value.cc: New.
* testsuite/special_functions/08_cyl_bessel_j/compile.cc: New.
* testsuite/special_functions/08_cyl_bessel_j/compile_2.cc: New.
* testsuite/special_functions/09_cyl_bessel_k/check_nan.cc: New.
* testsuite/special_functions/09_cyl_bessel_k/check_value.cc: New.
* testsuite/special_functions/09_cyl_bessel_k/compile.cc: New.
* testsuite/special_functions/09_cyl_bessel_k/compile_2.cc: New.
* testsuite/special_functions/10_cyl_neumann/check_nan.cc: New.
* testsuite/special_functions/10_cyl_neumann/check_value.cc: New.
* testsuite/special_functions/10_cyl_neumann/compile.cc: New.
* testsuite/special_functions/10_cyl_neumann/compile_2.cc: New.
* testsuite/special_functions/11_ellint_1/check_nan.cc: New.
* testsuite/special_functions/11_ellint_1/check_value.cc: New.
* testsuite/special_functions/11_ellint_1/compile.cc: New.
* testsuite/special_functions/11_ellint_1/compile_2.cc: New.
* testsuite/special_functions/12_ellint_2/check_nan.cc: New.
* testsuite/special_functions/12_ellint_2/check_value.cc: New.
* testsuite/special_functions/12_ellint_2/compile.cc: New.
* testsuite/special_functions/12_ellint_2/compile_2.cc: New.
* testsuite/special_functions/13_ellint_3/check_nan.cc: New.
* testsuite/special_functions/13_ellint_3/check_value.cc: New.
* testsuite/special_functions/13_ellint_3/compile.cc: New.
* testsuite/special_functions/13_ellint_3/compile_2.cc: New.
* testsuite/special_functions/14_expint/check_nan.cc: New.
* testsuite/special_functions/14_expint/check_value.cc: New.
* testsuite/special_functions/14_expint/compile.cc: New.
* testsuite/special_functions/14_expint/compile_2.cc: New.
* testsuite/special_functions/15_hermite/check_nan.cc: New.
* testsuite/special_functions/15_hermite/check_value.cc: New.
* testsuite/special_functions/15_hermite/compile.cc: New.
* testsuite/special_functions/15_hermite/compile_2.cc: New.
* testsuite/special_functions/16_laguerre/check_nan.cc: New.
* testsuite/special_functions/16_laguerre/check_value.cc: New.
* testsuite/special_functions/16_laguerre/compile.cc: New.
* testsuite/special_functions/16_laguerre/compile_2.cc: New.
* testsuite/special_functions/17_legendre/check_nan.cc: New.
* testsuite/special_functions/17_legendre/check_value.cc: New.
* testsuite/special_functions/17_legendre/compile.cc: New.
* testsuite/special_functions/17_legendre/compile_2.cc: New.
* testsuite/special_functions/18_riemann_zeta/check_nan.cc: New.
* testsuite/special_functions/18_riemann_zeta/check_value.cc: New.
* testsuite/special_functions/18_riemann_zeta/compile.cc: New.
* testsuite/special_functions/18_riemann_zeta/compile_2.cc: New.
* testsuite/special_functions/19_sph_bessel/check_nan.cc: New.
* testsuite/special_functions/19_sph_bessel/check_value.cc: New.
* testsuite/special_functions/19_sph_bessel/compile.cc: New.
* testsuite/special_functions/19_sph_bessel/compile_2.cc: New.
* testsuite/special_functions/20_sph_legendre/check_nan.cc: New.
* testsuite/special_functions/20_sph_legendre/check_value.cc: New.
* testsuite/special_functions/20_sph_legendre/compile.cc: New.
* testsuite/special_functions/20_sph_legendre/compile_2.cc: New.
* testsuite/special_functions/21_sph_neumann/check_nan.cc: New.
* testsuite/special_functions/21_sph_neumann/check_value.cc: New.
* testsuite/special_functions/21_sph_neumann/compile.cc: New.
* testsuite/special_functions/21_sph_neumann/compile_2.cc: New.
* testsuite/util/specfun_testcase.h: New.
* testsuite/tr1/5_numerical_facilities/special_functions/08_cyl_bessel_i/check_value.cc: More testcases.
* testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/10_cyl_bessel_k/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/21_sph_bessel/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/23_sph_neumann/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/16_hermite/check_value.cc: New.
Co-Authored-By: Florian Goth <CaptainSifff@gmx.de>
Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
From-SVN: r232377
Diffstat (limited to 'libstdc++-v3/testsuite/special_functions/17_legendre')
4 files changed, 462 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/special_functions/17_legendre/check_nan.cc b/libstdc++-v3/testsuite/special_functions/17_legendre/check_nan.cc new file mode 100644 index 00000000000..98a9a30741c --- /dev/null +++ b/libstdc++-v3/testsuite/special_functions/17_legendre/check_nan.cc @@ -0,0 +1,59 @@ +// { dg-require-c-std "" } +// { dg-add-options ieee } +// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.1.17 legendre + +#include <cmath> +#include <testsuite_hooks.h> + +void +test01() +{ + + float xf = std::numeric_limits<float>::quiet_NaN(); + double xd = std::numeric_limits<double>::quiet_NaN(); + long double xl = std::numeric_limits<long double>::quiet_NaN(); + + unsigned int l = 2; + + float a = std::legendre(l, xf); + float b = std::legendref(l, xf); + double c = std::legendre(l, xd); + long double d = std::legendre(l, xl); + long double e = std::legendrel(l, xl); + + bool test [[gnu::unused]] = true; + VERIFY(std::isnan(a)); + VERIFY(std::isnan(b)); + VERIFY(std::isnan(c)); + VERIFY(std::isnan(d)); + VERIFY(std::isnan(e)); + + return; +} + +int +main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/special_functions/17_legendre/check_value.cc b/libstdc++-v3/testsuite/special_functions/17_legendre/check_value.cc new file mode 100644 index 00000000000..58944783928 --- /dev/null +++ b/libstdc++-v3/testsuite/special_functions/17_legendre/check_value.cc @@ -0,0 +1,319 @@ +// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } +// +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// legendre +// Compare against values generated by the GNU Scientific Library. +// The GSL can be found on the web: http://www.gnu.org/software/gsl/ +#include <limits> +#include <cmath> +#if defined(__TEST_DEBUG) +# include <iostream> +# define VERIFY(A) \ + if (!(A)) \ + { \ + std::cout << "line " << __LINE__ \ + << " max_abs_frac = " << max_abs_frac \ + << std::endl; \ + } +#else +# include <testsuite_hooks.h> +#endif +#include <specfun_testcase.h> + + +// Test data for l=0. +// max(|f - f_GSL|): 0.0000000000000000 +// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000 +const testcase_legendre<double> +data001[21] = +{ + { 1.0000000000000000, 0, -1.0000000000000000 }, + { 1.0000000000000000, 0, -0.90000000000000002 }, + { 1.0000000000000000, 0, -0.80000000000000004 }, + { 1.0000000000000000, 0, -0.69999999999999996 }, + { 1.0000000000000000, 0, -0.59999999999999998 }, + { 1.0000000000000000, 0, -0.50000000000000000 }, + { 1.0000000000000000, 0, -0.40000000000000002 }, + { 1.0000000000000000, 0, -0.30000000000000004 }, + { 1.0000000000000000, 0, -0.19999999999999996 }, + { 1.0000000000000000, 0, -0.099999999999999978 }, + { 1.0000000000000000, 0, 0.0000000000000000 }, + { 1.0000000000000000, 0, 0.10000000000000009 }, + { 1.0000000000000000, 0, 0.19999999999999996 }, + { 1.0000000000000000, 0, 0.30000000000000004 }, + { 1.0000000000000000, 0, 0.39999999999999991 }, + { 1.0000000000000000, 0, 0.50000000000000000 }, + { 1.0000000000000000, 0, 0.60000000000000009 }, + { 1.0000000000000000, 0, 0.69999999999999996 }, + { 1.0000000000000000, 0, 0.80000000000000004 }, + { 1.0000000000000000, 0, 0.89999999999999991 }, + { 1.0000000000000000, 0, 1.0000000000000000 }, +}; +const double toler001 = 2.5000000000000020e-13; + +// Test data for l=1. +// max(|f - f_GSL|): 0.0000000000000000 +// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000 +const testcase_legendre<double> +data002[21] = +{ + { -1.0000000000000000, 1, -1.0000000000000000 }, + { -0.90000000000000002, 1, -0.90000000000000002 }, + { -0.80000000000000004, 1, -0.80000000000000004 }, + { -0.69999999999999996, 1, -0.69999999999999996 }, + { -0.59999999999999998, 1, -0.59999999999999998 }, + { -0.50000000000000000, 1, -0.50000000000000000 }, + { -0.40000000000000002, 1, -0.40000000000000002 }, + { -0.30000000000000004, 1, -0.30000000000000004 }, + { -0.19999999999999996, 1, -0.19999999999999996 }, + { -0.099999999999999978, 1, -0.099999999999999978 }, + { 0.0000000000000000, 1, 0.0000000000000000 }, + { 0.10000000000000009, 1, 0.10000000000000009 }, + { 0.19999999999999996, 1, 0.19999999999999996 }, + { 0.30000000000000004, 1, 0.30000000000000004 }, + { 0.39999999999999991, 1, 0.39999999999999991 }, + { 0.50000000000000000, 1, 0.50000000000000000 }, + { 0.60000000000000009, 1, 0.60000000000000009 }, + { 0.69999999999999996, 1, 0.69999999999999996 }, + { 0.80000000000000004, 1, 0.80000000000000004 }, + { 0.89999999999999991, 1, 0.89999999999999991 }, + { 1.0000000000000000, 1, 1.0000000000000000 }, +}; +const double toler002 = 2.5000000000000020e-13; + +// Test data for l=2. +// max(|f - f_GSL|): 1.1102230246251565e-16 +// max(|f - f_GSL| / |f_GSL|): 1.3877787807814482e-15 +const testcase_legendre<double> +data003[21] = +{ + { 1.0000000000000000, 2, -1.0000000000000000 }, + { 0.71500000000000008, 2, -0.90000000000000002 }, + { 0.46000000000000019, 2, -0.80000000000000004 }, + { 0.23499999999999988, 2, -0.69999999999999996 }, + { 0.039999999999999925, 2, -0.59999999999999998 }, + { -0.12500000000000000, 2, -0.50000000000000000 }, + { -0.25999999999999995, 2, -0.40000000000000002 }, + { -0.36499999999999999, 2, -0.30000000000000004 }, + { -0.44000000000000006, 2, -0.19999999999999996 }, + { -0.48499999999999999, 2, -0.099999999999999978 }, + { -0.50000000000000000, 2, 0.0000000000000000 }, + { -0.48499999999999999, 2, 0.10000000000000009 }, + { -0.44000000000000006, 2, 0.19999999999999996 }, + { -0.36499999999999999, 2, 0.30000000000000004 }, + { -0.26000000000000012, 2, 0.39999999999999991 }, + { -0.12500000000000000, 2, 0.50000000000000000 }, + { 0.040000000000000147, 2, 0.60000000000000009 }, + { 0.23499999999999988, 2, 0.69999999999999996 }, + { 0.46000000000000019, 2, 0.80000000000000004 }, + { 0.71499999999999986, 2, 0.89999999999999991 }, + { 1.0000000000000000, 2, 1.0000000000000000 }, +}; +const double toler003 = 2.5000000000000020e-13; + +// Test data for l=5. +// max(|f - f_GSL|): 2.0122792321330962e-16 +// max(|f - f_GSL| / |f_GSL|): 4.8911475274404243e-15 +const testcase_legendre<double> +data004[21] = +{ + { -1.0000000000000000, 5, -1.0000000000000000 }, + { 0.041141250000000087, 5, -0.90000000000000002 }, + { 0.39951999999999993, 5, -0.80000000000000004 }, + { 0.36519874999999991, 5, -0.69999999999999996 }, + { 0.15263999999999994, 5, -0.59999999999999998 }, + { -0.089843750000000000, 5, -0.50000000000000000 }, + { -0.27063999999999994, 5, -0.40000000000000002 }, + { -0.34538625000000001, 5, -0.30000000000000004 }, + { -0.30751999999999996, 5, -0.19999999999999996 }, + { -0.17882874999999995, 5, -0.099999999999999978 }, + { 0.0000000000000000, 5, 0.0000000000000000 }, + { 0.17882875000000015, 5, 0.10000000000000009 }, + { 0.30751999999999996, 5, 0.19999999999999996 }, + { 0.34538625000000001, 5, 0.30000000000000004 }, + { 0.27064000000000010, 5, 0.39999999999999991 }, + { 0.089843750000000000, 5, 0.50000000000000000 }, + { -0.15264000000000016, 5, 0.60000000000000009 }, + { -0.36519874999999991, 5, 0.69999999999999996 }, + { -0.39951999999999993, 5, 0.80000000000000004 }, + { -0.041141250000000261, 5, 0.89999999999999991 }, + { 1.0000000000000000, 5, 1.0000000000000000 }, +}; +const double toler004 = 2.5000000000000020e-13; + +// Test data for l=10. +// max(|f - f_GSL|): 2.7755575615628914e-16 +// max(|f - f_GSL| / |f_GSL|): 1.0547610802636413e-15 +const testcase_legendre<double> +data005[21] = +{ + { 1.0000000000000000, 10, -1.0000000000000000 }, + { -0.26314561785585960, 10, -0.90000000000000002 }, + { 0.30052979560000004, 10, -0.80000000000000004 }, + { 0.085805795531640333, 10, -0.69999999999999996 }, + { -0.24366274560000001, 10, -0.59999999999999998 }, + { -0.18822860717773438, 10, -0.50000000000000000 }, + { 0.096839064399999925, 10, -0.40000000000000002 }, + { 0.25147634951601561, 10, -0.30000000000000004 }, + { 0.12907202559999983, 10, -0.19999999999999996 }, + { -0.12212499738710943, 10, -0.099999999999999978 }, + { -0.24609375000000000, 10, 0.0000000000000000 }, + { -0.12212499738710922, 10, 0.10000000000000009 }, + { 0.12907202559999983, 10, 0.19999999999999996 }, + { 0.25147634951601561, 10, 0.30000000000000004 }, + { 0.096839064400000258, 10, 0.39999999999999991 }, + { -0.18822860717773438, 10, 0.50000000000000000 }, + { -0.24366274559999984, 10, 0.60000000000000009 }, + { 0.085805795531640333, 10, 0.69999999999999996 }, + { 0.30052979560000004, 10, 0.80000000000000004 }, + { -0.26314561785585899, 10, 0.89999999999999991 }, + { 1.0000000000000000, 10, 1.0000000000000000 }, +}; +const double toler005 = 2.5000000000000020e-13; + +// Test data for l=20. +// max(|f - f_GSL|): 3.3306690738754696e-16 +// max(|f - f_GSL| / |f_GSL|): 2.2307336678138069e-15 +const testcase_legendre<double> +data006[21] = +{ + { 1.0000000000000000, 20, -1.0000000000000000 }, + { -0.14930823530984835, 20, -0.90000000000000002 }, + { 0.22420460541741347, 20, -0.80000000000000004 }, + { -0.20457394463834172, 20, -0.69999999999999996 }, + { 0.15916752910098109, 20, -0.59999999999999998 }, + { -0.048358381067373557, 20, -0.50000000000000000 }, + { -0.10159261558628156, 20, -0.40000000000000002 }, + { 0.18028715947998042, 20, -0.30000000000000004 }, + { -0.098042194344594796, 20, -0.19999999999999996 }, + { -0.082077130944527663, 20, -0.099999999999999978 }, + { 0.17619705200195312, 20, 0.0000000000000000 }, + { -0.082077130944528023, 20, 0.10000000000000009 }, + { -0.098042194344594796, 20, 0.19999999999999996 }, + { 0.18028715947998042, 20, 0.30000000000000004 }, + { -0.10159261558628112, 20, 0.39999999999999991 }, + { -0.048358381067373557, 20, 0.50000000000000000 }, + { 0.15916752910098075, 20, 0.60000000000000009 }, + { -0.20457394463834172, 20, 0.69999999999999996 }, + { 0.22420460541741347, 20, 0.80000000000000004 }, + { -0.14930823530984924, 20, 0.89999999999999991 }, + { 1.0000000000000000, 20, 1.0000000000000000 }, +}; +const double toler006 = 2.5000000000000020e-13; + +// Test data for l=50. +// max(|f - f_GSL|): 3.6082248300317588e-16 +// max(|f - f_GSL| / |f_GSL|): 2.1700196856209138e-15 +const testcase_legendre<double> +data007[21] = +{ + { 1.0000000000000000, 50, -1.0000000000000000 }, + { -0.17003765994383671, 50, -0.90000000000000002 }, + { 0.13879737345093113, 50, -0.80000000000000004 }, + { -0.014572731645892852, 50, -0.69999999999999996 }, + { -0.058860798844002096, 50, -0.59999999999999998 }, + { -0.031059099239609811, 50, -0.50000000000000000 }, + { 0.041569033381825375, 50, -0.40000000000000002 }, + { 0.10911051574714797, 50, -0.30000000000000004 }, + { 0.083432272204197494, 50, -0.19999999999999996 }, + { -0.038205812661313600, 50, -0.099999999999999978 }, + { -0.11227517265921705, 50, 0.0000000000000000 }, + { -0.038205812661314155, 50, 0.10000000000000009 }, + { 0.083432272204197494, 50, 0.19999999999999996 }, + { 0.10911051574714797, 50, 0.30000000000000004 }, + { 0.041569033381824674, 50, 0.39999999999999991 }, + { -0.031059099239609811, 50, 0.50000000000000000 }, + { -0.058860798844001430, 50, 0.60000000000000009 }, + { -0.014572731645892852, 50, 0.69999999999999996 }, + { 0.13879737345093113, 50, 0.80000000000000004 }, + { -0.17003765994383657, 50, 0.89999999999999991 }, + { 1.0000000000000000, 50, 1.0000000000000000 }, +}; +const double toler007 = 2.5000000000000020e-13; + +// Test data for l=100. +// max(|f - f_GSL|): 3.4694469519536142e-16 +// max(|f - f_GSL| / |f_GSL|): 6.8214063779431592e-15 +const testcase_legendre<double> +data008[21] = +{ + { 1.0000000000000000, 100, -1.0000000000000000 }, + { 0.10226582055871893, 100, -0.90000000000000002 }, + { 0.050861167913584228, 100, -0.80000000000000004 }, + { -0.077132507199778641, 100, -0.69999999999999996 }, + { -0.023747023905133141, 100, -0.59999999999999998 }, + { -0.060518025961861198, 100, -0.50000000000000000 }, + { -0.072258202125684470, 100, -0.40000000000000002 }, + { 0.057127392202801566, 100, -0.30000000000000004 }, + { 0.014681835355659706, 100, -0.19999999999999996 }, + { -0.063895098434750205, 100, -0.099999999999999978 }, + { 0.079589237387178727, 100, 0.0000000000000000 }, + { -0.063895098434749761, 100, 0.10000000000000009 }, + { 0.014681835355659706, 100, 0.19999999999999996 }, + { 0.057127392202801566, 100, 0.30000000000000004 }, + { -0.072258202125685025, 100, 0.39999999999999991 }, + { -0.060518025961861198, 100, 0.50000000000000000 }, + { -0.023747023905134217, 100, 0.60000000000000009 }, + { -0.077132507199778641, 100, 0.69999999999999996 }, + { 0.050861167913584228, 100, 0.80000000000000004 }, + { 0.10226582055871711, 100, 0.89999999999999991 }, + { 1.0000000000000000, 100, 1.0000000000000000 }, +}; +const double toler008 = 5.0000000000000039e-13; + +template<typename Tp, unsigned int Num> + void + test(const testcase_legendre<Tp> (&data)[Num], Tp toler) + { + bool test __attribute__((unused)) = true; + const Tp eps = std::numeric_limits<Tp>::epsilon(); + Tp max_abs_diff = -Tp(1); + Tp max_abs_frac = -Tp(1); + unsigned int num_datum = Num; + for (unsigned int i = 0; i < num_datum; ++i) + { + const Tp f = std::legendre(data[i].l, data[i].x); + const Tp f0 = data[i].f0; + const Tp diff = f - f0; + if (std::abs(diff) > max_abs_diff) + max_abs_diff = std::abs(diff); + if (std::abs(f0) > Tp(10) * eps + && std::abs(f) > Tp(10) * eps) + { + const Tp frac = diff / f0; + if (std::abs(frac) > max_abs_frac) + max_abs_frac = std::abs(frac); + } + } + VERIFY(max_abs_frac < toler); + } + +int +main() +{ + test(data001, toler001); + test(data002, toler002); + test(data003, toler003); + test(data004, toler004); + test(data005, toler005); + test(data006, toler006); + test(data007, toler007); + test(data008, toler008); + return 0; +} diff --git a/libstdc++-v3/testsuite/special_functions/17_legendre/compile.cc b/libstdc++-v3/testsuite/special_functions/17_legendre/compile.cc new file mode 100644 index 00000000000..820293a1ba1 --- /dev/null +++ b/libstdc++-v3/testsuite/special_functions/17_legendre/compile.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.1.17 legendre + +#include <cmath> + +void +test01() +{ + float xf = 0.5F; + double xd = 0.5; + long double xl = 0.5L; + + unsigned int l = 2; + + std::legendre(l, xf); + std::legendref(l, xf); + std::legendre(l, xd); + std::legendre(l, xl); + std::legendrel(l, xl); + + return; +} + diff --git a/libstdc++-v3/testsuite/special_functions/17_legendre/compile_2.cc b/libstdc++-v3/testsuite/special_functions/17_legendre/compile_2.cc new file mode 100644 index 00000000000..4c69f9ae07a --- /dev/null +++ b/libstdc++-v3/testsuite/special_functions/17_legendre/compile_2.cc @@ -0,0 +1,42 @@ +// { dg-do compile { xfail *-*-* } } +// { dg-excess-errors "" } +// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } + +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 8.1.17 legendre + +#include <math.h> + +void +test01() +{ + float xf = 0.5F; + double xd = 0.5; + long double xl = 0.5L; + unsigned int l = 2; + + legendre(l, xf); + legendref(l, xf); + legendre(l, xd); + legendre(l, xl); + legendrel(l, xl); + + return; +} + |