Commit b4688136 by Edward Smith-Rowland Committed by Edward Smith-Rowland

PR libstdc++/pr66689 - comp_ellint_3 and ellint_3 return garbage values

2017-11-18  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/pr66689 - comp_ellint_3 and ellint_3 return garbage values
	* include/tr1/ell_integral.tcc: Correct the nu sign convention
	in ellint_3 and comp_ellint_3.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	06_comp_ellint_3/check_value.cc: Regen with correct values.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	14_ellint_3/check_value.cc: Ditto.
	* testsuite/special_functions/06_comp_ellint_3/check_value.cc: Ditto.
	* testsuite/special_functions/13_ellint_3/check_value.cc: Ditto.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	01_assoc_laguerre/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	02_assoc_legendre/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	03_beta/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	04_comp_ellint_1/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	05_comp_ellint_2/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	07_conf_hyperg/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	08_cyl_bessel_i/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	09_cyl_bessel_j/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	10_cyl_bessel_k/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	11_cyl_neumann/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	12_ellint_1/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	13_ellint_2/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	15_expint/check_value_neg.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	16_hermite/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	17_hyperg/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	18_laguerre/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	19_legendre/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	20_riemann_zeta/check_value_neg.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	21_sph_bessel/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	22_sph_legendre/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	23_sph_neumann/check_value.cc: Regen.
	* testsuite/ext/special_functions/conf_hyperg/check_value.cc: Regen.
	* testsuite/ext/special_functions/hyperg/check_value.cc: Regen.
	* testsuite/special_functions/01_assoc_laguerre/check_value.cc: Regen.
	* testsuite/special_functions/02_assoc_legendre/check_value.cc: Regen.
	* testsuite/special_functions/03_beta/check_value.cc: Regen.
	* testsuite/special_functions/04_comp_ellint_1/check_value.cc: Regen.
	* testsuite/special_functions/05_comp_ellint_2/check_value.cc: Regen.
	* testsuite/special_functions/07_cyl_bessel_i/check_value.cc: Regen.
	* testsuite/special_functions/08_cyl_bessel_j/check_value.cc: Regen.
	* testsuite/special_functions/09_cyl_bessel_k/check_value.cc: Regen.
 	* testsuite/special_functions/10_cyl_neumann/check_value.cc: Regen.
	* testsuite/special_functions/11_ellint_1/check_value.cc: Regen.
	* testsuite/special_functions/12_ellint_2/check_value.cc: Regen.
	* testsuite/special_functions/14_expint/check_value.cc: Regen.
	* testsuite/special_functions/15_hermite/check_value.cc: Regen.
	* testsuite/special_functions/16_laguerre/check_value.cc: Regen.
	* testsuite/special_functions/17_legendre/check_value.cc: Regen.
	* testsuite/special_functions/18_riemann_zeta/check_value.cc: Regen.
	* testsuite/special_functions/19_sph_bessel/check_value.cc: Regen.
	* testsuite/special_functions/20_sph_legendre/check_value.cc: Regen.
	* testsuite/special_functions/21_sph_neumann/check_value.cc: Regen.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	06_comp_ellint_3/pr66689.cc: New.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	14_ellint_3/pr66689.cc: New.
	* testsuite/special_functions/06_comp_ellint_3/pr66689.cc: New.
	* testsuite/special_functions/13_ellint_3/pr66689.cc: New.

