5 #include "su2clebsch.hpp"
10 int ipow(int base, int exp)
24 prestore::prestore(unsigned int _max2j)
27 cgcdata = new double[ipow(max2j+1,6)];
29 for (int factor1_2j=0; factor1_2j<=max2j; factor1_2j++)
30 for (int factor1_mp=0; factor1_mp<=max2j; factor1_mp++)
31 for (int factor2_2j=0; factor2_2j<=max2j; factor2_2j++)
32 for (int factor2_mp=0; factor2_mp<=max2j; factor2_mp++)
33 for (int irrep_2j=0; irrep_2j<=max2j; irrep_2j++)
34 for (int irrep_mp=0; irrep_mp<=max2j; irrep_mp++)
36 cgcdata[ factor1_2j*ipow(max2j+1,5) + factor1_mp*ipow(max2j+1,4) +
37 factor2_2j*ipow(max2j+1,3) + factor2_mp*ipow(max2j+1,2) +
38 irrep_2j*(max2j+1) + irrep_mp ]
40 cgc( factor1_2j, 2*factor1_mp-max2j, factor2_2j, 2*factor2_mp-max2j,
41 irrep_2j, 2*irrep_mp-max2j );
45 bool stateValid(int state_2j, int state_2m)
47 if ( abs(state_2m) > state_2j || (state_2j + state_2m) % 2 != 0 )
53 double cgc (int factor1_2j, int factor1_2m, int factor2_2j, int factor2_2m,
54 int irrep_2j, int irrep_2m, const prestore& Prestore)
56 if ( ! ( stateValid(factor1_2j, factor1_2m) && stateValid(factor2_2j, factor2_2m) && stateValid(irrep_2j, irrep_2m) ) )
59 if ( factor1_2j > Prestore.max2j || factor2_2j > Prestore.max2j || irrep_2j > Prestore.max2j )
60 return cgc(factor1_2j, factor1_2m, factor2_2j, factor2_2m, irrep_2j, irrep_2m);
62 return Prestore.cgcdata[ factor1_2j*ipow(Prestore.max2j+1,5) +
63 (factor1_2m+Prestore.max2j)/2 *ipow(Prestore.max2j+1,4) +
64 factor2_2j*ipow(Prestore.max2j+1,3) +
65 (factor2_2m+Prestore.max2j)/2 *ipow(Prestore.max2j+1,2) +
66 irrep_2j*(Prestore.max2j+1) +
67 (irrep_2m+Prestore.max2j)/2 ];
70 double cgc (int factor1_2j, int factor1_2m, int factor2_2j, int factor2_2m,
71 int irrep_2j, int irrep_2m)
73 if ( ! ( stateValid(factor1_2j, factor1_2m) && stateValid(factor2_2j, factor2_2m) && stateValid(irrep_2j, irrep_2m) ) )
76 const int factor1_n = (factor1_2j + factor1_2m) / 2;
77 const int factor2_n = (factor2_2j + factor2_2m) / 2;
78 const int irrep_n = (irrep_2j + irrep_2m) / 2;
80 clebsch::weight factor1_S(2);
81 factor1_S(1) = factor1_2j;
82 clebsch::weight factor2_S(2);
83 factor2_S(1) = factor2_2j;
84 clebsch::weight irrep_S(2);
85 irrep_S(1) = irrep_2j;
87 clebsch::decomposition decomp(factor1_S, factor2_S);
90 for (int i = 0; i < decomp.size(); ++i) {
91 if (decomp(i) == irrep_S) {
100 const clebsch::coefficients C(irrep_S, factor1_S, factor2_S);
102 return C( factor1_n, factor2_n, 0, irrep_n );