flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
threshold_corrections.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
20#include "error.hpp"
21#include "logger.hpp"
22#include <string>
23#include <iostream>
24
25namespace flexiblesusy {
26
27namespace {
28
31{
32 if (pos < 0) {
33 throw OutOfBoundsError(
34 "get_digit: position ( " + std::to_string(pos) + ") must be positive");
35 }
36
37 int num = std::abs(static_cast<int>(flags));
38
39 while (--pos >= 0) {
40 num /= 10;
41 }
42
43 return static_cast<Threshold_corrections::Flags_t>(num % 10);
44}
45
47void set_digit(Threshold_corrections::Flags_t& flags, int pos, int digit)
48{
49 if (pos < 0) {
50 throw OutOfBoundsError(
51 "set_digit: position ( " + std::to_string(pos) + ") must be positive");
52 }
53
54 if (digit > 9) {
55 throw OutOfBoundsError(
56 "set_digit: digit ( " + std::to_string(digit) + ") must be less or equal than 9.");
57 }
58
59 if (digit < 0) {
60 WARNING("digit at position " << pos << " is negative (" << digit << ")."
61 " I'm setting it to zero.");
62 digit = 0;
63 }
64
65 const auto old_digit = get_digit(flags, pos);
66
67 int dig = digit - old_digit;
68
69 while (--pos >= 0) {
70 dig *= 10;
71 }
72
73 flags += dig;
74}
75
76} // anonymous namespace
77
79{
80 set(flags);
81}
82
84{
85 alpha_em = get_digit(flags, static_cast<int>(Positions::alpha_em ));
86 sin_theta_w = get_digit(flags, static_cast<int>(Positions::sin_theta_w));
87 alpha_s = get_digit(flags, static_cast<int>(Positions::alpha_s ));
88 mz = get_digit(flags, static_cast<int>(Positions::mz ));
89 mw = get_digit(flags, static_cast<int>(Positions::mw ));
90 mh = get_digit(flags, static_cast<int>(Positions::mh ));
91 mt = get_digit(flags, static_cast<int>(Positions::mt ));
92 mb = get_digit(flags, static_cast<int>(Positions::mb ));
93 mtau = get_digit(flags, static_cast<int>(Positions::mtau ));
94}
95
97{
98 Flags_t flags = 0;
99
100 set_digit(flags, static_cast<int>(Positions::alpha_em ), alpha_em);
101 set_digit(flags, static_cast<int>(Positions::sin_theta_w), sin_theta_w);
102 set_digit(flags, static_cast<int>(Positions::alpha_s ), alpha_s);
103 set_digit(flags, static_cast<int>(Positions::mz ), mz);
104 set_digit(flags, static_cast<int>(Positions::mw ), mw);
105 set_digit(flags, static_cast<int>(Positions::mh ), mh);
106 set_digit(flags, static_cast<int>(Positions::mt ), mt);
107 set_digit(flags, static_cast<int>(Positions::mb ), mb);
108 set_digit(flags, static_cast<int>(Positions::mtau ), mtau);
109
110 return flags;
111}
112
113std::ostream& operator<<(std::ostream& ostr, const Threshold_corrections& tc)
114{
115 ostr << '['
116 << tc.mtau << ','
117 << tc.mb << ','
118 << tc.mt << ','
119 << tc.mh << ','
120 << tc.mw << ','
121 << tc.mz << ','
122 << tc.alpha_s << ','
123 << tc.sin_theta_w << ','
124 << tc.alpha_em << ']';
125
126 return ostr;
127}
128
129} // namespace flexiblesusy
Out of bounds access.
Definition: error.hpp:208
#define WARNING(msg)
Definition: logger.hpp:63
void set_digit(Threshold_corrections::Flags_t &flags, int pos, int digit)
sets digit [0-9] in flags at position pos
int get_digit(Threshold_corrections::Flags_t flags, int pos)
returns digit [0-9] in flags at position pos
std::string to_string(char a)
std::ostream & operator<<(std::ostream &ostr, const Dynamic_array_view< ElementType > &av)
Definition: array_view.hpp:143
void set(Flags_t)
sets all values to digits in given a Flags_t
Flags_t get() const
returns all value in a Flags_t
contains struct for selection of low-energy threshold correction loop orders