19 // Declaration of LAPACK subroutines
20 // Make sure the data types match your version of LAPACK
22 extern "C" void dgesvd_(char const* JOBU,
37 extern "C" void dgels_(char const* TRANS,
50 const double EPS = 1e-12;
52 // binomial coefficients
54 std::vector<int> cache;
58 int operator()(int n, int k);
63 std::vector<int> elem;
69 // create a non-initialized weight
72 // create irrep weight of given index
74 weight(int N, int index);
76 // assign from another instance
77 clebsch::weight &operator=(const clebsch::weight &w);
79 // access elements of this weight (k = 1, ..., N)
80 int &operator()(int k);
81 const int &operator()(int k) const;
85 bool operator<(const weight &w) const;
86 bool operator==(const weight &w) const;
88 // element-wise sum of weights
89 clebsch::weight operator+(const weight &w) const;
91 // returns the index of this irrep weight (index = 0, 1, ...)
95 // returns the dimension of this irrep weight
97 long long dimension() const;
102 std::vector<int> elem;
109 pattern(const pattern &pat);
111 // create pattern of given index from irrep weight
113 pattern(const weight &irrep, int index = 0);
115 // access elements of this pattern (l = 1, ..., N; k = 1, ..., l)
116 int &operator()(int k, int l);
117 const int &operator()(int k, int l) const;
119 // find succeeding/preceding pattern, return false if not possible
124 // returns the pattern index (index = 0, ..., dimension - 1)
128 // returns the pattern weight
130 clebsch::weight get_weight() const;
132 // returns matrix element of lowering operator J^(l)_-
133 // between this pattern minus M^(k,l) and this pattern
134 // (l = 1, ..., N; k = 1, ..., l)
136 double lowering_coeff(int k, int l) const;
138 // returns matrix element of raising operator J^(l)_+
139 // between this pattern plus M^(k,l) and this pattern
140 // (l = 1, ..., N; k = 1, ..., l)
142 double raising_coeff(int k, int l) const;
145 class decomposition {
146 std::vector<clebsch::weight> weights;
147 std::vector<int> multiplicities;
153 // save given irreps for later use
154 const weight factor1, factor2;
156 // construct the decomposition of factor1 times factor2 into irreps
158 decomposition(const weight &factor1, const weight &factor2);
160 // return the number of occurring irreps
163 // access the occurring irreps
164 // j = 0, ..., size() - 1
165 const clebsch::weight &operator()(int j) const;
167 // return the outer multiplicity of irrep in this decomposition
168 int multiplicity(const weight &irrep) const;
171 class index_adapter {
172 std::vector<int> indices;
173 std::vector<int> multiplicities;
179 // save given irreps for later use
180 const int factor1, factor2;
182 // construct this index_adapter from a given decomposition
183 index_adapter(const clebsch::decomposition &decomp);
185 // return the number of occurring irreps
188 // access the occurring irreps
189 int operator()(int j) const;
191 // return the outer multiplicity of irrep in this decomposition
192 int multiplicity(int irrep) const;
196 std::map<std::vector<int>, double> clzx;
198 // access Clebsch-Gordan coefficients in convenient manner
199 void set(int factor1_state,
201 int multiplicity_index,
205 // internal functions, doing most of the work
206 void highest_weight_normal_form(); // Eq. (37)
207 void compute_highest_weight_coeffs(); // Eq. (36)
208 void compute_lower_weight_coeffs(int multip_index, int state, std::vector<char> &done); // Eq. (40)
214 // save irreps and their dimensions for later use
215 const weight factor1, factor2, irrep;
216 const int factor1_dimension, factor2_dimension, irrep_dimension;
218 // outer multiplicity of irrep in this decomposition
219 const int multiplicity;
221 // construct all Clebsch-Gordan coefficients of this decomposition
222 coefficients(const weight &irrep, const weight &factor1, const weight &factor2);
224 // access Clebsch-Gordan coefficients (read-only)
225 // multiplicity_index = 0, ..., multiplicity - 1
226 // factor1_state = 0, ..., factor1_dimension - 1
227 // factor2_state = 0, ..., factor2_dimension - 1
228 // irrep_state = 0, ..., irrep_dimension
229 double operator()(int factor1_state,
231 int multiplicity_index,
232 int irrep_state) const;