mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-07-21 13:23:49 +00:00
Update complex_adaptor to match precision requirements.
Add test case. Fixes https://github.com/boostorg/multiprecision/issues/595
This commit is contained in:
@@ -192,6 +192,56 @@ struct complex_adaptor
|
||||
m_real.negate();
|
||||
m_imag.negate();
|
||||
}
|
||||
|
||||
//
|
||||
// Default precision:
|
||||
//
|
||||
static BOOST_MP_CXX14_CONSTEXPR unsigned default_precision() noexcept
|
||||
{
|
||||
return Backend::default_precision();
|
||||
}
|
||||
static BOOST_MP_CXX14_CONSTEXPR void default_precision(unsigned digits10)
|
||||
{
|
||||
Backend::default_precision(digits10);
|
||||
Backend::thread_default_precision(digits10);
|
||||
}
|
||||
static BOOST_MP_CXX14_CONSTEXPR unsigned thread_default_precision() noexcept
|
||||
{
|
||||
return Backend::thread_default_precision();
|
||||
}
|
||||
static BOOST_MP_CXX14_CONSTEXPR void thread_default_precision(unsigned digits10)
|
||||
{
|
||||
Backend::thread_default_precision(digits10);
|
||||
}
|
||||
BOOST_MP_CXX14_CONSTEXPR unsigned precision() const noexcept
|
||||
{
|
||||
return m_real.precision();
|
||||
}
|
||||
BOOST_MP_CXX14_CONSTEXPR void precision(unsigned digits10)
|
||||
{
|
||||
m_real.precision(digits10);
|
||||
m_imag.precision(digits10);
|
||||
}
|
||||
//
|
||||
// Variable precision options:
|
||||
//
|
||||
static constexpr variable_precision_options default_variable_precision_options()noexcept
|
||||
{
|
||||
return Backend::default_variable_precision_options();
|
||||
}
|
||||
static constexpr variable_precision_options thread_default_variable_precision_options()noexcept
|
||||
{
|
||||
return Backend::thread_default_variable_precision_options();
|
||||
}
|
||||
static BOOST_MP_CXX14_CONSTEXPR void default_variable_precision_options(variable_precision_options opts)
|
||||
{
|
||||
Backend::default_variable_precision_options(opts);
|
||||
Backend::thread_default_variable_precision_options(opts);
|
||||
}
|
||||
static BOOST_MP_CXX14_CONSTEXPR void thread_default_variable_precision_options(variable_precision_options opts)
|
||||
{
|
||||
Backend::thread_default_variable_precision_options(opts);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Backend, class T>
|
||||
|
||||
@@ -1234,6 +1234,7 @@ test-suite misc :
|
||||
[ run git_issue_540.cpp ]
|
||||
[ run git_issue_573.cpp : : : <toolset>msvc:<cxxflags>-sdl ]
|
||||
[ run git_issue_576.cpp : : : [ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ] ]
|
||||
[ run git_issue_595.cpp : : : [ check-target-builds ../config//has_mpfr : <source>gmp <source>mpfr ] ]
|
||||
[ compile git_issue_98.cpp :
|
||||
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
|
||||
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2023 John Maddock. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#include <boost/multiprecision/complex_adaptor.hpp>
|
||||
#include <boost/multiprecision/logged_adaptor.hpp>
|
||||
#include <boost/multiprecision/debug_adaptor.hpp>
|
||||
#include <iostream>
|
||||
#include "test.hpp"
|
||||
|
||||
template <class T>
|
||||
void test()
|
||||
{
|
||||
T val;
|
||||
unsigned n = T::default_precision();
|
||||
T::default_precision(n);
|
||||
n = T::thread_default_precision();
|
||||
T::thread_default_precision(n);
|
||||
n = val.precision();
|
||||
val.precision(n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::multiprecision;
|
||||
|
||||
test<mpfr_float>();
|
||||
|
||||
using c = number<complex_adaptor<mpfr_float::backend_type>, et_on>;
|
||||
|
||||
test<c>();
|
||||
|
||||
using l = number<logged_adaptor<mpfr_float::backend_type>, et_on>;
|
||||
|
||||
test<l>();
|
||||
|
||||
using d = number<debug_adaptor<mpfr_float::backend_type>, et_on>;
|
||||
|
||||
test<d>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user