Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
fixed_precision_utilities.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//fixed_precision_utilities.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//fixed_precision_utilities.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with fixed_precision_utilities.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22#pragma once
23
25
26
27namespace bertini{ namespace tracking {
28namespace fixed{
29
30inline
31void SetPrecision(SampCont<complex_mp> & samples, unsigned prec)
32{
33 for (auto& s : samples)
34 for (unsigned ii=0; ii<s.size(); ii++)
35 s(ii).precision(prec);
36}
37
38inline
39void SetPrecision(TimeCont<complex_mp> & times, unsigned prec)
40{
41 for (auto& t : times)
42 t.precision(prec);
43}
44
45inline
46unsigned MaxPrecision(SampCont<complex_mp> const& samples)
47{
48 unsigned max_precision = 0;
49 for (auto& s : samples)
50 if(Precision(s(0)) > max_precision)
51 max_precision = Precision(s(0));
52 return max_precision;
53}
54
55inline
56unsigned MaxPrecision(TimeCont<complex_mp> const& times)
57{
58 unsigned max_precision = 0;
59 for (auto& t : times)
60 if(Precision(t) > max_precision)
61 max_precision = Precision(t);
62 return max_precision;
63}
64
65
66//does not a thing, because cannot.
67inline
68unsigned EnsureAtUniformPrecision(TimeCont<complex_dbl> const & /*times*/, SampCont<complex_dbl> const & /*derivatives*/)
69{
70 return DoublePrecision();
71}
72
73inline
74unsigned EnsureAtUniformPrecision(TimeCont<complex_dbl> const & /*times*/, SampCont<complex_dbl> const & /*samples*/, SampCont<complex_dbl> const & /*derivatives*/)
75{
76 return DoublePrecision();
77}
78
79
80//changes precision of complex_mp to highest needed precision for the samples.
81inline
82unsigned EnsureAtUniformPrecision(TimeCont<complex_mp> const & /*times*/, SampCont<complex_mp> const & samples)
83{
84 return MaxPrecision(samples);
85}
86
87
88//returns max precision of all samples.
89inline
90unsigned EnsureAtUniformPrecision(TimeCont<complex_mp> const & /*times*/, SampCont<complex_mp> const & samples, SampCont<complex_mp> const & derivatives)
91{
92 return max(MaxPrecision(samples),
93 MaxPrecision(derivatives));
94}
95
96
97}}} // re: namespaces
Definition fixed_precision_utilities.hpp:28
unsigned MaxPrecision(SampCont< complex_mp > const &samples)
Definition fixed_precision_utilities.hpp:46
unsigned EnsureAtUniformPrecision(TimeCont< complex_dbl > const &, SampCont< complex_dbl > const &)
Definition fixed_precision_utilities.hpp:68
void SetPrecision(SampCont< complex_mp > &samples, unsigned prec)
Definition fixed_precision_utilities.hpp:31
Definition adaptive_precision_utilities.hpp:35
T max(T const &a, T const &b, T const &c)
Three-argument form of max.
Definition mpfr_extensions.hpp:96
Definition algorithm_builder.hpp:36
constexpr unsigned DoublePrecision()
The number of digits considered "double precision" (16).
Definition num_traits.hpp:152
std::deque< Vec< T > > SampCont
Definition config.hpp:33
std::deque< T > TimeCont
Definition config.hpp:34
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object.
Definition eigen_extensions.hpp:339
Configs and settings for tracking.