ls1-MarDyn
ls1-MarDyn molecular dynamics code
WignerMatrix.h
1/*
2 * WignerMatrix.h
3 *
4 * Created on: Dec 11, 2014
5 * Author: uwe
6 */
7
8#ifndef WIGNERMATRIX_H_
9#define WIGNERMATRIX_H_
10
11#include "CuboidPyramidalMatrix.h"
12#include <vector>
13
14namespace bhfmm {
15
16typedef enum {
17 ROT_TYPE_L = 0,
18 ROT_TYPE_M = 1,
19 ROT_TYPE_UNINITIALIZED
20} RotationType;
21
23public:
24 /* constructor */
25 WignerMatrix() : _type(ROT_TYPE_UNINITIALIZED), order(0), mat() {}
26
27 WignerMatrix(RotationType rt, unsigned ord, bool clean = false) :
28 _type(rt), order(ord), mat(ord + 1, clean) {}
29
30 /* destructor */
31 ~~WignerMatrix() {}
32
33
34 void clear() {mat.clear();}
35 unsigned get_num_entries() const { return mat.get_num_entries();}
36 unsigned get_order() const {return order;}
37
38 void evaluate(double theta);
39
40 /* prints all matrix elements to order maxl */
41 void print(int maxl);
42
43 //const accesssor
44 inline double acc_c(unsigned l, unsigned m, int k) const {return mat.access_const(l,m,k);}
45
46 //direct accessor
47 inline double & acc(unsigned l, unsigned m, int k) {return mat.access(l,m,k);}
48
49 RotationType getType() const {return _type;}
50
51private:
52 RotationType _type;
53
54 // multiply by sqrt(((l-k)!*(l+k)!)/((l-m)!*(l+m)!))
55 void scale();
56
57 //sequential accessor
58 inline double & acc_seq(unsigned l) {return mat.access_seq(l);}
59
60 //sequential const accessor
61 inline double acc_c_seq(unsigned l) const {return mat.access_seq_const(l);}
62
63 void evaluate_0_Pip2(double theta);
64
65 void mirror_k();
66
67 template <class PowPair>
68 void apply_minus_one_pow();
69
70
71 unsigned order;
73
74 // helper classes to avoid code duplication
75 class l_m {
76 public:
77 inline static int sum(int l, int m, int /*k*/) {
78 return l + m;
79 }
80 };
81
82 class l_k {
83 public:
84 inline static int sum(int l, int /*m*/, int k) {
85 return l + k;
86 }
87 };
88
89 class m_k {
90 public:
91 inline static int sum(int /*l*/, int m, int k) {
92 return m + k;
93 }
94 };
95
96
97 void initializeSqrtLookUp();
98 double lookUpFactor(unsigned l, unsigned m, unsigned k) const {
99 return (_sqrtFactorialLookUp[l-k] * _sqrtFactorialLookUp[l+k]) / (_sqrtFactorialLookUp[l-m] * _sqrtFactorialLookUp[l+m]);
100 }
101 // Look-up table for sqrt(n!) for n up to 2*ord
102 static std::vector<double> _sqrtFactorialLookUp;
103 static bool _sqrtFactorialLookUpInitialized;
104
105};
106
107} // namespace bhfmm
108
109
110#endif /* WIGNERMATRIX_H_ */
Definition: CuboidPyramidalMatrix.h:16
Definition: WignerMatrix.h:22
Definition: L2PCellProcessor.cpp:15