5#include <mpblas_mpfr.h>
8namespace uni20::mplapack::detail
12class precision_scope {
14 explicit precision_scope(Precision
p)
15 : precision_(mpfr_get_default_prec()), rounding_(mpfr_get_default_rounding_mode()), emin_(mpfr_get_emin()),
16 emax_(mpfr_get_emax()), stable_rounding_(gmpfrxx_mkII::detail::stable_mpfr_rounding_mode_storage()),
17 real_initialized_(gmpfrxx_mkII::detail::mpfr_defaults_initialized_storage()),
18 complex_initialized_(mpfrxx::mpc_defaults_initialized_storage()),
19 complex_precision_(mpfrxx::mpc_precision_override_storage()),
20 complex_rounding_(mpfrxx::mpc_rounding_override_storage())
22 auto const bits = uni20::detail::mpfr_precision(
p);
23 mpfrxx::initialize_thread_defaults();
24 mpfrxx::initialize_mpc_defaults_for_current_thread();
27 gmpfrxx_mkII::detail::set_mpfr_default_exponent_range(emin_, emax_);
28 mpfrxx::set_default_precision_bits(bits);
29 mpfrxx::set_default_rounding_mode(MPFR_RNDN);
30 mpfrxx::set_default_mpc_precision_bits(bits);
31 mpfrxx::set_default_mpc_rounding_mode(MPFR_RNDN);
33 ~precision_scope() noexcept
35 mpfr_set_default_prec(precision_);
36 mpfr_set_default_rounding_mode(rounding_);
37 gmpfrxx_mkII::detail::set_mpfr_default_exponent_range(emin_, emax_);
38 gmpfrxx_mkII::detail::stable_mpfr_rounding_mode_storage() = stable_rounding_;
39 gmpfrxx_mkII::detail::mpfr_defaults_initialized_storage() = real_initialized_;
40 mpfrxx::mpc_defaults_initialized_storage() = complex_initialized_;
41 mpfrxx::mpc_precision_override_storage() = complex_precision_;
42 mpfrxx::mpc_rounding_override_storage() = complex_rounding_;
44 precision_scope(precision_scope
const&) =
delete;
45 precision_scope& operator=(precision_scope
const&) =
delete;
48 mpfr_prec_t precision_;
50 mpfr_exp_t emin_, emax_;
51 mpfr_rnd_t stable_rounding_;
52 bool real_initialized_, complex_initialized_;
53 mpfrxx::mpc_precision_override_state complex_precision_;
54 mpfrxx::mpc_rounding_override_state complex_rounding_;
Definition data_table.cpp:8