Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
fixed_precision_utilities.hpp
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) 2015 - 2021 by 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// individual authors of this file include:
23// silviana amethyst, university of wisconsin eau claire
24// Tim Hodges, Colorado State University
25
26#pragma once
27
29
30
31namespace bertini{ namespace tracking {
32namespace fixed{
33
34inline
35void SetPrecision(SampCont<mpfr_complex> & samples, unsigned prec)
36{
37 for (auto& s : samples)
38 for (unsigned ii=0; ii<s.size(); ii++)
39 s(ii).precision(prec);
40}
41
42inline
43void SetPrecision(TimeCont<mpfr_complex> & times, unsigned prec)
44{
45 for (auto& t : times)
46 t.precision(prec);
47}
48
49inline
50unsigned MaxPrecision(SampCont<mpfr_complex> const& samples)
51{
52 unsigned max_precision = 0;
53 for (auto& s : samples)
54 if(Precision(s(0)) > max_precision)
55 max_precision = Precision(s(0));
56 return max_precision;
57}
58
59inline
60unsigned MaxPrecision(TimeCont<mpfr_complex> const& times)
61{
62 unsigned max_precision = 0;
63 for (auto& t : times)
64 if(Precision(t) > max_precision)
65 max_precision = Precision(t);
66 return max_precision;
67}
68
69
70//does not a thing, because cannot.
71inline
72unsigned EnsureAtUniformPrecision(TimeCont<dbl> const & times, SampCont<dbl> const & derivatives)
73{
74 return DoublePrecision();
75}
76
77inline
78unsigned EnsureAtUniformPrecision(TimeCont<dbl> const & times, SampCont<dbl> const & samples, SampCont<dbl> const & derivatives)
79{
80 return DoublePrecision();
81}
82
83
84//changes precision of mpfr_complex to highest needed precision for the samples.
85inline
86unsigned EnsureAtUniformPrecision(TimeCont<mpfr_complex> const & times, SampCont<mpfr_complex> const & samples)
87{
88 return MaxPrecision(samples);
89}
90
91
92//returns max precision of all samples.
93inline
94unsigned EnsureAtUniformPrecision(TimeCont<mpfr_complex> const & times, SampCont<mpfr_complex> const & samples, SampCont<mpfr_complex> const & derivatives)
95{
96 return max(MaxPrecision(samples),
97 MaxPrecision(derivatives));
98}
99
100
101}}} // re: namespaces
102
103
unsigned Precision(Eigen::MatrixBase< Derived > const &v)
Get the precision of an Eigen object. If the object is empty, it's the precision of a default-constru...
Definition eigen_extensions.hpp:292
T max(T const &a, T const &b, T const &c)
Three-argument form of max.
Definition mpfr_extensions.hpp:98
Configs and settings for tracking.