ARTS 2.5.4 (git: 31ce4f0e)
wigner_functions.h
Go to the documentation of this file.
1/* Copyright (C) 2012
2 * Richard Larsson <ric.larsson@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA. */
18
27#ifndef wigner_functions_h
28#define wigner_functions_h
29
30#include "rational.h"
31
32#include <wigner/wigxjpf/inc/wigxjpf.h>
33
34#include <algorithm>
35#include <array>
36
37#ifdef FAST_WIGNER_PATH_3J
38#define DO_FAST_WIGNER 1
39#include <wigner/fastwigxj/inc/fastwigxj.h>
40#else
41#define DO_FAST_WIGNER 0
42#endif
43
44
51std::pair<Rational, Rational> wigner_limits(std::pair<Rational, Rational> a, std::pair<Rational, Rational> b);
52
97template<Index pos> constexpr
98std::pair<Rational, Rational> wigner3j_limits([[maybe_unused]] const Rational a=0,
99 [[maybe_unused]] const Rational b=0,
100 [[maybe_unused]] const Rational c=0,
101 [[maybe_unused]] const Rational d=0,
102 [[maybe_unused]] const Rational e=0) {
103 static_assert(pos < 7 and pos > 0, "Only valid for pos := 1, 2, 3, 4, 5, and 6");
104
105 if constexpr (pos == 1 or pos == 2) {
106 const Rational maxX = b - a;
107 std::pair<Rational, Rational> out {-maxX, a + b};
108 if (out.first > out.second) swap(out.first, out.second);
109 if (out.second > maxX) out.second = maxX;
110 if (out.first > maxX) out = {RATIONAL_UNDEFINED, RATIONAL_UNDEFINED};
111 return out;
112 } else if constexpr (pos == 3) {
113 const Rational maxX = a + b;
114 const Rational minX = abs(a - b);
115 if (maxX >= minX) return {minX, maxX};
117 } else {
118 const Rational lim = pos == 4 ? abs(a) :
119 pos == 5 ? abs(b) :
120 /*pos == 6*/ abs(c);
121 const Rational val = - e - d;
122 if (-lim <= val and val <= lim) return {val, val};
124 }
125}
126
147Numeric wigner3j(const Rational j1,
148 const Rational j2,
149 const Rational j3,
150 const Rational m1,
151 const Rational m2,
152 const Rational m3);
153
174Numeric wigner6j(const Rational j1,
175 const Rational j2,
176 const Rational j3,
177 const Rational l1,
178 const Rational l2,
179 const Rational l3);
180
188Index make_wigner_ready(int largest, int fastest, int size);
189
196bool is_wigner_ready(int j);
197
204bool is_wigner3_ready(const Rational& J);
205
212bool is_wigner6_ready(const Rational& J);
213
214template <class ... Integer> constexpr
215int temp_init_size(Integer... vals) noexcept {
216 constexpr auto N = sizeof...(Integer);
217 static_assert(N > 0);
218 const std::array<int, N> v{int(vals)...};
219 return 1 + 2 * (*std::max_element(v.begin(), v.end()));
220}
221
237
254
255#endif // wigner_functions_h
#define abs(x)
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
constexpr Numeric e
Elementary charge convenience name [C].
Contains the rational class definition.
#define RATIONAL_UNDEFINED
Definition: rational.h:357
#define N
Definition: rng.cc:164
#define M
Definition: rng.cc:165
Implements rational numbers to work with other ARTS types.
Definition: rational.h:43
#define d
#define v
#define a
#define c
#define b
constexpr std::pair< Rational, Rational > wigner3j_limits(const Rational a=0, const Rational b=0, const Rational c=0, const Rational d=0, const Rational e=0)
bool is_wigner_ready(int j)
Tells if the function can deal with the input integer.
Numeric dwigner6j(Index A, Index B, Index C, Index D, Index F)
Computes the wigner 6J symbol with floating point precision.
Numeric wigner6j(const Rational j1, const Rational j2, const Rational j3, const Rational l1, const Rational l2, const Rational l3)
Wigner 6J symbol.
bool is_wigner3_ready(const Rational &J)
Tells if the function is ready for Wigner 3J calculations.
Index make_wigner_ready(int largest, int fastest, int size)
Ready Wigner.
Numeric dwigner3j(Index M, Index J1, Index J2, Index J)
Computes the wigner 3J symbol with floating point precision.
constexpr int temp_init_size(Integer... vals) noexcept
bool is_wigner6_ready(const Rational &J)
Tells if the function is ready for Wigner 6J calculations.
Numeric wigner3j(const Rational j1, const Rational j2, const Rational j3, const Rational m1, const Rational m2, const Rational m3)
Wigner 3J symbol.
std::pair< Rational, Rational > wigner_limits(std::pair< Rational, Rational > a, std::pair< Rational, Rational > b)