29#ifndef BERTINI_MPFR_COMPLEX_HPP
30#define BERTINI_MPFR_COMPLEX_HPP
36#include <boost/archive/text_oarchive.hpp>
37#include <boost/archive/text_iarchive.hpp>
38#include <boost/serialization/split_member.hpp>
50#include <boost/multiprecision/mpc.hpp>
54namespace bmp = boost::multiprecision;
55using bmp::backends::mpc_complex_backend;
57#ifdef BMP_EXPRESSION_TEMPLATES
58 using complex_mp = bmp::number<mpc_complex_backend<0>, bmp::et_on >;
60 using complex_mp = bmp::number<mpc_complex_backend<0>, bmp::et_off >;
65 return bmp::variable_precision_options::preserve_related_precision;
81 real_mp::thread_default_variable_precision_options(opts);
86 real_mp::thread_default_variable_precision_options(
saved_options);
90 void reset(boost::multiprecision::variable_precision_options opts)
92 real_mp::thread_default_variable_precision_options(opts);
110 real_mp::default_variable_precision_options(opts);
111 real_mp::thread_default_variable_precision_options(opts);
121 void reset(boost::multiprecision::variable_precision_options opts)
123 real_mp::default_variable_precision_options(opts);
124 real_mp::thread_default_variable_precision_options(opts);
137 auto p = real_mp::default_precision();
138 assert(p==complex_mp::default_precision() &&
"precision of real and complex multiprecision numbers have drifted...");
145 real_mp::default_precision(prec);
146 complex_mp::default_precision(prec);
152 real_mp::thread_default_precision(prec);
153 complex_mp::thread_default_precision(prec);
154#ifdef BMP_EXPRESSION_TEMPLATES
165 real_mp::thread_default_variable_precision_options(
166 bmp::variable_precision_options::preserve_related_precision);
167 complex_mp::thread_default_variable_precision_options(
168 bmp::variable_precision_options::preserve_related_precision);
178 real_mp::thread_default_precision(prec);
179 complex_mp::thread_default_precision(prec);
185 return static_cast<unsigned>(real_mp::thread_default_precision());
195 template <
typename Archive>
196 void save(Archive& ar, ::boost::multiprecision::backends::mpc_complex_backend<0>
const& r,
unsigned )
198 unsigned num_digits(r.precision());
200 std::string tmp = r.str(0,std::ios::scientific);
207 template <
typename Archive>
208 void load(Archive& ar, ::boost::multiprecision::backends::mpc_complex_backend<0>& r,
unsigned )
212 r.precision(num_digits);
222BOOST_SERIALIZATION_SPLIT_FREE(::boost::multiprecision::backends::mpc_complex_backend<0>);
240 return num.precision();
Extensions to the Boost.Multiprecision library.
Definition algorithm_builder.hpp:36
bool isnan(std::complex< double > const &z)
an overload of isnan, for std::complex<double>
Definition double_extensions.hpp:63
void SetThreadPrecision(unsigned prec)
Set the precision (digits) for the current thread only (does not touch the global default).
Definition mpfr_complex.hpp:176
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58
auto DefaultPrecision()
Get the global default precision (digits) for multiprecision numbers.
Definition mpfr_complex.hpp:135
boost::multiprecision::number< boost::multiprecision::mpfr_float_backend< 0 >, boost::multiprecision::et_on > real_mp
The arbitrary-precision real number type.
Definition mpfr_extensions.hpp:53
unsigned ThreadPrecision()
Get the current thread's precision (digits).
Definition mpfr_complex.hpp:183
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
auto DefaultPrecisionPolicy()
The default Boost.Multiprecision variable-precision policy used by bertini.
Definition mpfr_complex.hpp:64
Definition forbid_mixed_arithmetic.hpp:29
Definition mpfr_complex.hpp:191
void load(Archive &ar, ::boost::multiprecision::backends::mpc_complex_backend< 0 > &r, unsigned)
Load a mpc_complex type from a boost archive.
Definition mpfr_complex.hpp:208
void save(Archive &ar, ::boost::multiprecision::backends::mpc_complex_backend< 0 > const &r, unsigned)
Save a mpc_complex type to a boost archive.
Definition mpfr_complex.hpp:196
Definition forbid_mixed_arithmetic.hpp:27
boost::multiprecision::variable_precision_options saved_options_all_threads
The all-thread options to restore.
Definition mpfr_complex.hpp:102
void reset(boost::multiprecision::variable_precision_options opts)
Set both the global and thread options again (without changing what will be restored).
Definition mpfr_complex.hpp:121
scoped_mpfr_precision_options_all_threads(boost::multiprecision::variable_precision_options opts)
Save the current global and thread options and set the given ones for both.
Definition mpfr_complex.hpp:106
~scoped_mpfr_precision_options_all_threads()
Definition mpfr_complex.hpp:114
boost::multiprecision::variable_precision_options saved_options_this_thread
The current-thread options to restore.
Definition mpfr_complex.hpp:103
boost::multiprecision::variable_precision_options saved_options
The options to restore on destruction.
Definition mpfr_complex.hpp:76
~scoped_mpfr_precision_options_this_thread()
Definition mpfr_complex.hpp:84
scoped_mpfr_precision_options_this_thread(boost::multiprecision::variable_precision_options opts)
Save the current thread options and set the given ones.
Definition mpfr_complex.hpp:79
void reset(boost::multiprecision::variable_precision_options opts)
Set the thread options again (without changing what will be restored).
Definition mpfr_complex.hpp:90