flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
library_looptools.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
19#include "library_looptools.hpp"
20#include "clooptools.h"
21#include "fortran_utils.hpp"
22#include <boost/preprocessor/seq/elem.hpp>
23#include <boost/preprocessor/seq/for_each_i.hpp>
24#include <limits>
25
26#define A_PAIR (A)(aa)
27#define B_PAIR (B)(bb)
28#define C_PAIR (C)(cc)
29#define D_PAIR (D)(dd)
30
31#define REAL(R, DUMMY, ELEM) , ELEM.real()
32
33#define CAT_(a, b) a##b
34#define CAT(a, b) CAT_(a, b)
35
36#define LIB(PAIR) BOOST_PP_SEQ_ELEM(0, PAIR)
37#define LT(PAIR) BOOST_PP_SEQ_ELEM(1, PAIR)
38
39#define LIB_NAME(PAIR, INDEX) CAT(LIB(PAIR), INDEX)
40#define LIB_ARGS(PAIR) CAT(LIB(PAIR), _ARGS)
41
42#define LT_ARGS(PAIR) CAT(LIB(PAIR), _ARGS_SEQ)
43#define LT_NAME(PAIR) CAT(LIB(PAIR), 0i)
44#define LT_IDX(PAIR, INDEX) CAT(LT(PAIR), INDEX)
45
46#define LT_ONE(_, PAIR, I, INDEX) \
47 std::complex<double> Looptools::LIB_NAME(PAIR, \
48 INDEX)(LIB_ARGS(PAIR)) noexcept \
49 { \
50 set_mu2_uv(scl2_in); \
51 return LT_NAME(PAIR)(LT_IDX(PAIR, INDEX) \
52 BOOST_PP_SEQ_FOR_EACH(REAL, , LT_ARGS(PAIR))); \
53 }
54
55#define LT_ONE_DERIVATIVE(_, PAIR, I, INDEX) \
56 std::complex<double> Looptools::CAT(D, LIB_NAME(PAIR, INDEX))(LIB_ARGS(PAIR)) noexcept \
57 { \
58 set_mu2_uv(scl2_in); \
59 return LT_NAME(PAIR)(CAT(CAT(d, LT(PAIR)), INDEX) \
60 BOOST_PP_SEQ_FOR_EACH(REAL, , LT_ARGS(PAIR))); \
61 } \
62
63
64#define LT_ALL(PAIR) \
65 void Looptools::LIB(PAIR)(CAT(LIB(PAIR), coeff_t) & \
66 arr, \
67 CAT(LIB(PAIR), _ARGS)) noexcept \
68 { \
69 const int coeffs[] = {BOOST_PP_SEQ_ENUM( \
70 BOOST_PP_SEQ_TRANSFORM(APPEND, LT(PAIR), CAT(LIB(PAIR), _CSEQ)))}; \
71 ComplexType res[CAT(N, LT(PAIR))]; \
72 set_mu2_uv(scl2_in); \
73 \
74 CAT(LIB(PAIR), put) \
75 (res BOOST_PP_SEQ_FOR_EACH(REAL, , CAT(LIB(PAIR), _ARGS_SEQ))); \
76 for (int i = 0; i < CAT(LIB(PAIR), _N); ++i) { \
77 arr.at(i) = res[coeffs[i]]; \
78 } \
79 }
80
81#define LT_ALL_DERIVATIVE(PAIR) \
82 void Looptools::CAT(D, LIB(PAIR))(CAT(LIB(PAIR), coeff_t) & \
83 arr, \
84 CAT(LIB(PAIR), _ARGS)) noexcept \
85 { \
86 const int coeffs[] = {BOOST_PP_SEQ_ENUM( \
87 BOOST_PP_SEQ_TRANSFORM(APPEND, CAT(d, LT(PAIR)), CAT(LIB(PAIR), _CSEQ)))}; \
88 ComplexType res[CAT(N, LT(PAIR))]; \
89 set_mu2_uv(scl2_in); \
90 \
91 CAT(LIB(PAIR), put) \
92 (res BOOST_PP_SEQ_FOR_EACH(REAL, , CAT(LIB(PAIR), _ARGS_SEQ))); \
93 for (int i = 0; i < CAT(CAT(D, LIB(PAIR)), _N); ++i) { \
94 arr.at(i) = res[coeffs[i]]; \
95 } \
96 }
97
98namespace flexiblesusy
99{
100namespace looplibrary
101{
102
103Looptools::Looptools() : current_mu2_uv(1.0)
104{
105 futils::swap();
106 ltini();
108 futils::swap();
109}
110
111void Looptools::set_mu2_uv(double scl2_in) noexcept
112{
113 if (std::abs(scl2_in - this->current_mu2_uv) >
114 std::numeric_limits<double>::epsilon()) {
115 setmudim(scl2_in);
116 this->current_mu2_uv = scl2_in;
117 }
118}
119
120BOOST_PP_SEQ_FOR_EACH_I(LT_ONE, A_PAIR, A_CSEQ)
121BOOST_PP_SEQ_FOR_EACH_I(LT_ONE, B_PAIR, B_CSEQ)
122BOOST_PP_SEQ_FOR_EACH_I(LT_ONE_DERIVATIVE, B_PAIR, DB_CSEQ)
123BOOST_PP_SEQ_FOR_EACH_I(LT_ONE, C_PAIR, C_CSEQ)
124BOOST_PP_SEQ_FOR_EACH_I(LT_ONE, D_PAIR, D_CSEQ)
125
131
132} // namespace looplibrary
133} // namespace flexiblesusy
#define D_PAIR
#define C_PAIR
#define LT_ONE(_, PAIR, I, INDEX)
#define A_PAIR
#define LT_ALL(PAIR)
#define LT_ALL_DERIVATIVE(PAIR)
#define B_PAIR
#define LT_ONE_DERIVATIVE(_, PAIR, I, INDEX)
#define D_CSEQ
#define A_CSEQ
#define B_CSEQ
#define DB_CSEQ
#define C_CSEQ
void flush() noexcept
Flushes output of fortran routines.
void swap() noexcept
Swaps stdout and stderr descriptors.