11 cout << "What would you like to do?" << endl;
12 cout << "1) Translate an i-weight S to its index P(S)" << endl;
13 cout << "2) Recover an i-weight S from its index P(S)" << endl;
14 cout << "3) Translate a pattern M to its index Q(M)" << endl;
15 cout << "4) Recover a pattern M from its index Q(M)" << endl;
16 cout << "5) Calculate Clebsch-Gordan coefficients for S x S' -> S''" << endl;
17 cout << "6) Calculate all Glebsch-Gordan coefficients for S x S'" << endl;
18 cout << "0) Quit" << endl;
22 } while (choice < 0 || choice > 6);
28 cout << "N (e.g. 3): ";
35 for (int k = 1; k <= N; ++k) {
38 cout << S.index() << endl;
45 clebsch::weight S(N, P);
47 for (int k = 1; k <= N; ++k) {
54 clebsch::pattern M(N);
55 for (int l = N; l >= 1; --l) {
56 cout << "Row l = " << l << ": ";
57 for (int k = 1; k <= l; ++k) {
61 cout << "Index: " << M.index() + 1 << endl;
67 for (int i = 1; i <= N; ++i) {
72 cout << "Index (1..dim(S)): ";
74 clebsch::pattern M(S, Q - 1);
75 for (int l = N; l >= 1; --l) {
76 for (int k = 1; k <= l; ++k) {
77 cout << M(k, l) << '\t';
85 cout << "Irrep S (e.g.";
86 for (int k = N - 1; k >= 0; --k) {
90 for (int k = 1; k <= N; ++k) {
94 clebsch::weight Sprime(N);
95 cout << "Irrep S' (e.g.";
96 for (int k = N - 1; k >= 0; --k) {
100 for (int k = 1; k <= N; ++k) {
104 clebsch::decomposition decomp(S, Sprime);
105 cout << "Littlewood-Richardson decomposition S \\otimes S' = \\oplus S'':" << endl;
106 cout << "[irrep index] S'' (outer multiplicity) {dimension d_S}" << endl;
107 for (int i = 0; i < decomp.size(); ++i) {
108 cout << "[" << decomp(i).index() << "] ";
109 for (int k = 1; k <= N; ++k) {
110 cout << decomp(i)(k) << ' ';
112 cout << '(' << decomp.multiplicity(decomp(i)) << ") {"
113 << decomp(i).dimension() << "}" << endl;;
116 clebsch::weight Sdoubleprime(N);
117 for (bool b = true; b; ) {
118 cout << "Irrep S'': ";
119 for (int k = 1; k <= N; ++k) {
120 cin >> Sdoubleprime(k);
122 for (int i = 0; i < decomp.size(); ++i) {
123 if (decomp(i) == Sdoubleprime) {
129 cout << "S'' does not occur in the decomposition" << endl;
135 cout << "Outer multiplicity index: ";
137 if (1 <= alpha && alpha <= decomp.multiplicity(Sdoubleprime)) {
140 cout << "S'' does not have this multiplicity" << endl;
144 cout << "Enter file name to write to file (leave blank for screen output): ";
145 cin.ignore(1234, '\n');
146 getline(cin, file_name);
148 const clebsch::coefficients C(Sdoubleprime, S, Sprime);
149 int dimS = S.dimension(),
150 dimSprime = Sprime.dimension(),
151 dimSdoubleprime = Sdoubleprime.dimension();
153 ofstream os(file_name.c_str());
154 (file_name.empty() ? cout : os).setf(ios::fixed);
155 (file_name.empty() ? cout : os).precision(15);
156 (file_name.empty() ? cout : os) << "List of nonzero CGCs for S x S' => S'', alpha" << endl;
157 (file_name.empty() ? cout : os) << "Q(M)\tQ(M')\tQ(M'')\tCGC" << endl;
158 for (int i = 0; i < dimSdoubleprime; ++i) {
159 for (int j = 0; j < dimS; ++j) {
160 for (int k = 0; k < dimSprime; ++k) {
161 double x = double(C(j, k, alpha - 1, i));
163 if (fabs(x) > clebsch::EPS) {
164 (file_name.empty() ? cout : os) << j + 1 << '\t'
165 << k + 1 << '\t' << i + 1 << '\t' << x << endl;
174 clebsch::weight S(N);
175 cout << "Irrep S (e.g.";
176 for (int k = N - 1; k >= 0; --k) {
180 for (int k = 1; k <= N; ++k) {
184 clebsch::weight Sprime(N);
185 cout << "Irrep S' (e.g.";
186 for (int k = N - 1; k >= 0; --k) {
190 for (int k = 1; k <= N; ++k) {
195 cout << "Enter file name to write to file (leave blank for screen output): ";
196 cin.ignore(1234, '\n');
197 getline(cin, file_name);
199 ofstream os(file_name.c_str());
200 (file_name.empty() ? cout : os).setf(ios::fixed);
201 (file_name.empty() ? cout : os).precision(15);
203 clebsch::decomposition decomp(S, Sprime);
204 (file_name.empty() ? cout : os) <<
205 "Littlewood-Richardson decomposition S \\otimes S' = \\oplus S'':" << endl;
206 (file_name.empty() ? cout : os) <<
207 "[irrep index] S'' (outer multiplicity) {dimension d_S}" << endl;
208 for (int i = 0; i < decomp.size(); ++i) {
209 (file_name.empty() ? cout : os) << "[" << decomp(i).index() << "] ";
210 for (int k = 1; k <= N; ++k) {
211 (file_name.empty() ? cout : os) << decomp(i)(k) << ' ';
213 (file_name.empty() ? cout : os) << '(' << decomp.multiplicity(decomp(i)) << ") {"
214 << decomp(i).dimension() << "}" << endl;;
217 for (int i = 0; i < decomp.size(); ++i) {
218 const clebsch::coefficients C(decomp(i),S, Sprime);
219 int dimS = S.dimension(),
220 dimSprime = Sprime.dimension(),
221 dimSdoubleprime = decomp(i).dimension();
223 for (int m = 0; m < C.multiplicity; ++m) {
224 (file_name.empty() ? cout : os) << "List of nonzero CGCs for S x S' => S'' = (";
225 for (int j = 1; j <= N; ++j) cout << decomp(i)(j) << (j < N ? ' ' : ')');
226 (file_name.empty() ? cout : os) << ", alpha = " << m + 1 << endl;
227 (file_name.empty() ? cout : os) << "Q(M)\tQ(M')\tQ(M'')\tCGC" << endl;
228 for (int i = 0; i < dimSdoubleprime; ++i) {
229 for (int j = 0; j < dimS; ++j) {
230 for (int k = 0; k < dimSprime; ++k) {
231 double x = double(C(j, k, m, i));
233 if (fabs(x) > clebsch::EPS) {
234 (file_name.empty() ? cout : os) << j + 1<< '\t'
235 << k + 1 << '\t' << i + 1 << '\t' << x << endl;
241 (file_name.empty() ? cout : os) << endl;