CLHEP
2.4.7.1
C++ Class Library for High Energy Physics
CLHEP
GenericFunctions
ClebschGordanCoefficientSet.hh
Go to the documentation of this file.
1
#ifndef _ClebschGordanCoefficientSet_h_
2
#define _ClebschGordanCoefficientSet_h_
3
#include <map>
4
#include <algorithm>
5
#include <cmath>
6
namespace
Genfun
{
7
8
class
ClebschGordanCoefficientSet
{
9
10
public
:
11
12
double
operator ()
(
unsigned
int
l1,
unsigned
int
l2,
int
m1,
int
m2,
int
L,
int
M)
const
;
13
14
private
:
15
16
// Key used to optimize access (look up previously calcuated results).
17
class
Key {
18
19
public
:
20
21
inline
Key(
unsigned
int
xl1,
unsigned
int
xl2,
int
xm1,
int
xm2,
unsigned
int
xL):
22
l1(xl1),l2(xl2),m1(xm1),m2(xm2),L(xL) {}
23
24
inline
bool
operator < (
const
Key & o)
const
{
25
if
( l1!=o.l1)
return
l1<o.l1;
26
if
( l2!=o.l2)
return
l2<o.l2;
27
if
( m1!=o.m1)
return
m1<o.m1;
28
if
( m2!=o.m2)
return
m2<o.m2;
29
if
( L!=o.L )
return
L<o.L;
30
return
false
;
31
}
32
33
34
inline
bool
operator== (
const
Key & o)
const
{
35
return
l1==o.l1 && l2 == o.l2 && m1==o.m1 && m2==o.m2 && L == o.L;
36
}
37
38
private
:
39
40
unsigned
int
l1;
41
unsigned
l2;
42
int
m1;
43
int
m2;
44
unsigned
int
L;
45
// M=m1+m2;
46
47
};
48
49
50
mutable
std::map<Key, double> coeff;
51
52
static
double
calcCoefficient(
int
l1,
int
l2,
int
L,
int
m1,
int
m2,
int
M);
53
54
};
55
56
57
58
59
inline
double
ClebschGordanCoefficientSet::operator ()
(
unsigned
int
l1,
unsigned
int
l2,
int
m1,
int
m2,
int
L,
int
M)
const
{
60
if
((m1+m2)!=M)
return
0;
61
62
Key key(l1,l2,m1,m2,L);
63
std::map<Key,double>::iterator i=coeff.find(key),end=coeff.end();
64
if
(i==end) {
65
double
c = calcCoefficient(l1, l2, L, m1, m2,M);
66
coeff[key]=c;
67
return
c;
68
}
69
70
return
(*i).second;
71
72
}
73
}
74
75
#endif
Genfun::ClebschGordanCoefficientSet
Definition
ClebschGordanCoefficientSet.hh:8
Genfun::ClebschGordanCoefficientSet::operator()
double operator()(unsigned int l1, unsigned int l2, int m1, int m2, int L, int M) const
Definition
ClebschGordanCoefficientSet.hh:59
Genfun
Definition
Abs.hh:14
Generated by
1.10.0