mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-18 14:12:32 +00:00
Complex/mpc: Add remaining non-member functions for complex types.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <boost/multiprecision/detail/number_base.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/math/special_functions/next.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/front.hpp>
|
||||
#include <boost/mpl/fold.hpp>
|
||||
@@ -1500,6 +1501,10 @@ template <class T>
|
||||
typename enable_if_c<sizeof(T) == 0>::type eval_acosh();
|
||||
template <class T>
|
||||
typename enable_if_c<sizeof(T) == 0>::type eval_atanh();
|
||||
template <class T>
|
||||
typename enable_if_c<sizeof(T) == 0>::type eval_conj();
|
||||
template <class T>
|
||||
typename enable_if_c<sizeof(T) == 0>::type eval_proj();
|
||||
|
||||
//
|
||||
// eval_logb and eval_scalbn simply assume base 2 and forward to
|
||||
@@ -1846,6 +1851,49 @@ inline typename boost::enable_if_c<number_category<typename multiprecision::deta
|
||||
return imag(value_type(arg));
|
||||
}
|
||||
|
||||
template <class T, expression_template_option ExpressionTemplates>
|
||||
inline typename boost::lazy_enable_if_c<number_category<T>::value == number_kind_complex, component_type<number<T, ExpressionTemplates> > >::type
|
||||
abs(const number<T, ExpressionTemplates>& v)
|
||||
{
|
||||
return BOOST_MP_MOVE(boost::math::hypot(real(v), imag(v)));
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename boost::lazy_enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_complex, component_type<typename detail::expression<tag, A1, A2, A3, A4>::result_type> >::type
|
||||
abs(const detail::expression<tag, A1, A2, A3, A4>& v)
|
||||
{
|
||||
typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
|
||||
return BOOST_MP_MOVE(abs(static_cast<number_type>(v)));
|
||||
}
|
||||
|
||||
template <class T, expression_template_option ExpressionTemplates>
|
||||
inline typename boost::lazy_enable_if_c<number_category<T>::value == number_kind_complex, component_type<number<T, ExpressionTemplates> > >::type
|
||||
arg(const number<T, ExpressionTemplates>& v)
|
||||
{
|
||||
return BOOST_MP_MOVE(atan2(imag(v), real(v)));
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename boost::lazy_enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_complex, component_type<typename detail::expression<tag, A1, A2, A3, A4>::result_type> >::type
|
||||
arg(const detail::expression<tag, A1, A2, A3, A4>& v)
|
||||
{
|
||||
typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
|
||||
return BOOST_MP_MOVE(arg(static_cast<number_type>(v)));
|
||||
}
|
||||
|
||||
template <class T, expression_template_option ExpressionTemplates>
|
||||
inline typename boost::lazy_enable_if_c<number_category<T>::value == number_kind_complex, component_type<number<T, ExpressionTemplates> > >::type
|
||||
norm(const number<T, ExpressionTemplates>& v)
|
||||
{
|
||||
typename component_type<number<T, ExpressionTemplates> >::type a(v.real()), b(v.imag());
|
||||
return BOOST_MP_MOVE(a * a + b * b);
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename boost::lazy_enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_complex, component_type<typename detail::expression<tag, A1, A2, A3, A4>::result_type> >::type
|
||||
norm(const detail::expression<tag, A1, A2, A3, A4>& v)
|
||||
{
|
||||
typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
|
||||
return BOOST_MP_MOVE(norm(static_cast<number_type>(v)));
|
||||
}
|
||||
|
||||
} // namespace multiprecision
|
||||
|
||||
namespace math {
|
||||
@@ -1876,34 +1924,40 @@ namespace multiprecision{
|
||||
> c99_error_policy;
|
||||
|
||||
template <class Backend, multiprecision::expression_template_option ExpressionTemplates>
|
||||
inline multiprecision::number<Backend, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
inline typename boost::enable_if_c<number_category<Backend>::value != number_kind_complex, multiprecision::number<Backend, ExpressionTemplates> >::type
|
||||
asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
{
|
||||
return boost::math::asinh(arg, c99_error_policy());
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
inline typename boost::enable_if_c<number_category<typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::value != number_kind_complex, typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::type
|
||||
asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
{
|
||||
typedef typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type value_type;
|
||||
return asinh(value_type(arg));
|
||||
}
|
||||
template <class Backend, multiprecision::expression_template_option ExpressionTemplates>
|
||||
inline multiprecision::number<Backend, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
inline typename boost::enable_if_c<number_category<Backend>::value != number_kind_complex, multiprecision::number<Backend, ExpressionTemplates> >::type
|
||||
acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
{
|
||||
return boost::math::acosh(arg, c99_error_policy());
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
inline typename boost::enable_if_c<number_category<typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::value != number_kind_complex, typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::type
|
||||
acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
{
|
||||
typedef typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type value_type;
|
||||
return acosh(value_type(arg));
|
||||
}
|
||||
template <class Backend, multiprecision::expression_template_option ExpressionTemplates>
|
||||
inline multiprecision::number<Backend, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
inline typename boost::enable_if_c<number_category<Backend>::value != number_kind_complex, multiprecision::number<Backend, ExpressionTemplates> >::type
|
||||
atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::number<Backend, ExpressionTemplates>& arg)
|
||||
{
|
||||
return boost::math::atanh(arg, c99_error_policy());
|
||||
}
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
inline typename boost::enable_if_c<number_category<typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::value != number_kind_complex, typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type>::type
|
||||
atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const multiprecision::detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
{
|
||||
typedef typename multiprecision::detail::expression<tag, A1, A2, A3, A4>::result_type value_type;
|
||||
return atanh(value_type(arg));
|
||||
@@ -2887,7 +2941,7 @@ func(const detail::expression<tag, A1, A2, A3, A4>& arg, const detail::expressio
|
||||
}\
|
||||
template <class Backend, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<Backend>::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, number<Backend, et_on> >::value && (number_category<Backend>::value == category),\
|
||||
detail::expression<\
|
||||
detail::function\
|
||||
, detail::BOOST_JOIN(category, BOOST_JOIN(func, _funct))<Backend> \
|
||||
@@ -2910,7 +2964,7 @@ func(const number<Backend, et_on>& arg, const Arithmetic& a)\
|
||||
}\
|
||||
template <class tag, class A1, class A2, class A3, class A4, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<detail::expression<tag, A1, A2, A3, A4> >::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value && (number_category<detail::expression<tag, A1, A2, A3, A4> >::value == category),\
|
||||
detail::expression<\
|
||||
detail::function\
|
||||
, detail::BOOST_JOIN(category, BOOST_JOIN(func, _funct))<typename detail::backend_type<detail::expression<tag, A1, A2, A3, A4> >::type> \
|
||||
@@ -2933,7 +2987,7 @@ func(const detail::expression<tag, A1, A2, A3, A4>& arg, const Arithmetic& a)\
|
||||
}\
|
||||
template <class Backend, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<Backend>::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, number<Backend, et_on> >::value && (number_category<Backend>::value == category),\
|
||||
detail::expression<\
|
||||
detail::function\
|
||||
, detail::BOOST_JOIN(category, BOOST_JOIN(func, _funct))<Backend> \
|
||||
@@ -2956,7 +3010,7 @@ func(const Arithmetic& arg, const number<Backend, et_on>& a)\
|
||||
}\
|
||||
template <class tag, class A1, class A2, class A3, class A4, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<detail::expression<tag, A1, A2, A3, A4> >::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value && (number_category<detail::expression<tag, A1, A2, A3, A4> >::value == category),\
|
||||
detail::expression<\
|
||||
detail::function\
|
||||
, detail::BOOST_JOIN(category, BOOST_JOIN(func, _funct))<typename detail::backend_type<detail::expression<tag, A1, A2, A3, A4> >::type> \
|
||||
@@ -2989,7 +3043,7 @@ func(const number<Backend, et_off>& arg, const number<Backend, et_off>& a)\
|
||||
}\
|
||||
template <class Backend, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<Backend>::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, number<Backend, et_off> >::value && (number_category<Backend>::value == category),\
|
||||
number<Backend, et_off> \
|
||||
>::type \
|
||||
func(const number<Backend, et_off>& arg, const Arithmetic& a)\
|
||||
@@ -3002,7 +3056,7 @@ func(const number<Backend, et_off>& arg, const Arithmetic& a)\
|
||||
}\
|
||||
template <class Backend, class Arithmetic> \
|
||||
inline typename enable_if_c<\
|
||||
is_arithmetic<Arithmetic>::value && (number_category<Backend>::value == category),\
|
||||
is_compatible_arithmetic_type<Arithmetic, number<Backend, et_off>>::value && (number_category<Backend>::value == category),\
|
||||
number<Backend, et_off> \
|
||||
>::type \
|
||||
func(const Arithmetic& a, const number<Backend, et_off>& arg)\
|
||||
@@ -3102,10 +3156,11 @@ struct abs_funct
|
||||
}
|
||||
|
||||
template <class tag, class A1, class A2, class A3, class A4>
|
||||
inline detail::expression<
|
||||
inline typename boost::disable_if_c<component_type<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_complex,
|
||||
detail::expression<
|
||||
detail::function
|
||||
, detail::abs_funct<typename detail::backend_type<detail::expression<tag, A1, A2, A3, A4> >::type>
|
||||
, detail::expression<tag, A1, A2, A3, A4> >
|
||||
, detail::expression<tag, A1, A2, A3, A4> > >::type
|
||||
abs(const detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
{
|
||||
return detail::expression<
|
||||
@@ -3118,10 +3173,11 @@ abs(const detail::expression<tag, A1, A2, A3, A4>& arg)
|
||||
);
|
||||
}
|
||||
template <class Backend>
|
||||
inline detail::expression<
|
||||
inline typename disable_if_c<number_category<Backend>::value == number_kind_complex,
|
||||
detail::expression<
|
||||
detail::function
|
||||
, detail::abs_funct<Backend>
|
||||
, number<Backend, et_on> >
|
||||
, number<Backend, et_on> > >::type
|
||||
abs(const number<Backend, et_on>& arg)
|
||||
{
|
||||
return detail::expression<
|
||||
@@ -3134,7 +3190,7 @@ abs(const number<Backend, et_on>& arg)
|
||||
);
|
||||
}
|
||||
template <class Backend>
|
||||
inline number<Backend, et_off>
|
||||
inline typename disable_if_c<number_category<Backend>::value == number_kind_complex, number<Backend, et_off> >::type
|
||||
abs(const number<Backend, et_off>& arg)
|
||||
{
|
||||
number<Backend, et_off> result;
|
||||
@@ -3213,6 +3269,8 @@ UNARY_OP_FUNCTOR(tanh, number_kind_complex)
|
||||
UNARY_OP_FUNCTOR(asinh, number_kind_complex)
|
||||
UNARY_OP_FUNCTOR(acosh, number_kind_complex)
|
||||
UNARY_OP_FUNCTOR(atanh, number_kind_complex)
|
||||
UNARY_OP_FUNCTOR(conj, number_kind_complex)
|
||||
UNARY_OP_FUNCTOR(proj, number_kind_complex)
|
||||
|
||||
//
|
||||
// Integer functions:
|
||||
|
||||
@@ -88,7 +88,7 @@ inline void pow_imp(T& result, const T& t, const U& p, const mpl::true_&)
|
||||
} // namespace detail
|
||||
|
||||
template<typename T, typename U>
|
||||
inline typename enable_if<is_integral<U> >::type eval_pow(T& result, const T& t, const U& p)
|
||||
inline typename enable_if_c<is_integral<U>::value>::type eval_pow(T& result, const T& t, const U& p)
|
||||
{
|
||||
detail::pow_imp(result, t, p, boost::is_signed<U>());
|
||||
}
|
||||
@@ -715,7 +715,7 @@ inline void eval_pow(T& result, const T& x, const T& a)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if<is_floating_point<A>, void>::type eval_pow(T& result, const T& x, const A& a)
|
||||
inline typename enable_if_c<is_compatible_arithmetic_type<A, number<T> >::value && !is_integral<A>::value, void>::type eval_pow(T& result, const T& x, const A& a)
|
||||
{
|
||||
// Note this one is restricted to float arguments since pow.hpp already has a version for
|
||||
// integer powers....
|
||||
@@ -727,7 +727,7 @@ inline typename enable_if<is_floating_point<A>, void>::type eval_pow(T& result,
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if<is_arithmetic<A>, void>::type eval_pow(T& result, const A& x, const T& a)
|
||||
inline typename enable_if_c<is_compatible_arithmetic_type<A, number<T> >::value, void>::type eval_pow(T& result, const A& x, const T& a)
|
||||
{
|
||||
typedef typename boost::multiprecision::detail::canonical<A, T>::type canonical_type;
|
||||
typedef typename mpl::if_<is_same<A, canonical_type>, T, canonical_type>::type cast_type;
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/multiprecision/detail/digits.hpp>
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#include <boost/math/special_functions/asinh.hpp>
|
||||
#include <boost/math/special_functions/acosh.hpp>
|
||||
#include <boost/math/special_functions/atanh.hpp>
|
||||
#include <boost/functional/hash_fwd.hpp>
|
||||
#include <mpc.h>
|
||||
#include <cmath>
|
||||
@@ -884,6 +881,18 @@ inline void eval_atanh(mpc_float_backend<Digits10>& result, const mpc_float_back
|
||||
mpc_atanh(result.data(), arg.data(), GMP_RNDN);
|
||||
}
|
||||
|
||||
template <unsigned Digits10>
|
||||
inline void eval_conj(mpc_float_backend<Digits10>& result, const mpc_float_backend<Digits10>& arg)
|
||||
{
|
||||
mpc_conj(result.data(), arg.data(), GMP_RNDN);
|
||||
}
|
||||
|
||||
template <unsigned Digits10>
|
||||
inline void eval_proj(mpc_float_backend<Digits10>& result, const mpc_float_backend<Digits10>& arg)
|
||||
{
|
||||
mpc_proj(result.data(), arg.data(), GMP_RNDN);
|
||||
}
|
||||
|
||||
template <unsigned Digits10>
|
||||
inline std::size_t hash_value(const mpc_float_backend<Digits10>& val)
|
||||
{
|
||||
@@ -955,6 +964,12 @@ inline typename component_type<boost::multiprecision::number<boost::multiprecisi
|
||||
return result;
|
||||
}
|
||||
|
||||
template <unsigned Digits10, expression_template_option ExpressionTemplates>
|
||||
number<backends::mpc_float_backend<Digits10> > polar(number<backends::mpfr_float_backend<Digits10>, ExpressionTemplates>const& r, number<backends::mpfr_float_backend<Digits10>, ExpressionTemplates> const& theta)
|
||||
{
|
||||
number<backends::mpc_float_backend<Digits10> > result(number<backends::mpfr_float_backend<Digits10>, ExpressionTemplates>(r * cos(theta)), number<backends::mpfr_float_backend<Digits10>, ExpressionTemplates>(r * sin(theta)));
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace multiprecision
|
||||
|
||||
|
||||
@@ -1710,6 +1710,8 @@ private:
|
||||
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR bool is_realy_self(const self_type& v)const BOOST_NOEXCEPT{ return &v == this; }
|
||||
|
||||
static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR const Backend& function_arg_value(const self_type& v) BOOST_NOEXCEPT { return v.backend(); }
|
||||
template <class Other, expression_template_option ET2>
|
||||
static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR const Other& function_arg_value(const number<Other, ET2>& v) BOOST_NOEXCEPT { return v.backend(); }
|
||||
template <class V>
|
||||
static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR const V& function_arg_value(const V& v) BOOST_NOEXCEPT { return v; }
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
|
||||
@@ -1974,6 +1974,52 @@ typename boost::enable_if_c<boost::multiprecision::number_category<Real>::value
|
||||
BOOST_CHECK_EQUAL(real(a), 3);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
|
||||
a += r;
|
||||
BOOST_CHECK_EQUAL(real(a), 6);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
|
||||
a *= r;
|
||||
BOOST_CHECK_EQUAL(real(a), 18);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
|
||||
a = a / r;
|
||||
BOOST_CHECK_EQUAL(real(a), 6);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
a = a - r;
|
||||
BOOST_CHECK_EQUAL(real(a), 3);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
a = r + a;
|
||||
BOOST_CHECK_EQUAL(real(a), 6);
|
||||
BOOST_CHECK_EQUAL(imag(a), 0);
|
||||
|
||||
r = abs(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("3.60555127546398929311922126747049594625129657384524621271045305622716694829301044520461908201849071767351418202406"), r, tol);
|
||||
r = arg(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.98279372324732906798571061101466601449687745363162855676142508831798807154979603538970653437281731110816513970201"), r, tol);
|
||||
r = norm(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(13), r, tol);
|
||||
a = conj(c);
|
||||
BOOST_CHECK_EQUAL(real(a), 2);
|
||||
BOOST_CHECK_EQUAL(imag(a), -3);
|
||||
a = proj(c);
|
||||
BOOST_CHECK_EQUAL(real(a), 2);
|
||||
BOOST_CHECK_EQUAL(imag(a), 3);
|
||||
a = polar(real_type(3), real_type(-10));
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-2.517214587229357356776591843472194503559790495399505640507861193146377760598812305202801138281266416782353163216"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.63206333266810944021424298555413184505092903874867167472255203785027162892148027712122702168494964847488147271478"), imag(a), tol);
|
||||
r = abs(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("3.60555127546398929311922126747049594625129657384524621271045305622716694829301044520461908201849071767351418202406"), r, tol);
|
||||
r = arg(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.98279372324732906798571061101466601449687745363162855676142508831798807154979603538970653437281731110816513970201"), r, tol);
|
||||
r = norm(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(13), r, tol);
|
||||
a = conj(c + 0);
|
||||
BOOST_CHECK_EQUAL(real(a), 2);
|
||||
BOOST_CHECK_EQUAL(imag(a), -3);
|
||||
a = proj(c + 0);
|
||||
BOOST_CHECK_EQUAL(real(a), 2);
|
||||
BOOST_CHECK_EQUAL(imag(a), 3);
|
||||
|
||||
a = exp(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-7.3151100949011025174865361510507893218698794489446322367845159660828327860599907104337742108443234172141249777"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.0427436562359044141015039404625521939183300604422348975424523449538886779880818796291971422701951470533151185"), imag(a), tol);
|
||||
@@ -1986,6 +2032,19 @@ typename boost::enable_if_c<boost::multiprecision::number_category<Real>::value
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.556971676153418384603252578971164215414864594193534135900595487498776545815097120403823727129449829836488977743"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.426821890855466638944275673291166123449562356934437957244904971730668088711719757900679614536803436424488603794"), imag(a), tol);
|
||||
|
||||
a = exp(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-7.3151100949011025174865361510507893218698794489446322367845159660828327860599907104337742108443234172141249777"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.0427436562359044141015039404625521939183300604422348975424523449538886779880818796291971422701951470533151185"), imag(a), tol);
|
||||
|
||||
a = log(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.282474678730768368026743720782659302402633972380103558209522755331732333662205089699787331720244744384629096046"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.9827937232473290679857106110146660144968774536316285567614250883179880715497960353897065343728173111081651397020"), imag(a), tol);
|
||||
|
||||
a = log10(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.556971676153418384603252578971164215414864594193534135900595487498776545815097120403823727129449829836488977743"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.426821890855466638944275673291166123449562356934437957244904971730668088711719757900679614536803436424488603794"), imag(a), tol);
|
||||
|
||||
// Powers where one arg is an integer.
|
||||
b = Real(5, -2);
|
||||
a = pow(c, b);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-3053.8558566606567369633610140423321260211388217942246293871310470377722279440084474789529228008638668934381183"), real(a), tol);
|
||||
@@ -1996,8 +2055,44 @@ typename boost::enable_if_c<boost::multiprecision::number_category<Real>::value
|
||||
a = pow(3, c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
a = pow(c + 0, b);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-3053.8558566606567369633610140423321260211388217942246293871310470377722279440084474789529228008638668934381183"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("3097.9975862915005132449772136982559285192410496951232473245540634244845290672745578327467396750607773968246915"), imag(a), tol);
|
||||
a = pow(c + 0, 3);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(-46), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(9), imag(a), tol);
|
||||
a = pow(3, c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
|
||||
//TODO powers where one arg is a real_type.
|
||||
r = 3;
|
||||
// Powers where one arg is a real_type.
|
||||
a = pow(c, r);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(-46), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(9), imag(a), tol);
|
||||
a = pow(r, c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
a = pow(c + 0, r);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(-46), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(9), imag(a), tol);
|
||||
a = pow(r, c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
|
||||
// Powers where one arg is an float.
|
||||
a = pow(c, 3.0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(-46), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(9), imag(a), tol);
|
||||
a = pow(3.0, c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
a = pow(c + 0, 3.0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(-46), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type(9), imag(a), tol);
|
||||
a = pow(3.0, c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-8.8931513442797186948734782808862447235385767991868219480917324534839621090167050538805196124711247247992169338"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.3826999557878897572499699021550296885662132089951379549068064961882821777067532977546360861176011175070188118"), imag(a), tol);
|
||||
|
||||
a = sqrt(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.674149228035540040448039300849051821674708677883920366727287836003399240343274891876712629708287692163156802065"), real(a), tol);
|
||||
@@ -2020,6 +2115,27 @@ typename boost::enable_if_c<boost::multiprecision::number_category<Real>::value
|
||||
a = atan(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.409921049596575522530619384460420782588207051908724814771070766475530084440199227135813201495737846771570458568"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.2290726829685387662958818029420027678625253049770656169479919704951963414344907622560676377741902308144912055002"), imag(a), tol);
|
||||
a = sqrt(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.674149228035540040448039300849051821674708677883920366727287836003399240343274891876712629708287692163156802065"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.8959774761298381247157337552900434410433241995549314932449006989874470582160955817053273057885402621549320588976"), imag(a), tol);
|
||||
a = sin(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("9.154499146911429573467299544609832559158860568765182977899828142590020335321896403936690014669532606510294425039"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-4.168906959966564350754813058853754843573565604758055889965478710592666260138453299795649308385497563475115931624"), imag(a), tol);
|
||||
a = cos(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-4.1896256909688072301325550196159737286219454041279210357407905058369727912162626993926269783331491034500484583"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-9.1092278937553365979791972627788621213326202389201695649104967309554222940748568716960841549279996556547993373"), imag(a), tol);
|
||||
a = tan(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-0.0037640256415042482927512211303226908396306202016580864328644932511249097100916559688254811519914564480500042311"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.0032386273536098014463585978219272598077897241071003399272426939850671219193120708438426543945017427085738411"), imag(a), tol);
|
||||
a = asin(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.5706527843210994007102838796856696501828032450960401365302732598209740064262509342420347149436326252483895113827"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.983387029916535432347076902894039565014248302909345356125267430944752731616095111727103650117987412058949254132"), imag(a), tol);
|
||||
a = acos(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.000143542473797218521037811954081791915781454591512773957199036332934196716853565071982697727425908742684531873"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-1.983387029916535432347076902894039565014248302909345356125267430944752731616095111727103650117987412058949254132"), imag(a), tol);
|
||||
a = atan(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.409921049596575522530619384460420782588207051908724814771070766475530084440199227135813201495737846771570458568"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.2290726829685387662958818029420027678625253049770656169479919704951963414344907622560676377741902308144912055002"), imag(a), tol);
|
||||
|
||||
a = sinh(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-3.5905645899857799520125654477948167931949136757293015099986213974178826801534614215227593814301490087307920223"), real(a), tol);
|
||||
@@ -2039,6 +2155,24 @@ typename boost::enable_if_c<boost::multiprecision::number_category<Real>::value
|
||||
a = atanh(c);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.1469466662255297520474327851547159424423449403442452953891851939502023996823900422792744078835711416939934387775"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.338972522294493561124193575909144241084316172544492778582005751793809271060233646663717270678614587712809117131"), imag(a), tol);
|
||||
a = sinh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-3.5905645899857799520125654477948167931949136757293015099986213974178826801534614215227593814301490087307920223"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.53092108624851980526704009066067655967277345095149103008706855371803528753067068552935673000832252607835087747"), imag(a), tol);
|
||||
a = cosh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-3.7245455049153225654739707032559725286749657732153307267858945686649501059065292889110148294141744084833329553"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.51182256998738460883446384980187563424555660949074386745538379123585339045741119409984041226187262097496424111"), imag(a), tol);
|
||||
a = tanh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.965385879022133124278480269394560685879729650005757773636908240066639772853967550095754361348005358178253777920"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("-0.00988437503832249372031403430350121097961813353467039031861010606115560355679254344335582852193041894874685555114"), imag(a), tol);
|
||||
a = asinh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.968637925793096291788665095245498189520731012682010573842811017352748255492485345887875752070076230641308014923"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.9646585044076027920454110594995323555197773725073316527132580297155508786089335572049608301897631767195194427315"), imag(a), tol);
|
||||
a = acosh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.983387029916535432347076902894039565014248302909345356125267430944752731616095111727103650117987412058949254132"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.000143542473797218521037811954081791915781454591512773957199036332934196716853565071982697727425908742684531873"), imag(a), tol);
|
||||
a = atanh(c + 0);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("0.1469466662255297520474327851547159424423449403442452953891851939502023996823900422792744078835711416939934387775"), real(a), tol);
|
||||
BOOST_CHECK_CLOSE_FRACTION(real_type("1.338972522294493561124193575909144241084316172544492778582005751793809271060233646663717270678614587712809117131"), imag(a), tol);
|
||||
}
|
||||
|
||||
template <class Real>
|
||||
|
||||
Reference in New Issue
Block a user