From-SVN: r254924
parent d4321083
2017-11-18 Edward Smith-Rowland <3dw4rd@verizon.net>
PR libstdc++/pr66689 - comp_ellint_3 and ellint_3 return garbage values
* include/tr1/ell_integral.tcc: Correct the nu sign convention
in ellint_3 and comp_ellint_3.
* testsuite/tr1/5_numerical_facilities/special_functions/
06_comp_ellint_3/check_value.cc: Regen with correct values.
* testsuite/tr1/5_numerical_facilities/special_functions/
14_ellint_3/check_value.cc: Ditto.
* testsuite/special_functions/06_comp_ellint_3/check_value.cc: Ditto.
* testsuite/special_functions/13_ellint_3/check_value.cc: Ditto.
* testsuite/tr1/5_numerical_facilities/special_functions/
01_assoc_laguerre/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
02_assoc_legendre/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
03_beta/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
04_comp_ellint_1/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
05_comp_ellint_2/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
07_conf_hyperg/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
08_cyl_bessel_i/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
09_cyl_bessel_j/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
10_cyl_bessel_k/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
11_cyl_neumann/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
12_ellint_1/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
13_ellint_2/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
15_expint/check_value_neg.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
16_hermite/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
17_hyperg/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
18_laguerre/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
19_legendre/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
20_riemann_zeta/check_value_neg.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
21_sph_bessel/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
22_sph_legendre/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
23_sph_neumann/check_value.cc: Regen.
* testsuite/ext/special_functions/conf_hyperg/check_value.cc: Regen.
* testsuite/ext/special_functions/hyperg/check_value.cc: Regen.
* testsuite/special_functions/01_assoc_laguerre/check_value.cc: Regen.
* testsuite/special_functions/02_assoc_legendre/check_value.cc: Regen.
* testsuite/special_functions/03_beta/check_value.cc: Regen.
* testsuite/special_functions/04_comp_ellint_1/check_value.cc: Regen.
* testsuite/special_functions/05_comp_ellint_2/check_value.cc: Regen.
* testsuite/special_functions/07_cyl_bessel_i/check_value.cc: Regen.
* testsuite/special_functions/08_cyl_bessel_j/check_value.cc: Regen.
* testsuite/special_functions/09_cyl_bessel_k/check_value.cc: Regen.
* testsuite/special_functions/10_cyl_neumann/check_value.cc: Regen.
* testsuite/special_functions/11_ellint_1/check_value.cc: Regen.
* testsuite/special_functions/12_ellint_2/check_value.cc: Regen.
* testsuite/special_functions/14_expint/check_value.cc: Regen.
* testsuite/special_functions/15_hermite/check_value.cc: Regen.
* testsuite/special_functions/16_laguerre/check_value.cc: Regen.
* testsuite/special_functions/17_legendre/check_value.cc: Regen.
* testsuite/special_functions/18_riemann_zeta/check_value.cc: Regen.
* testsuite/special_functions/19_sph_bessel/check_value.cc: Regen.
* testsuite/special_functions/20_sph_legendre/check_value.cc: Regen.
* testsuite/special_functions/21_sph_neumann/check_value.cc: Regen.
* testsuite/tr1/5_numerical_facilities/special_functions/
06_comp_ellint_3/pr66689.cc: New.
* testsuite/tr1/5_numerical_facilities/special_functions/
14_ellint_3/pr66689.cc: New.
* testsuite/special_functions/06_comp_ellint_3/pr66689.cc: New.
* testsuite/special_functions/13_ellint_3/pr66689.cc: New.
2017-11-18 Edward Smith-Rowland <3dw4rd@verizon.net>
Expose Airy functions as an extenaion.
* include/bits/specfun.h: Expose airy_ai and airy_bi.
* include/tr1/modified_bessel_func.tcc: Treat NaN and inf arg, return.
......
......@@ -685,8 +685,8 @@ namespace tr1
const _Tp __kk = __k * __k;
return __ellint_rf(_Tp(0), _Tp(1) - __kk, _Tp(1))
- __nu
* __ellint_rj(_Tp(0), _Tp(1) - __kk, _Tp(1), _Tp(1) + __nu)
+ __nu
* __ellint_rj(_Tp(0), _Tp(1) - __kk, _Tp(1), _Tp(1) - __nu)
/ _Tp(3);
}
}
......@@ -735,9 +735,9 @@ namespace tr1
const _Tp __Pi = __s
* __ellint_rf(__cc, _Tp(1) - __kk * __ss, _Tp(1))
- __nu * __sss
+ __nu * __sss
* __ellint_rj(__cc, _Tp(1) - __kk * __ss, _Tp(1),
_Tp(1) + __nu * __ss) / _Tp(3);
_Tp(1) - __nu * __ss) / _Tp(3);
if (__n == 0)
return __Pi;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -39,52 +39,56 @@
#include <specfun_testcase.h>
// Test data.
// max(|f - f_GSL|): 6.6613381477509392e-16
// max(|f - f_GSL| / |f_GSL|): 4.0617918857203532e-16
// max(|f - f_Boost|): 4.4408920985006262e-16 at index 18
// max(|f - f_Boost| / |f_Boost|): 1.9472906870017937e-16
// mean(f - f_Boost): -1.1686558153949016e-17
// variance(f - f_Boost): 1.2181788466954587e-32
// stddev(f - f_Boost): 1.1037113964689586e-16
const testcase_comp_ellint_1<double>
data001[19] =
{
{ 2.2805491384227703, -0.90000000000000002 },
{ 1.9953027776647296, -0.80000000000000004 },
{ 1.8456939983747236, -0.69999999999999996 },
{ 1.7507538029157526, -0.59999999999999998 },
{ 1.6857503548125963, -0.50000000000000000 },
{ 1.6399998658645112, -0.40000000000000002 },
{ 1.6080486199305128, -0.30000000000000004 },
{ 1.5868678474541660, -0.19999999999999996 },
{ 1.5747455615173562, -0.099999999999999978 },
{ 1.5707963267948966, 0.0000000000000000 },
{ 1.5747455615173562, 0.10000000000000009 },
{ 1.5868678474541660, 0.19999999999999996 },
{ 1.6080486199305128, 0.30000000000000004 },
{ 1.6399998658645112, 0.39999999999999991 },
{ 1.6857503548125963, 0.50000000000000000 },
{ 1.7507538029157526, 0.60000000000000009 },
{ 1.8456939983747236, 0.69999999999999996 },
{ 1.9953027776647296, 0.80000000000000004 },
{ 2.2805491384227703, 0.89999999999999991 },
{ 2.2805491384227703, -0.90000000000000002, 0.0 },
{ 1.9953027776647294, -0.80000000000000004, 0.0 },
{ 1.8456939983747234, -0.69999999999999996, 0.0 },
{ 1.7507538029157526, -0.59999999999999998, 0.0 },
{ 1.6857503548125961, -0.50000000000000000, 0.0 },
{ 1.6399998658645112, -0.39999999999999991, 0.0 },
{ 1.6080486199305128, -0.29999999999999993, 0.0 },
{ 1.5868678474541662, -0.19999999999999996, 0.0 },
{ 1.5747455615173560, -0.099999999999999978, 0.0 },
{ 1.5707963267948966, 0.0000000000000000, 0.0 },
{ 1.5747455615173560, 0.10000000000000009, 0.0 },
{ 1.5868678474541662, 0.20000000000000018, 0.0 },
{ 1.6080486199305128, 0.30000000000000004, 0.0 },
{ 1.6399998658645112, 0.40000000000000013, 0.0 },
{ 1.6857503548125961, 0.50000000000000000, 0.0 },
{ 1.7507538029157526, 0.60000000000000009, 0.0 },
{ 1.8456939983747238, 0.70000000000000018, 0.0 },
{ 1.9953027776647294, 0.80000000000000004, 0.0 },
{ 2.2805491384227707, 0.90000000000000013, 0.0 },
};
const double toler001 = 2.5000000000000020e-13;
template<typename Tp, unsigned int Num>
template<typename Ret, unsigned int Num>
void
test(const testcase_comp_ellint_1<Tp> (&data)[Num], Tp toler)
test(const testcase_comp_ellint_1<Ret> (&data)[Num], Ret toler)
{
const Tp eps = std::numeric_limits<Tp>::epsilon();
Tp max_abs_diff = -Tp(1);
Tp max_abs_frac = -Tp(1);
bool test __attribute__((unused)) = true;
const Ret eps = std::numeric_limits<Ret>::epsilon();
Ret max_abs_diff = -Ret(1);
Ret max_abs_frac = -Ret(1);
unsigned int num_datum = Num;
for (unsigned int i = 0; i < num_datum; ++i)
{
const Tp f = std::comp_ellint_1(data[i].k);
const Tp f0 = data[i].f0;
const Tp diff = f - f0;
const Ret f = std::comp_ellint_1(data[i].k);
const Ret f0 = data[i].f0;
const Ret 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)
if (std::abs(f0) > Ret(10) * eps
&& std::abs(f) > Ret(10) * eps)
{
const Tp frac = diff / f0;
const Ret frac = diff / f0;
if (std::abs(frac) > max_abs_frac)
max_abs_frac = std::abs(frac);
}
......
......@@ -39,52 +39,56 @@
#include <specfun_testcase.h>
// Test data.
// max(|f - f_GSL|): 6.6613381477509392e-16
// max(|f - f_GSL| / |f_GSL|): 4.4233707954398090e-16
// max(|f - f_Boost|): 1.1102230246251565e-15 at index 13
// max(|f - f_Boost| / |f_Boost|): 7.3722846590663481e-16
// mean(f - f_Boost): 1.7529837230923525e-16
// variance(f - f_Boost): 1.8020397140465364e-33
// stddev(f - f_Boost): 4.2450438325729176e-17
const testcase_comp_ellint_2<double>
data001[19] =
{
{ 1.1716970527816140, -0.90000000000000002 },
{ 1.2763499431699064, -0.80000000000000004 },
{ 1.3556611355719554, -0.69999999999999996 },
{ 1.4180833944487241, -0.59999999999999998 },
{ 1.4674622093394274, -0.50000000000000000 },
{ 1.5059416123600402, -0.40000000000000002 },
{ 1.5348334649232491, -0.30000000000000004 },
{ 1.5549685462425291, -0.19999999999999996 },
{ 1.5668619420216685, -0.099999999999999978 },
{ 1.5707963267948966, 0.0000000000000000 },
{ 1.5668619420216685, 0.10000000000000009 },
{ 1.5549685462425291, 0.19999999999999996 },
{ 1.5348334649232491, 0.30000000000000004 },
{ 1.5059416123600404, 0.39999999999999991 },
{ 1.4674622093394274, 0.50000000000000000 },
{ 1.4180833944487241, 0.60000000000000009 },
{ 1.3556611355719554, 0.69999999999999996 },
{ 1.2763499431699064, 0.80000000000000004 },
{ 1.1716970527816144, 0.89999999999999991 },
{ 1.1716970527816142, -0.90000000000000002, 0.0 },
{ 1.2763499431699064, -0.80000000000000004, 0.0 },
{ 1.3556611355719554, -0.69999999999999996, 0.0 },
{ 1.4180833944487243, -0.59999999999999998, 0.0 },
{ 1.4674622093394272, -0.50000000000000000, 0.0 },
{ 1.5059416123600404, -0.39999999999999991, 0.0 },
{ 1.5348334649232491, -0.29999999999999993, 0.0 },
{ 1.5549685462425293, -0.19999999999999996, 0.0 },
{ 1.5668619420216683, -0.099999999999999978, 0.0 },
{ 1.5707963267948966, 0.0000000000000000, 0.0 },
{ 1.5668619420216683, 0.10000000000000009, 0.0 },
{ 1.5549685462425293, 0.20000000000000018, 0.0 },
{ 1.5348334649232491, 0.30000000000000004, 0.0 },
{ 1.5059416123600402, 0.40000000000000013, 0.0 },
{ 1.4674622093394272, 0.50000000000000000, 0.0 },
{ 1.4180833944487241, 0.60000000000000009, 0.0 },
{ 1.3556611355719554, 0.70000000000000018, 0.0 },
{ 1.2763499431699064, 0.80000000000000004, 0.0 },
{ 1.1716970527816140, 0.90000000000000013, 0.0 },
};
const double toler001 = 2.5000000000000020e-13;
template<typename Tp, unsigned int Num>
template<typename Ret, unsigned int Num>
void
test(const testcase_comp_ellint_2<Tp> (&data)[Num], Tp toler)
test(const testcase_comp_ellint_2<Ret> (&data)[Num], Ret toler)
{
const Tp eps = std::numeric_limits<Tp>::epsilon();
Tp max_abs_diff = -Tp(1);
Tp max_abs_frac = -Tp(1);
bool test __attribute__((unused)) = true;
const Ret eps = std::numeric_limits<Ret>::epsilon();
Ret max_abs_diff = -Ret(1);
Ret max_abs_frac = -Ret(1);
unsigned int num_datum = Num;
for (unsigned int i = 0; i < num_datum; ++i)
{
const Tp f = std::comp_ellint_2(data[i].k);
const Tp f0 = data[i].f0;
const Tp diff = f - f0;
const Ret f = std::comp_ellint_2(data[i].k);
const Ret f0 = data[i].f0;
const Ret 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)
if (std::abs(f0) > Ret(10) * eps
&& std::abs(f) > Ret(10) * eps)
{
const Tp frac = diff / f0;
const Ret frac = diff / f0;
if (std::abs(frac) > max_abs_frac)
max_abs_frac = std::abs(frac);
}
......
// { dg-do run { target c++11 } }
// { dg-require-c-std "" }
// { dg-add-options ieee }
// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
#include <cmath>
#include <testsuite_hooks.h>
void
test01()
{
double Pi1 = std::comp_ellint_3(0.75, 0.0);
VERIFY(std::abs(Pi1 - 1.91099) < 0.00001);
double Pi2 = std::comp_ellint_3(0.75, 0.5);
VERIFY(std::abs(Pi2 - 2.80011) < 0.00001);
}
int
main()
{
test01();
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
// { dg-do run { target c++11 } }
// { dg-require-c-std "" }
// { dg-add-options ieee }
// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
#include <cmath>
#include <testsuite_hooks.h>
void
test01()
{
const double pi = 3.141592654;
double Pi1 = std::ellint_3(0.75, 0.0, pi / 2.0);
VERIFY(std::abs(Pi1 - 1.91099) < 0.00001);
double Pi2 = std::ellint_3(0.75, 0.5, pi / 2.0);
VERIFY(std::abs(Pi2 - 2.80011) < 0.00001);
}
int
main()
{
test01();
return 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
// { dg-do run { target c++11 } }
// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
//
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
// Copyright (C) 2016-2017 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
......@@ -19,78 +20,85 @@
// comp_ellint_1
// 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 <tr1/cmath>
#if defined(__TEST_DEBUG)
#include <iostream>
#define VERIFY(A) \
if (!(A)) \
{ \
std::cout << "line " << __LINE__ \
<< " max_abs_frac = " << max_abs_frac \
<< std::endl; \
}
# include <iostream>
# define VERIFY(A) \
if (!(A)) \
{ \
std::cout << "line " << __LINE__ \
<< " max_abs_frac = " << max_abs_frac \
<< std::endl; \
}
#else
#include <testsuite_hooks.h>
# include <testsuite_hooks.h>
#endif
#include "../testcase.h"
#include <specfun_testcase.h>
// Test data.
testcase_comp_ellint_1<double> data001[] = {
{ 2.2805491384227703, -0.90000000000000002 },
{ 1.9953027776647296, -0.80000000000000004 },
{ 1.8456939983747236, -0.69999999999999996 },
{ 1.7507538029157526, -0.59999999999999998 },
{ 1.6857503548125963, -0.50000000000000000 },
{ 1.6399998658645112, -0.40000000000000002 },
{ 1.6080486199305126, -0.30000000000000004 },
{ 1.5868678474541664, -0.19999999999999996 },
{ 1.5747455615173562, -0.099999999999999978 },
{ 1.5707963267948966, 0.0000000000000000 },
{ 1.5747455615173562, 0.10000000000000009 },
{ 1.5868678474541664, 0.19999999999999996 },
{ 1.6080486199305126, 0.30000000000000004 },
{ 1.6399998658645112, 0.39999999999999991 },
{ 1.6857503548125963, 0.50000000000000000 },
{ 1.7507538029157526, 0.60000000000000009 },
{ 1.8456939983747236, 0.69999999999999996 },
{ 1.9953027776647296, 0.80000000000000004 },
{ 2.2805491384227699, 0.89999999999999991 },
// max(|f - f_Boost|): 4.4408920985006262e-16 at index 18
// max(|f - f_Boost| / |f_Boost|): 1.9472906870017937e-16
// mean(f - f_Boost): -1.1686558153949016e-17
// variance(f - f_Boost): 1.2181788466954587e-32
// stddev(f - f_Boost): 1.1037113964689586e-16
const testcase_comp_ellint_1<double>
data001[19] =
{
{ 2.2805491384227703, -0.90000000000000002, 0.0 },
{ 1.9953027776647294, -0.80000000000000004, 0.0 },
{ 1.8456939983747234, -0.69999999999999996, 0.0 },
{ 1.7507538029157526, -0.59999999999999998, 0.0 },
{ 1.6857503548125961, -0.50000000000000000, 0.0 },
{ 1.6399998658645112, -0.39999999999999991, 0.0 },
{ 1.6080486199305128, -0.29999999999999993, 0.0 },
{ 1.5868678474541662, -0.19999999999999996, 0.0 },
{ 1.5747455615173560, -0.099999999999999978, 0.0 },
{ 1.5707963267948966, 0.0000000000000000, 0.0 },
{ 1.5747455615173560, 0.10000000000000009, 0.0 },
{ 1.5868678474541662, 0.20000000000000018, 0.0 },
{ 1.6080486199305128, 0.30000000000000004, 0.0 },
{ 1.6399998658645112, 0.40000000000000013, 0.0 },
{ 1.6857503548125961, 0.50000000000000000, 0.0 },
{ 1.7507538029157526, 0.60000000000000009, 0.0 },
{ 1.8456939983747238, 0.70000000000000018, 0.0 },
{ 1.9953027776647294, 0.80000000000000004, 0.0 },
{ 2.2805491384227707, 0.90000000000000013, 0.0 },
};
const double toler001 = 2.5000000000000020e-13;
// Test function.
template <typename Tp>
void test001()
{
const Tp eps = std::numeric_limits<Tp>::epsilon();
Tp max_abs_diff = -Tp(1);
Tp max_abs_frac = -Tp(1);
unsigned int num_datum = sizeof(data001)
/ sizeof(testcase_comp_ellint_1<double>);
for (unsigned int i = 0; i < num_datum; ++i)
{
const Tp f = std::tr1::comp_ellint_1(Tp(data001[i].k));
const Tp f0 = data001[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 < Tp(2.5000000000000020e-13));
}
template<typename Ret, unsigned int Num>
void
test(const testcase_comp_ellint_1<Ret> (&data)[Num], Ret toler)
{
bool test __attribute__((unused)) = true;
const Ret eps = std::numeric_limits<Ret>::epsilon();
Ret max_abs_diff = -Ret(1);
Ret max_abs_frac = -Ret(1);
unsigned int num_datum = Num;
for (unsigned int i = 0; i < num_datum; ++i)
{
const Ret f = std::tr1::comp_ellint_1(data[i].k);
const Ret f0 = data[i].f0;
const Ret diff = f - f0;
if (std::abs(diff) > max_abs_diff)
max_abs_diff = std::abs(diff);
if (std::abs(f0) > Ret(10) * eps
&& std::abs(f) > Ret(10) * eps)
{
const Ret frac = diff / f0;
if (std::abs(frac) > max_abs_frac)
max_abs_frac = std::abs(frac);
}
}
VERIFY(max_abs_frac < toler);
}
int main(int, char**)
int
main()
{
test001<double>();
test(data001, toler001);
return 0;
}
// 2007-02-04 Edward Smith-Rowland <3dw4rd@verizon.net>
// { dg-do run { target c++11 } }
// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
//
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
// Copyright (C) 2016-2017 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
......@@ -19,78 +20,85 @@
// comp_ellint_2
// 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 <tr1/cmath>
#if defined(__TEST_DEBUG)
#include <iostream>
#define VERIFY(A) \
if (!(A)) \
{ \
std::cout << "line " << __LINE__ \
<< " max_abs_frac = " << max_abs_frac \
<< std::endl; \
}
# include <iostream>
# define VERIFY(A) \
if (!(A)) \
{ \
std::cout << "line " << __LINE__ \
<< " max_abs_frac = " << max_abs_frac \
<< std::endl; \
}
#else
#include <testsuite_hooks.h>
# include <testsuite_hooks.h>
#endif
#include "../testcase.h"
#include <specfun_testcase.h>
// Test data.
testcase_comp_ellint_2<double> data001[] = {
{ 1.1716970527816140, -0.90000000000000002 },
{ 1.2763499431699066, -0.80000000000000004 },
{ 1.3556611355719557, -0.69999999999999996 },
{ 1.4180833944487243, -0.59999999999999998 },
{ 1.4674622093394274, -0.50000000000000000 },
{ 1.5059416123600402, -0.40000000000000002 },
{ 1.5348334649232489, -0.30000000000000004 },
{ 1.5549685462425296, -0.19999999999999996 },
{ 1.5668619420216685, -0.099999999999999978 },
{ 1.5707963267948966, 0.0000000000000000 },
{ 1.5668619420216685, 0.10000000000000009 },
{ 1.5549685462425296, 0.19999999999999996 },
{ 1.5348334649232489, 0.30000000000000004 },
{ 1.5059416123600404, 0.39999999999999991 },
{ 1.4674622093394274, 0.50000000000000000 },
{ 1.4180833944487241, 0.60000000000000009 },
{ 1.3556611355719557, 0.69999999999999996 },
{ 1.2763499431699066, 0.80000000000000004 },
{ 1.1716970527816142, 0.89999999999999991 },
// max(|f - f_Boost|): 1.1102230246251565e-15 at index 13
// max(|f - f_Boost| / |f_Boost|): 7.3722846590663481e-16
// mean(f - f_Boost): 1.7529837230923525e-16
// variance(f - f_Boost): 1.8020397140465364e-33
// stddev(f - f_Boost): 4.2450438325729176e-17
const testcase_comp_ellint_2<double>
data001[19] =
{
{ 1.1716970527816142, -0.90000000000000002, 0.0 },
{ 1.2763499431699064, -0.80000000000000004, 0.0 },
{ 1.3556611355719554, -0.69999999999999996, 0.0 },
{ 1.4180833944487243, -0.59999999999999998, 0.0 },
{ 1.4674622093394272, -0.50000000000000000, 0.0 },
{ 1.5059416123600404, -0.39999999999999991, 0.0 },
{ 1.5348334649232491, -0.29999999999999993, 0.0 },
{ 1.5549685462425293, -0.19999999999999996, 0.0 },
{ 1.5668619420216683, -0.099999999999999978, 0.0 },
{ 1.5707963267948966, 0.0000000000000000, 0.0 },
{ 1.5668619420216683, 0.10000000000000009, 0.0 },
{ 1.5549685462425293, 0.20000000000000018, 0.0 },
{ 1.5348334649232491, 0.30000000000000004, 0.0 },
{ 1.5059416123600402, 0.40000000000000013, 0.0 },
{ 1.4674622093394272, 0.50000000000000000, 0.0 },
{ 1.4180833944487241, 0.60000000000000009, 0.0 },
{ 1.3556611355719554, 0.70000000000000018, 0.0 },
{ 1.2763499431699064, 0.80000000000000004, 0.0 },
{ 1.1716970527816140, 0.90000000000000013, 0.0 },
};
const double toler001 = 2.5000000000000020e-13;
// Test function.
template <typename Tp>
void test001()
{
const Tp eps = std::numeric_limits<Tp>::epsilon();
Tp max_abs_diff = -Tp(1);
Tp max_abs_frac = -Tp(1);
unsigned int num_datum = sizeof(data001)
/ sizeof(testcase_comp_ellint_2<double>);
for (unsigned int i = 0; i < num_datum; ++i)
{
const Tp f = std::tr1::comp_ellint_2(Tp(data001[i].k));
const Tp f0 = data001[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 < Tp(5.0000000000000039e-13));
}
template<typename Ret, unsigned int Num>
void
test(const testcase_comp_ellint_2<Ret> (&data)[Num], Ret toler)
{
bool test __attribute__((unused)) = true;
const Ret eps = std::numeric_limits<Ret>::epsilon();
Ret max_abs_diff = -Ret(1);
Ret max_abs_frac = -Ret(1);
unsigned int num_datum = Num;
for (unsigned int i = 0; i < num_datum; ++i)
{
const Ret f = std::tr1::comp_ellint_2(data[i].k);
const Ret f0 = data[i].f0;
const Ret diff = f - f0;
if (std::abs(diff) > max_abs_diff)
max_abs_diff = std::abs(diff);
if (std::abs(f0) > Ret(10) * eps
&& std::abs(f) > Ret(10) * eps)
{
const Ret frac = diff / f0;
if (std::abs(frac) > max_abs_frac)
max_abs_frac = std::abs(frac);
}
}
VERIFY(max_abs_frac < toler);
}
int main(int, char**)
int
main()
{
test001<double>();
test(data001, toler001);
return 0;
}
#include <tr1/cmath>
#include <testsuite_hooks.h>
void
test01()
{
double Pi1 = std::tr1::comp_ellint_3(0.75, 0.0);
VERIFY(std::abs(Pi1 - 1.91099) < 0.00001);
double Pi2 = std::tr1::comp_ellint_3(0.75, 0.5);
VERIFY(std::abs(Pi2 - 2.80011) < 0.00001);
}
int
main()
{
test01();
return 0;
}
#include <tr1/cmath>
#include <testsuite_hooks.h>
void
test01()
{
const double pi = 3.141592654;
double Pi1 = std::tr1::ellint_3(0.75, 0.0, pi / 2.0);
VERIFY(std::abs(Pi1 - 1.91099) < 0.00001);
double Pi2 = std::tr1::ellint_3(0.75, 0.5, pi / 2.0);
VERIFY(std::abs(Pi2 - 2.80011) < 0.00001);
}
int
main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment