Skip to content

Commit 94c0413

Browse files
authored
Merge pull request #521 from cppalliance/t_gamma_bama_jama
Fix #519 via `tgamma()` 128-bit coefficient list
2 parents b2798ed + c2b3312 commit 94c0413

File tree

5 files changed

+238
-25
lines changed

5 files changed

+238
-25
lines changed

include/boost/decimal/detail/cmath/impl/lgamma_impl.hpp

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,38 @@ struct lgamma_taylor_series_imp
9393
+ decimal64 { UINT64_C(384'615'390'346'751'857), -19 }, // x^26
9494
}};
9595

96-
// TODO: add d128_coeffs
96+
static constexpr std::array<decimal128, 25> d128_coeffs =
97+
{{
98+
// Use a Taylor series expansion of the logarithm of the gamma function.
99+
// N[Series[Log[Gamma[x]], {x, 0, 26}], 32]
100+
// log(1/x)
101+
// -EulerGamma // * x
102+
decimal128 { UINT64_C(822'467'033'424'113'218), -18 }, // x^2
103+
- decimal128 { UINT64_C(400'685'634'386'531'428), -18 }, // x^3
104+
+ decimal128 { UINT64_C(270'580'808'427'784'548), -18 }, // x^4
105+
- decimal128 { UINT64_C(207'385'551'028'673'985), -18 }, // x^5
106+
+ decimal128 { UINT64_C(169'557'176'997'408'190), -18 }, // x^6
107+
- decimal128 { UINT64_C(144'049'896'768'846'118), -18 }, // x^7
108+
+ decimal128 { UINT64_C(125'509'669'524'743'042), -18 }, // x^8
109+
- decimal128 { UINT64_C(111'334'265'869'564'690), -18 }, // x^9
110+
+ decimal128 { UINT64_C(100'099'457'512'781'809), -18 }, // x^10
111+
- decimal128 { UINT64_C(909'540'171'458'290'422), -19 }, // x^11
112+
+ decimal128 { UINT64_C(833'538'405'461'090'040), -19 }, // x^12
113+
- decimal128 { UINT64_C(769'325'164'113'521'915), -19 }, // x^13
114+
+ decimal128 { UINT64_C(714'329'462'953'613'361), -19 }, // x^14
115+
- decimal128 { UINT64_C(666'687'058'824'204'680), -19 }, // x^15
116+
+ decimal128 { UINT64_C(625'009'551'412'130'407), -19 }, // x^16
117+
- decimal128 { UINT64_C(588'239'786'586'845'823), -19 }, // x^17
118+
+ decimal128 { UINT64_C(555'557'676'274'036'111), -19 }, // x^18
119+
- decimal128 { UINT64_C(526'316'793'796'166'607), -19 }, // x^19
120+
+ decimal128 { UINT64_C(500'000'476'981'016'936), -19 }, // x^20
121+
- decimal128 { UINT64_C(476'190'703'301'422'280), -19 }, // x^21
122+
+ decimal128 { UINT64_C(454'545'562'932'046'694), -19 }, // x^22
123+
- decimal128 { UINT64_C(434'782'660'530'402'594), -19 }, // x^23
124+
+ decimal128 { UINT64_C(416'666'691'503'412'105), -19 }, // x^24
125+
- decimal128 { UINT64_C(400'000'011'921'401'406), -19 }, // x^25
126+
+ decimal128 { UINT64_C(384'615'390'346'751'857), -19 }, // x^26
127+
}};
97128
};
98129

99130
template <bool b>
@@ -166,6 +197,40 @@ struct lgamma_laurent_series_imp
166197
- decimal64 { UINT64_C(328'565'400'725'242'178), + 2 - 18 }, // * x^-25
167198
+ decimal64 { UINT64_C(549'592'170'046'323'711), + 4 - 18 }, // * x^-26
168199
}};
200+
201+
static constexpr std::array<decimal128, 26> d128_coeffs = {{
202+
// Use a Laurent infinite-series expansion of the logarithm of the
203+
// gamma function divided by the square root.
204+
// N[Series[Log[Gamma[x]], {x, Infinity, 26}], 32]
205+
// log( e^-x * x^x * sqrt(x) * [Series below] )
206+
// See also Wolfram Alpha(R): https://www.wolframalpha.com/input?i=Series%5BLog%5BGamma%5Bx%5D%5D%2C+%7Bx%2C+Infinity%2C+4%7D%5D
207+
decimal128 { UINT64_C(250'662'827'463'100'050), + 1 - 18 }, // * x^-1
208+
+ decimal128 { UINT64_C(208'885'689'552'583'375), - 0 - 18 }, // * x^-2
209+
+ decimal128 { UINT64_C(870'357'039'802'430'730), - 2 - 18 }, // * x^-3
210+
- decimal128 { UINT64_C(672'109'047'402'988'175), - 2 - 18 }, // * x^-4
211+
- decimal128 { UINT64_C(575'201'238'110'171'235), - 3 - 18 }, // * x^-5
212+
+ decimal128 { UINT64_C(196'529'488'158'320'306), - 2 - 18 }, // * x^-6
213+
+ decimal128 { UINT64_C(174'782'521'204'559'121), - 3 - 18 }, // * x^-7
214+
- decimal128 { UINT64_C(148'434'113'515'827'614), - 2 - 18 }, // * x^-8
215+
- decimal128 { UINT64_C(129'637'573'211'255'432), - 3 - 18 }, // * x^-9
216+
+ decimal128 { UINT64_C(210'431'122'975'320'637), - 2 - 18 }, // * x^-10
217+
+ decimal128 { UINT64_C(180'599'945'655'550'436), - 3 - 18 }, // * x^-11
218+
- decimal128 { UINT64_C(479'878'567'054'634'606), - 2 - 18 }, // * x^-12
219+
- decimal128 { UINT64_C(407'367'859'381'525'183), - 3 - 18 }, // * x^-13
220+
+ decimal128 { UINT64_C(160'508'503'319'445'960), - 1 - 18 }, // * x^-14
221+
+ decimal128 { UINT64_C(135'399'228'015'909'411), - 2 - 18 }, // * x^-15
222+
- decimal128 { UINT64_C(740'154'212'684'273'819), - 1 - 18 }, // * x^-16
223+
- decimal128 { UINT64_C(622'080'867'880'877'866), - 2 - 18 }, // * x^-17
224+
+ decimal128 { UINT64_C(450'040'333'856'250'984), - 0 - 18 }, // * x^-18
225+
+ decimal128 { UINT64_C(377'400'786'521'707'440), - 1 - 18 }, // * x^-19
226+
- decimal128 { UINT64_C(348'872'797'304'123'310), + 1 - 18 }, // * x^-20
227+
- decimal128 { UINT64_C(292'138'192'227'179'792), - 0 - 18 }, // * x^-21
228+
+ decimal128 { UINT64_C(335'837'691'649'553'084), + 2 - 18 }, // * x^-22
229+
+ decimal128 { UINT64_C(280'944'016'052'174'395), + 1 - 18 }, // * x^-23
230+
- decimal128 { UINT64_C(393'042'854'585'987'930), + 3 - 18 }, // * x^-24
231+
- decimal128 { UINT64_C(328'565'400'725'242'178), + 2 - 18 }, // * x^-25
232+
+ decimal128 { UINT64_C(549'592'170'046'323'711), + 4 - 18 }, // * x^-26
233+
}};
169234
};
170235

171236
#if !(defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L) && (!defined(_MSC_VER) || _MSC_VER != 1900)
@@ -176,12 +241,18 @@ constexpr std::array<decimal32, 25> lgamma_taylor_series_imp<b>::d32_coeffs;
176241
template <bool b>
177242
constexpr std::array<decimal64, 25> lgamma_taylor_series_imp<b>::d64_coeffs;
178243

244+
template <bool b>
245+
constexpr std::array<decimal128, 25> lgamma_taylor_series_imp<b>::d128_coeffs;
246+
179247
template <bool b>
180248
constexpr std::array<decimal32, 26> lgamma_laurent_series_imp<b>::d32_coeffs;
181249

182250
template <bool b>
183251
constexpr std::array<decimal64, 26> lgamma_laurent_series_imp<b>::d64_coeffs;
184252

253+
template <bool b>
254+
constexpr std::array<decimal128, 26> lgamma_laurent_series_imp<b>::d128_coeffs;
255+
185256
#endif
186257

187258
} //namespace lgamma_detail
@@ -190,14 +261,7 @@ using lgamma_taylor_series_table = lgamma_detail::lgamma_taylor_series_imp<true>
190261
using lgamma_laurent_series_table = lgamma_detail::lgamma_laurent_series_imp<true>;
191262

192263
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
193-
constexpr auto lgamma_taylor_series_expansion(T x) noexcept
194-
{
195-
// LCOV_EXCL_START
196-
static_assert(!std::is_same<T, decimal128>::value, "Decimal128 has not been implemented");
197-
static_cast<void>(x);
198-
return T{1,0,true};
199-
// LCOV_EXCL_STOP
200-
}
264+
constexpr auto lgamma_taylor_series_expansion(T x) noexcept;
201265

202266
template <>
203267
constexpr auto lgamma_taylor_series_expansion<decimal32>(decimal32 x) noexcept
@@ -211,16 +275,15 @@ constexpr auto lgamma_taylor_series_expansion<decimal64>(decimal64 x) noexcept
211275
return taylor_series_result(x, lgamma_taylor_series_table::d64_coeffs);
212276
}
213277

214-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
215-
constexpr auto lgamma_laurent_series_expansion(T x) noexcept
278+
template <>
279+
constexpr auto lgamma_taylor_series_expansion<decimal128>(decimal128 x) noexcept
216280
{
217-
// LCOV_EXCL_START
218-
static_assert(!std::is_same<T, decimal128>::value, "Decimal128 has not been implemented");
219-
static_cast<void>(x);
220-
return T{1,0,true};
221-
// LCOV_EXCL_STOP
281+
return taylor_series_result(x, lgamma_taylor_series_table::d128_coeffs);
222282
}
223283

284+
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
285+
constexpr auto lgamma_laurent_series_expansion(T x) noexcept;
286+
224287
template <>
225288
constexpr auto lgamma_laurent_series_expansion<decimal32>(decimal32 x) noexcept
226289
{
@@ -233,6 +296,12 @@ constexpr auto lgamma_laurent_series_expansion<decimal64>(decimal64 x) noexcept
233296
return taylor_series_result(x, lgamma_laurent_series_table::d64_coeffs);
234297
}
235298

299+
template <>
300+
constexpr auto lgamma_laurent_series_expansion<decimal128>(decimal128 x) noexcept
301+
{
302+
return taylor_series_result(x, lgamma_laurent_series_table::d128_coeffs);
303+
}
304+
236305
} //namespace detail
237306
} //namespace decimal
238307
} //namespace boost

include/boost/decimal/detail/cmath/impl/taylor_series_result.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ constexpr auto taylor_series_result(T x, const Array &coeffs) noexcept
2727
return result;
2828
}
2929

30+
template <typename Array>
31+
constexpr auto taylor_series_result(boost::decimal::decimal128 x, const Array &coeffs) noexcept
32+
{
33+
const std::size_t N = coeffs.size();
34+
35+
auto result = coeffs[N - 1];
36+
37+
auto my_own_fma =
38+
[](boost::decimal::decimal128 x, boost::decimal::decimal128 y, boost::decimal::decimal128 z)
39+
{
40+
return (x * y) + z;
41+
};
42+
43+
for (std::size_t i = N - 1; i-- > 0;)
44+
{
45+
result = my_own_fma(result, x, coeffs[i]);
46+
}
47+
48+
return result;
49+
}
50+
3051
} //namespace detail
3152
} //namespace decimal
3253
} //namespace boost

include/boost/decimal/detail/cmath/impl/tgamma_impl.hpp

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,55 @@ struct tgamma_table_imp
7474
-::boost::decimal::decimal64 { UINT64_C(1'181'259'301'697'458'770), - 19 - 15 }, // * z^26
7575
+::boost::decimal::decimal64 { UINT64_C(1'186'692'254'751'600'333), - 19 - 17 }, // * z^27
7676
}};
77+
78+
static constexpr std::array<decimal128, 44> d128_coeffs =
79+
{{
80+
// N[Series[1/Gamma[z], {z, 0, 27}], 24]
81+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(312909238939453), UINT64_C(7916302232898517972) }, -34 }, // * z^2
82+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(355552215013931), UINT64_C(2875353717947891404) }, -34 }, // * z^3
83+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(227696740770409), UINT64_C(1287992959696612036) }, -35 }, // * z^4
84+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(90280762131699), UINT64_C(14660682722320745466) }, -34 }, // * z^5
85+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(228754377395439), UINT64_C(1086189775515439306) }, -35 }, // * z^6
86+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(521608121705894), UINT64_C(2882773517907923486) }, -36 }, // * z^7
87+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(391339697554084), UINT64_C(12203646426790846826) }, -36 }, // * z^8
88+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(63163861720165), UINT64_C(1793625582468481749) }, -36 }, // * z^9
89+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(116682745342423), UINT64_C(7466931387917530902) }, -37 }, // * z^10
90+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(69416197176288), UINT64_C(17486507952476000235) }, -37 }, // * z^11
91+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(109151266480053), UINT64_C(14157573701904186532) }, -38 }, // * z^12
92+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(67789387500902), UINT64_C(6337242598258275460) }, -39 }, // * z^13
93+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(61421529319989), UINT64_C(11330812743044278521) }, -39 }, // * z^14
94+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(111474328952626), UINT64_C(4349913604764276954) }, -40 }, // * z^15
95+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(331554179970335), UINT64_C(8536598537651543980) }, -42 }, // * z^16
96+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(271159377746131), UINT64_C(11232450780359262294) }, -42 }, // * z^17
97+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(64037022781195), UINT64_C(7729482665838775386) }, -42 }, // * z^18
98+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(56564275382244), UINT64_C(15921046388084405946) }, -43 }, // * z^19
99+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(421877346419979), UINT64_C(12114109382397224706) }, -45 }, // * z^20
100+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(200404234149424), UINT64_C(17191629897693416576) }, -45 }, // * z^21
101+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(276491627306932), UINT64_C(18075235341994261118) }, -46 }, // * z^22
102+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(111582078948016), UINT64_C(1315679057212061374) }, -47 }, // * z^23
103+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(289922303798056), UINT64_C(8236273575746269444) }, -48 }, // * z^24
104+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(66503802694735), UINT64_C(8619931044472680662) }, -48 }, // * z^25
105+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(64036195058454), UINT64_C(13570784405336680634) }, -49 }, // * z^26
106+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(64330716033670), UINT64_C(6228121739584017954) }, -51 }, // * z^27
107+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(76565308743615), UINT64_C(9665163337994634860) }, -51 },
108+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(124615253252825), UINT64_C(5713012462345318490) }, -52 },
109+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(92938152937825), UINT64_C(2160517649493992050) }, -53 },
110+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(72497982578925), UINT64_C(10055707640313829460) }, -55 },
111+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(111360223980902), UINT64_C(528747408384118098) }, -55 },
112+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(148320486134320), UINT64_C(12662323637555269860) }, -56 },
113+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(93911231108772), UINT64_C(8663955293807189228) }, -57 },
114+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(127969413738636), UINT64_C(17978922200959991754) }, -59 },
115+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(101100927852914), UINT64_C(16158702556622869636) }, -59 },
116+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(120243204727301), UINT64_C(13141135468649758444) }, -60 },
117+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(70352901832557), UINT64_C(2975454173305568482) }, -61 },
118+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(64005738370342), UINT64_C(18063645830042937300) }, -63 },
119+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(60963839731470), UINT64_C(14965217315129705920) }, -63 },
120+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(69230926066837), UINT64_C(16656915204960392533) }, -64 },
121+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(400691370795862), UINT64_C(16972369904241895558) }, -66 },
122+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(61514934723438), UINT64_C(5918930041313493498) }, -68 },
123+
+::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(251487992814431), UINT64_C(6680121266003781724) }, -68 },
124+
-::boost::decimal::decimal128 { boost::decimal::detail::uint128 { UINT64_C(289879709778175), UINT64_C(4432551928123929090) }, -69 },
125+
}};
77126
};
78127

79128
#if !(defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L) && (!defined(_MSC_VER) || _MSC_VER != 1900)
@@ -84,21 +133,17 @@ constexpr std::array<decimal32, 15> tgamma_table_imp<b>::d32_coeffs;
84133
template <bool b>
85134
constexpr std::array<decimal64, 36> tgamma_table_imp<b>::d64_coeffs;
86135

136+
template <bool b>
137+
constexpr std::array<decimal128, 44> tgamma_table_imp<b>::d128_coeffs;
138+
87139
#endif
88140

89141
} //namespace tgamma_detail
90142

91143
using tgamma_table = tgamma_detail::tgamma_table_imp<true>;
92144

93145
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
94-
constexpr auto tgamma_series_expansion(T z) noexcept
95-
{
96-
// LCOV_EXCL_START
97-
static_assert(!std::is_same<T, decimal128>::value, "Decimal128 has not been implemented");
98-
static_cast<void>(z);
99-
return T{1,0,true};
100-
// LCOV_EXCL_STOP
101-
}
146+
constexpr auto tgamma_series_expansion(T z) noexcept;
102147

103148
template <>
104149
constexpr auto tgamma_series_expansion<decimal32>(decimal32 z) noexcept
@@ -112,6 +157,12 @@ constexpr auto tgamma_series_expansion<decimal64>(decimal64 z) noexcept
112157
return taylor_series_result(z, tgamma_table::d64_coeffs);
113158
}
114159

160+
template <>
161+
constexpr auto tgamma_series_expansion<decimal128>(decimal128 z) noexcept
162+
{
163+
return taylor_series_result(z, tgamma_table::d128_coeffs);
164+
}
165+
115166
} //namespace detail
116167
} //namespace decimal
117168
} //namespace boost

include/boost/decimal/detail/cmath/tgamma.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ constexpr auto tgamma_impl(T x) noexcept
9999
z = z - nx;
100100
}
101101

102+
auto my_own_fma =
103+
[](T x, T y, T z)
104+
{
105+
return (x * y) + z;
106+
};
107+
102108
result = detail::tgamma_series_expansion(z);
103-
result = one / (z * fma(result, z, one));
109+
result = one / (z * my_own_fma(result, z, one));
104110

105111
if (x_is_gt_one)
106112
{

test/test_tgamma.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,64 @@ namespace local
316316

317317
return result_is_ok;
318318
}
319+
320+
auto test_tgamma_128(const int tol_factor) -> bool
321+
{
322+
using decimal_type = boost::decimal::decimal128;
323+
324+
using str_ctrl_array_type = std::array<const char*, 9U>;
325+
326+
const str_ctrl_array_type ctrl_strings =
327+
{{
328+
// Table[N[Gamma[(100 n + 10 n + 1)/100], 33], {n, 1, 9, 1}]
329+
"0.947395504039301942134227647281424",
330+
"1.10784755653406415338349971053114",
331+
"2.71139823924390323650711692085896",
332+
"10.2754040920152050479188001843206",
333+
"53.1934282525008207389522379291890",
334+
"350.998609824200588801455504140098",
335+
"2825.09453680418713613816084109635",
336+
"26903.6719467497675679082571845063",
337+
"296439.082102472192334520537379648"
338+
}};
339+
340+
std::array<decimal_type, std::tuple_size<str_ctrl_array_type>::value> tg_values { };
341+
std::array<decimal_type, std::tuple_size<str_ctrl_array_type>::value> ctrl_values { };
342+
343+
int n { 1 };
344+
345+
bool result_is_ok { true };
346+
347+
const decimal_type my_tol { std::numeric_limits<decimal_type>::epsilon() * static_cast<decimal_type>(tol_factor) };
348+
349+
for(auto i = static_cast<std::size_t>(UINT8_C(0)); i < std::tuple_size<str_ctrl_array_type>::value; ++i)
350+
{
351+
decimal_type x_arg =
352+
decimal_type
353+
{
354+
decimal_type { 1, 2 } * n
355+
+ decimal_type { 1, 1 } * n
356+
+ 1
357+
}
358+
/ decimal_type { 1, 2 };
359+
360+
++n;
361+
362+
tg_values[i] = tgamma(x_arg);
363+
364+
static_cast<void>
365+
(
366+
from_chars(ctrl_strings[i], ctrl_strings[i] + std::strlen(ctrl_strings[i]), ctrl_values[i])
367+
);
368+
369+
const auto result_tgamma_is_ok = is_close_fraction(tg_values[i], ctrl_values[i], my_tol);
370+
371+
result_is_ok = (result_tgamma_is_ok && result_is_ok);
372+
}
373+
374+
return result_is_ok;
375+
}
376+
319377
} // namespace local
320378

321379
auto main() -> int
@@ -371,6 +429,14 @@ auto main() -> int
371429
result_is_ok = (result_edge_is_ok && result_is_ok);
372430
}
373431

432+
{
433+
const auto result_tgamma128_is_ok = local::test_tgamma_128(1000000);
434+
435+
BOOST_TEST(result_tgamma128_is_ok);
436+
437+
result_is_ok = (result_tgamma128_is_ok && result_is_ok);
438+
}
439+
374440
result_is_ok = ((boost::report_errors() == 0) && result_is_ok);
375441

376442
return (result_is_ok ? 0 : -1);

0 commit comments

Comments
 (0)