-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathndsu3lib_coupling_su3so3.F90
1800 lines (1708 loc) · 86 KB
/
ndsu3lib_coupling_su3so3.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!******************************************************
!
! ndsu3lib_coupling_su3so3.F90
!! Module for SU(3)-SO(3) reduced coupling coefficients
!
! Jakub Herko
! University of Notre Dame
!
! SPDX-License-Identifier: MIT
!
!******************************************************
MODULE ndsu3lib_coupling_su3so3
!! Module for SU(3)-SO(3) reduced coupling coefficients
!-----------------------------------------------------------------------------
! Note: In subroutines with polymorphic interface below, SELECT TYPE cannot be
! used to identify sequence type mp_real. This is solved using pointers - see
! https://www.nag.com/nagware/np/r62_doc/manual/compiler_9_2.html
!-----------------------------------------------------------------------------
USE ndsu3lib_tools
USE ndsu3lib_coupling_canonical
IMPLICIT NONE
CONTAINS
FUNCTION Kmin(lambda, mu, L) RESULT(res)
!--------------------------------------------------------------------------
!! Lowest projection K of angular momentum L within SU(3) irrep (lambda,mu)
! as given by Eq.(...) in J.Herko et al. in preparation
!--------------------------------------------------------------------------
IMPLICIT NONE
INTEGER, INTENT(IN) :: lambda
!! SU(3) irrep label lambda
INTEGER, INTENT(IN) :: mu
!! SU(3) irrep label mu
INTEGER, INTENT(IN) :: L
!! angular momentum L
INTEGER :: res
!! Lowest projection K of angular momentum L
res = MAX(0, L - mu)
res = res + MOD(res + lambda, 2) ! K and lambda must have the same parity.
IF (res == 0) res = MOD(L + mu, 2)*2 ! If K=0, L and mu must have the same parity.
END FUNCTION Kmin
SUBROUTINE calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
!----------------------------------------------------------------------------------------------------------------------
!! Internal subroutine for calculation of inner product of SU(3)-SU(2)xU(1) and non-orthogonal SU(3)-SO(3) basis states
! / (lambda,mu) | (lambda,mu)\
! \epsilon,Lambda,M_Lambda | K,L,M /
! using Eq.(...) in [1] or equivalently Eq.(26) in [2]
!
! References: [1] J.Herko et al. in preparation
! [2] J.P.Draayer, Y.Akiyama, J.Math.Phys., Vol.14, No.12 (1973) 1904
!
! Input arguments: lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q
! Output argument: coeff
!
! Lambda2p is 2*Lambda
! MLambda2p is 2*M_Lambda
! M is K
! Mp is M
! p and q are the p,q labels of SU(2)xU(1) basis state
! coeff is the inner product
!----------------------------------------------------------------------------------------------------------------------
!#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
!USE mpmodule
!#endif
IMPLICIT NONE
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS(*), TARGET, INTENT(OUT) :: coeff
!! Resulting inner product
TYPE(mp_real), POINTER :: point
#else
REAL(KIND=8), INTENT(OUT) :: coeff
!! Resulting inner product
#endif
! TYPE(su3irrep),INTENT(IN) :: irrep
INTEGER, INTENT(IN) :: lambda
!! SU(3) irrep label lambda
INTEGER, INTENT(IN) :: mu
!! SU(3) irrep label mu
INTEGER, INTENT(IN) :: epsilon
!! U(1) label epsilon of SU(2)xU(1) basis state
INTEGER, INTENT(IN) :: Lambda2p
!! Twice the SU(2) label Lambda of SU(2)xU(1) basis state
INTEGER, INTENT(IN) :: MLambda2p
!! Twice the projection label M_Lambda of Lambda
INTEGER, INTENT(IN) :: M
!! Projection K of angular momentum L of SO(3) basis state along body-fixed 3-axis
INTEGER, INTENT(IN) :: L
!! Angular momentum L of SO(3) basis state
INTEGER, INTENT(IN) :: Mp
!! Projection M of angular momentum L of SO(3) basis state along laboratory frame z-axis
INTEGER, INTENT(IN) :: p
!! Label p of SU(2)xU(1) basis state
INTEGER, INTENT(IN) :: q
!! Label q of SU(2)xU(1) basis state
REAL(KIND=8) :: S11, S12, S2
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
REAL(wp) :: coeffq, S11q, S12q, S2q
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
TYPE(mp_realm) :: coeffq, S11q, S12q, S2q
#endif
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
TYPE(mp_real) :: S11mp, S12mp, S2mp
#endif
INTEGER :: a4, LmM, LpM, LmMp, gama, NLambda2p, k2L, kkappa, alpha, &
alphamin, alphamax, alphaminS2, alphamaxS2, LambdaM, MNLambda2p, LambdapMp, x, y, xm, xn, &
aux1, ind1, aux2, ind2, aux3, ind3, aux4, xpys, lambdas, aux5, indicator
! IF (I == 1) THEN
! lambda = irrep%lambda
! mu = irrep%mu
! epsilon = epsilonx
! MLambda2p = MLambda2px
! ELSE ! See Eq.(32) in Draayer & Akiyama and the text below it.
! lambda = irrep%mu
! mu = irrep%lambda
! epsilon = -epsilonx
! MLambda2p = -MLambda2px
! ENDIF
! p = ((2*(lambda - mu) - epsilon)/3 + Lambda2p)/2
LambdapMp = (Lambda2p + Mp)/2
! q = p + mu - Lambda2p
LmM = L - M
LmMp = L - Mp
alphaminS2 = MAX(0, -Mp - M) ! alphaminS2 is lower bound for alpha in S_2 in Eq.(26) in [2]
alphamaxS2 = MIN(LmM, LmMp) - 2 ! alphamaxS2 is upper bound for alpha in S_2 in Eq.(26) in [2] minus 2
LpM = L + M
LambdaM = (lambda + M)/2
xm = (Lambda2p - MLambda2p)/2
k2L = lambda + mu + L
kkappa = p + q
lambdas = lambda**2
NLambda2p = 2*(p + 1) - Lambda2p
MNLambda2p = (MLambda2p + NLambda2p)/2
xn = (Lambda2p - NLambda2p)/2
aux1 = xn*(xn + 1)/2
ind3 = p*(p + 1)/2
aux2 = ind3 + xm
aux3 = LmM*(LmM + 1)/2
aux4 = LpM*(LpM + 1)/2 + LmMp
aux5 = k2L*(k2L + 1)/2 + k2L - q - (lambda + M + Lambda2p + Mp)/2 - alphaminS2
#if defined(NDSU3LIB_OMP)
CALL lock%reader_lock()
DO WHILE (MAX(Lambda2p, 2*L, lambda + mu + 1) > upbound_binom)
IF (.NOT. lock%writer_lock(.TRUE.)) THEN
CALL lock%reader_unlock()
CALL lock%reader_lock()
!$omp flush acquire
CYCLE
END IF
!$omp flush acquire
CALL reallocate_binom(50)
!$omp flush release
CALL lock%writer_unlock(.TRUE.)
END DO
! DO WHILE(MAX(lambda,2*MIN(xm,xn+p+1)-xm+p)>upbound_I)
DO WHILE (MAX(lambda, 2*Lambda2p - xm + p) > upbound_I)
IF (.NOT. lock%writer_lock(.TRUE.)) THEN
CALL lock%reader_unlock()
CALL lock%reader_lock()
!$omp flush acquire
CYCLE
END IF
!$omp flush acquire
CALL reallocate_I(50)
!$omp flush release
CALL lock%writer_unlock(.TRUE.)
END DO
DO WHILE (kkappa > upbound_S .OR. k2L - kkappa > upbound_S)
IF (.NOT. lock%writer_lock(.TRUE.)) THEN
CALL lock%reader_unlock()
CALL lock%reader_lock()
!$omp flush acquire
CYCLE
END IF
!$omp flush acquire
CALL reallocate_S(50)
!$omp flush release
CALL lock%writer_unlock(.TRUE.)
END DO
#else
DO WHILE (MAX(Lambda2p, 2*L, lambda + mu + 1) > upbound_binom)
CALL reallocate_binom(50)
END DO
! DO WHILE(MAX(lambda,2*MIN(xm,xn+p+1)-xm+p)>upbound_I)
DO WHILE (MAX(lambda, 2*Lambda2p - xm + p) > upbound_I)
CALL reallocate_I(50)
END DO
DO WHILE (kkappa > upbound_S .OR. k2L - kkappa > upbound_S)
CALL reallocate_S(50)
END DO
#endif
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
SELECT TYPE (coeff)
TYPE IS (REAL(KIND=8))
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (k2L <= 17) THEN
indicator = 1
ELSE IF (k2L < 60) THEN
IF (mu <= (k2L + 1)/2 - lambda + k2L/3) THEN
indicator = 2
ELSE
indicator = 1
END IF
ELSE
indicator = 2
END IF
IF (indicator == 1) THEN ! double precision used
#endif
coeff = 0.D0
DO gama = 0, p
MNLambda2p = MNLambda2p - 1
xn = xn + 1
aux1 = aux1 + xn
IF (lambda - gama >= gama) THEN ! S12=I(lambda-gama,gama,LambdaM)
S12 = Ia(((lambda - gama)**3 + lambdas + gama)/2 + LambdaM)
ELSE IF (BTEST(LambdaM, 0)) THEN ! S12=(-1)^(LambdaM)*I(lambda-gama,gama,LambdaM)
S12 = -Ia((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
ELSE
S12 = Ia((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
END IF
! S12 is second S_1 in Eq.(26) in [2], where only alpha=0 contributes. Caution: There is typo: it should be
! S_1(M_Lambda=Lambda,Lambda,N_Lambda,M), not S_1(N_Lambda,Lambda,M_Lambda=Lambda,M)
IF (S12 /= 0.D0) THEN
alphamin = MAX(0, -MNLambda2p) ! alphamin is lower bound for alpha in first S_1 in Eq.(26) in [2]
alphamax = MIN(xm, xn) ! alphamax is upper bound for alpha in first S_1 in Eq.(26) in [2]
S11 = 0.D0 ! S11 is first S_1 in Eq.(26) in [2]
x = 2*alphamin + MNLambda2p
y = Lambda2p - x
xpys = (x + y)**2
ind1 = aux1 + alphamin
ind2 = aux2 - alphamin
DO alpha = alphamin, alphamax
IF (MAX(0, LambdapMp - x) <= MIN(y, LambdapMp)) THEN
IF (x >= y) THEN
S11 = S11 + binom(ind1)*binom(ind2)*Ia((x**3 + xpys + y)/2 + LambdapMp)
ELSE IF (BTEST(LambdapMp, 0)) THEN
S11 = S11 - binom(ind1)*binom(ind2)*Ia((y**3 + xpys + x)/2 + LambdapMp)
ELSE
S11 = S11 + binom(ind1)*binom(ind2)*Ia((y**3 + xpys + x)/2 + LambdapMp)
END IF
ELSE
EXIT
END IF
x = x + 2
y = y - 2
ind1 = ind1 + 1
ind2 = ind2 - 1
END DO
IF (S11 /= 0.D0) THEN
S2 = 0.D0 ! S2 is S_2 is Eq.(26) in [2]
a4 = upbound_S*kkappa*(kkappa + upbound_S + 2)/2 + aux5
ind1 = aux3 + alphaminS2
ind2 = aux4 - alphaminS2
IF (BTEST(alphaminS2, 0)) THEN ! if alphaminS2 is odd
DO alpha = alphaminS2, alphamaxS2, 2
S2 = S2 - binom(ind1)*binom(ind2)*Sa(a4)
S2 = S2 + binom(ind1 + 1)*binom(ind2 - 1)*Sa(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2 = S2 - binom(ind1)*binom(ind2)*Sa(a4)
ELSE
S2 = S2 - binom(ind1)*binom(ind2)*Sa(a4)
S2 = S2 + binom(ind1 + 1)*binom(ind2 - 1)*Sa(a4 - 1)
END IF
ELSE
DO alpha = alphaminS2, alphamaxS2, 2
S2 = S2 + binom(ind1)*binom(ind2)*Sa(a4)
S2 = S2 - binom(ind1 + 1)*binom(ind2 - 1)*Sa(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2 = S2 + binom(ind1)*binom(ind2)*Sa(a4)
S2 = S2 - binom(ind1 + 1)*binom(ind2 - 1)*Sa(a4 - 1)
ELSE
S2 = S2 + binom(ind1)*binom(ind2)*Sa(a4)
END IF
END IF
IF (S2 /= 0.D0) coeff = coeff + binom(ind3)*S11*S12*S2/DBLE(k2L + 1)
END IF
END IF
aux5 = aux5 - k2L
k2L = k2L - 1
kkappa = kkappa - 1
aux2 = aux2 - p + gama
ind3 = ind3 + 1
END DO
IF (coeff /= 0.D0) THEN
! Factor (2*L+1)/(2**p) appears in C in Eq.(26) in [2] as squared but that is typo: (2L+1) should not be squared.
aux1 = lambda + mu + 1
aux2 = p + mu + 1
aux3 = 2*L*(L + 1)
S2 = DBLE(2*L + 1)*DSQRT((binom((lambdas + lambda)/2 + p)/binom(aux3 - Mp)) &
*(binom(mu*(mu + 1)/2 + q)/binom((Lambda2p*(Lambda2p + 2) + MLambda2p)/2)) &
*(binom(aux1*(aux1 + 1)/2 + q)/binom(aux2*(aux2 + 1)/2 + q))*binom(aux3 - M)) &
/(4.D0**DBLE(p))
! S2 is C
IF (BTEST(L - p, 0)) THEN
coeff = -coeff*S2
ELSE
coeff = coeff*S2
END IF
! ELSE
! RETURN
END IF
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
ELSE ! quad precision used
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
coeffq = 0.0_wp
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
coeffq = mprealm(0.D0, nwdsm)
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
DO gama = 0, p
MNLambda2p = MNLambda2p - 1
xn = xn + 1
aux1 = aux1 + xn
IF (lambda - gama >= gama) THEN ! S12=I(lambda-gama,gama,LambdaM)
S12q = Ia_quad(((lambda - gama)**3 + lambdas + gama)/2 + LambdaM)
ELSE IF (BTEST(LambdaM, 0)) THEN ! S12=(-1)^(LambdaM)*I(lambda-gama,gama,LambdaM)
S12q = -Ia_quad((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
ELSE
S12q = Ia_quad((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
END IF
! S12 is second S_1 in Eq.(26) in [2], where only alpha=0 contributes. Caution: There is typo: it should be
! S_1(M_Lambda=Lambda,Lambda,N_Lambda,M), not S_1(N_Lambda,Lambda,M_Lambda=Lambda,M)
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
IF (S12q /= 0.0_wp) THEN
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (S12q /= 0.D0) THEN
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
alphamin = MAX(0, -MNLambda2p) ! alphamin is lower bound for alpha in first S_1 in Eq.(26) in [2]
alphamax = MIN(xm, xn) ! alphamax is upper bound for alpha in first S_1 in Eq.(26) in [2]
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
S11q = 0.0_wp
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
S11q = mprealm(0.D0, nwdsm)
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
x = 2*alphamin + MNLambda2p
y = Lambda2p - x
xpys = (x + y)**2
ind1 = aux1 + alphamin
ind2 = aux2 - alphamin
DO alpha = alphamin, alphamax
IF (MAX(0, LambdapMp - x) <= MIN(y, LambdapMp)) THEN
IF (x >= y) THEN
S11q = S11q + binom_quad(ind1)*binom_quad(ind2)*Ia_quad((x**3 + xpys + y)/2 + LambdapMp)
ELSE IF (BTEST(LambdapMp, 0)) THEN
S11q = S11q - binom_quad(ind1)*binom_quad(ind2)*Ia_quad((y**3 + xpys + x)/2 + LambdapMp)
ELSE
S11q = S11q + binom_quad(ind1)*binom_quad(ind2)*Ia_quad((y**3 + xpys + x)/2 + LambdapMp)
END IF
ELSE
EXIT
END IF
x = x + 2
y = y - 2
ind1 = ind1 + 1
ind2 = ind2 - 1
END DO
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
IF (S11q /= 0.0_wp) THEN
S2q = 0.0_wp
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (S11q /= 0.D0) THEN
S2q = mprealm(0.D0, nwdsm)
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
a4 = upbound_S*kkappa*(kkappa + upbound_S + 2)/2 + aux5
ind1 = aux3 + alphaminS2
ind2 = aux4 - alphaminS2
IF (BTEST(alphaminS2, 0)) THEN ! if alphaminS2 is odd
DO alpha = alphaminS2, alphamaxS2, 2
S2q = S2q - binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
S2q = S2q + binom_quad(ind1 + 1)*binom_quad(ind2 - 1)*Sa_quad(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2q = S2q - binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
ELSE
S2q = S2q - binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
S2q = S2q + binom_quad(ind1 + 1)*binom_quad(ind2 - 1)*Sa_quad(a4 - 1)
END IF
ELSE
DO alpha = alphaminS2, alphamaxS2, 2
S2q = S2q + binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
S2q = S2q - binom_quad(ind1 + 1)*binom_quad(ind2 - 1)*Sa_quad(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2q = S2q + binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
S2q = S2q - binom_quad(ind1 + 1)*binom_quad(ind2 - 1)*Sa_quad(a4 - 1)
ELSE
S2q = S2q + binom_quad(ind1)*binom_quad(ind2)*Sa_quad(a4)
END IF
END IF
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
IF (S2q /= 0.0_wp) THEN
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (S2q /= 0.D0) THEN
#endif
#if defined(NDSU3LIB_QUAD)
coeffq = coeffq + binom_quad(ind3)*S11q*S12q*S2q/QFLOAT(k2L + 1)
#elif defined(NDSU3LIB_QUAD_GNU)
coeffq = coeffq + binom_quad(ind3)*S11q*S12q*S2q/REAL(k2L + 1, 16)
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
coeffq = coeffq + binom_quad(ind3)*S11q*S12q*S2q/DBLE(k2L + 1)
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
END IF
END IF
END IF
aux5 = aux5 - k2L
k2L = k2L - 1
kkappa = kkappa - 1
aux2 = aux2 - p + gama
ind3 = ind3 + 1
END DO
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
IF (coeffq /= 0.0_wp) THEN
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (coeffq /= 0.D0) THEN
#endif
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
! Factor (2*L+1)/(2**p) appears in C in Eq.(26) in [2] as squared but that is typo: (2L+1) should not be squared
aux1 = lambda + mu + 1
aux2 = p + mu + 1
aux3 = 2*L*(L + 1)
#endif
#if defined(NDSU3LIB_QUAD)
S2q = QFLOAT(2*L + 1)*QSQRT((binom_quad((lambdas + lambda)/2 + p) &
/binom_quad(aux3 - Mp)) &
*(binom_quad(mu*(mu + 1)/2 + q) &
/binom_quad((Lambda2p*(Lambda2p + 2) + MLambda2p)/2)) &
*(binom_quad(aux1*(aux1 + 1)/2 + q) &
/binom_quad(aux2*(aux2 + 1)/2 + q)) &
*binom_quad(aux3 - M)) &
/(4.0_wp**QFLOAT(p))
#elif defined(NDSU3LIB_QUAD_GNU)
S2q = REAL(2*L + 1, 16)*SQRT((binom_quad((lambdas + lambda)/2 + p) &
/binom_quad(aux3 - Mp)) &
*(binom_quad(mu*(mu + 1)/2 + q) &
/binom_quad((Lambda2p*(Lambda2p + 2) + MLambda2p)/2)) &
*(binom_quad(aux1*(aux1 + 1)/2 + q) &
/binom_quad(aux2*(aux2 + 1)/2 + q)) &
*binom_quad(aux3 - M)) &
/(4.0_wp**REAL(p, 16))
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
S2q = DBLE(2*L + 1)*SQRT((binom_quad((lambdas + lambda)/2 + p) &
/binom_quad(aux3 - Mp)) &
*(binom_quad(mu*(mu + 1)/2 + q) &
/binom_quad((Lambda2p*(Lambda2p + 2) + MLambda2p)/2)) &
*(binom_quad(aux1*(aux1 + 1)/2 + q) &
/binom_quad(aux2*(aux2 + 1)/2 + q)) &
*binom_quad(aux3 - M)) &
/(4.D0**DBLE(p))
#endif
! S2q is C
#if (defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU) || defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (BTEST(L - p, 0)) THEN
coeff = -coeffq*S2q
ELSE
coeff = coeffq*S2q
END IF
ELSE
coeff = 0.D0
! RETURN
END IF
END IF
#endif
! Now coeff is coefficient for E=HW. For E=HW' there is additinal phase
! factor of (-1)^((lambda+M)/2) according to Eq.(33,6B) in [2], therefore:
! IF (I /= J .AND. BTEST(LambdaM, 0)) coeff = -coeff
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS DEFAULT ! CLASS IS (mp_real)
point => coeff
point = mpreal(0.D0, nwds) ! coeff=mpreal(0.D0,nwds)
DO gama = 0, p
MNLambda2p = MNLambda2p - 1
xn = xn + 1
aux1 = aux1 + xn
IF (lambda - gama >= gama) THEN ! S12=I(lambda-gama,gama,LambdaM)
S12mp = Ia_mp(((lambda - gama)**3 + lambdas + gama)/2 + LambdaM)
ELSE IF (BTEST(LambdaM, 0)) THEN ! S12=(-1)^(LambdaM)*I(lambda-gama,gama,LambdaM)
S12mp = -Ia_mp((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
ELSE
S12mp = Ia_mp((gama**3 + lambdas + lambda - gama)/2 + LambdaM)
END IF
! S12 is second S_1 in Eq.(26) in [2], where only alpha=0 contributes. Caution: There is typo: it should be
! S_1(M_Lambda=Lambda,Lambda,N_Lambda,M), not S_1(N_Lambda,Lambda,M_Lambda=Lambda,M)
IF (S12mp /= 0.D0) THEN
alphamin = MAX(0, -MNLambda2p) ! alphamin is lower bound for alpha in first S_1 in Eq.(26) in [2]
alphamax = MIN(xm, xn) ! alphamax is upper bound for alpha in first S_1 in Eq.(26) in [2]
S11mp = mpreal(0.D0, nwds)
x = 2*alphamin + MNLambda2p
y = Lambda2p - x
xpys = (x + y)**2
ind1 = aux1 + alphamin
ind2 = aux2 - alphamin
DO alpha = alphamin, alphamax
IF (MAX(0, LambdapMp - x) <= MIN(y, LambdapMp)) THEN
IF (x >= y) THEN
S11mp = S11mp + binom_mp(ind1)*binom_mp(ind2)*Ia_mp((x**3 + xpys + y)/2 + LambdapMp)
ELSE IF (BTEST(LambdapMp, 0)) THEN
S11mp = S11mp - binom_mp(ind1)*binom_mp(ind2)*Ia_mp((y**3 + xpys + x)/2 + LambdapMp)
ELSE
S11mp = S11mp + binom_mp(ind1)*binom_mp(ind2)*Ia_mp((y**3 + xpys + x)/2 + LambdapMp)
END IF
ELSE
EXIT
END IF
x = x + 2
y = y - 2
ind1 = ind1 + 1
ind2 = ind2 - 1
END DO
IF (S11mp /= 0.D0) THEN
S2mp = mpreal(0.D0, nwds)
a4 = upbound_S*kkappa*(kkappa + upbound_S + 2)/2 + aux5
ind1 = aux3 + alphaminS2
ind2 = aux4 - alphaminS2
IF (BTEST(alphaminS2, 0)) THEN ! if alphaminS2 is odd
DO alpha = alphaminS2, alphamaxS2, 2
S2mp = S2mp - binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
S2mp = S2mp + binom_mp(ind1 + 1)*binom_mp(ind2 - 1)*Sa_mp(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2mp = S2mp - binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
ELSE
S2mp = S2mp - binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
S2mp = S2mp + binom_mp(ind1 + 1)*binom_mp(ind2 - 1)*Sa_mp(a4 - 1)
END IF
ELSE
DO alpha = alphaminS2, alphamaxS2, 2
S2mp = S2mp + binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
S2mp = S2mp - binom_mp(ind1 + 1)*binom_mp(ind2 - 1)*Sa_mp(a4 - 1)
a4 = a4 - 2
ind1 = ind1 + 2
ind2 = ind2 - 2
END DO
IF (BTEST(alphamaxS2, 0)) THEN
S2mp = S2mp + binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
S2mp = S2mp - binom_mp(ind1 + 1)*binom_mp(ind2 - 1)*Sa_mp(a4 - 1)
ELSE
S2mp = S2mp + binom_mp(ind1)*binom_mp(ind2)*Sa_mp(a4)
END IF
END IF
IF (S2mp /= 0.D0) point = point + binom_mp(ind3)*S11mp*S12mp*S2mp/DBLE(k2L + 1)
! coeff=coeff+binom_mp(ind3)*S11mp*S12mp*S2mp/DFLOAT(k2L+1)
END IF
END IF
aux5 = aux5 - k2L
k2L = k2L - 1
kkappa = kkappa - 1
aux2 = aux2 - p + gama
ind3 = ind3 + 1
END DO
IF (point /= 0.D0) THEN ! IF(coeff/=0.D0)THEN
! Factor (2*L+1)/(2**p) appears in C in Eq.(26) in [2] as squared but that is typo: (2L+1) should not be squared.
aux1 = lambda + mu + 1
aux2 = p + mu + 1
aux3 = 2*L*(L + 1)
S2mp = DBLE(2*L + 1)*SQRT((binom_mp((lambdas + lambda)/2 + p) &
/binom_mp(aux3 - Mp)) &
*(binom_mp(mu*(mu + 1)/2 + q) &
/binom_mp((Lambda2p*(Lambda2p + 2) + MLambda2p)/2)) &
*(binom_mp(aux1*(aux1 + 1)/2 + q) &
/binom_mp(aux2*(aux2 + 1)/2 + q)) &
*binom_mp(aux3 - M)) &
/(4.D0**DBLE(p))
! S2mp is C
IF (BTEST(L - p, 0)) THEN
point = -point*S2mp ! coeff=-coeff*S2mp
ELSE
point = point*S2mp ! coeff=coeff*S2mp
END IF
! ELSE
! RETURN
END IF
! Now coeff (or point) is coefficient for E=HW. For E=HW' there is additinal phase
! factor of (-1)^((lambda+M)/2) according to Eq.(33,6B) in [2], therefore:
! IF (I /= J .AND. BTEST(LambdaM, 0)) point = -point ! coeff=-coeff
END SELECT
#endif
#if defined(NDSU3LIB_OMP)
CALL lock%reader_unlock()
#endif
END SUBROUTINE calculate_transformation_coef_internal
SUBROUTINE calculate_transformation_coef(I, J, irrep, epsilonx, Lambda2p, MLambda2px, M, L, Mp, coeff)
!--------------------------------------------------------------------------------------------------------
!! Calculate inner product of SU(3)-SU(2)xU(1) and non-orthogonal SU(3)-SO(3) basis states of SU(3) irrep
! / (lambda,mu) | (lambda,mu)\
! \epsilon,Lambda,M_Lambda | K,L,M /
! using Eq.(...) in [1] or equivalently Eq.(26),(32), and (33,6B) in [2].
!
! References: [1] J.Herko et al. in preparation
! [2] J.P.Draayer, Y.Akiyama, J.Math.Phys., Vol.14, No.12 (1973) 1904
!
! Input arguments: I, J, irrep, epsilonx, Lambda2p, MLambda2px, M, L, Mp
! Output argument: coeff
!
! (I,J)=(1,1) => E=HW, (I,J)=(1,0) => E=HW', (I,J)=(0,0) => E=LW, (I,J)=(0,1) => E=LW' in [2]
! irrep%lambda is lambda, irrep%mu is mu,
! epsilonx is epsilon, Lambda2p is 2*Lambda, MLambda2px is 2*M_Lambda, M is K, L is L, Mp is M,
! coeff is resulting inner product.
!
! Note: There are 2 typos in equation (26) in [2]:
! 1) In overall factor C, factor (2L+1) should not be squared.
! 2) Second S_1 should be S_1(M_Lambda=Lambda,Lambda,N_Lambda,M) instead of
! S_1(N_Lambda,Lambda,M_Lambda=Lambda,M).
!--------------------------------------------------------------------------------------------------------
#if defined(NDSU3LIB_CACHE_C)
USE ISO_C_BINDING
#endif
IMPLICIT NONE
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS(*), TARGET, INTENT(OUT) :: coeff
!! Resulting inner product in arbitrary precision
TYPE(mp_real), POINTER :: point
#else
REAL(KIND=8), INTENT(OUT) :: coeff
!! Resulting inner product in double precision
#endif
TYPE(su3irrep), INTENT(IN) :: irrep
!! SU(3) irrep
#if defined(NDSU3LIB_CACHE_C)
INTEGER, INTENT(IN) :: I, J, epsilonx, Lambda2p, MLambda2px, Mp
INTEGER :: epsilon, MLambda2p
INTEGER(C_INT), INTENT(IN) :: M, L
INTEGER(C_INT) :: lambda, mu, p, q, absMLambda2p, absMp
#else
INTEGER, INTENT(IN) :: I
!! Parameter determining from which extremal-weight SU(3)-SU(2)xU(1) basis state the SU(3)-SO(3) basis state is projected.
!! Should be 1 if lambda < mu, otherwise it shuold be 0
INTEGER, INTENT(IN) :: J
!! Parameter determining from which extremal-weight SU(3)-SU(2)xU(1) basis state the SU(3)-SO(3) basis state is projected.
!! Should be 0 if lambda < mu, otherwise it shuold be 1
INTEGER, INTENT(IN) :: epsilonx
!! U(1) label epsilon of SU(3)-SU(2)xU(1) basis state
INTEGER, INTENT(IN) :: Lambda2p
!! Twice the SU(2) label Lambda of SU(3)-SU(2)xU(1) basis state
INTEGER, INTENT(IN) :: MLambda2px
!! Twice the projection label M_Lambda of Lambda
INTEGER, INTENT(IN) :: M
!! Projection K of angular momentum L of SU(3)-SO(3) basis state along body-fixed 3-axis
INTEGER, INTENT(IN) :: L
!! Angular momentum L of SU(3)-SO(3) basis state
INTEGER, INTENT(IN) :: Mp
!! Projection M of angular momentum L of SU(3)-SO(3) basis state along laboratory frame z-axis
INTEGER :: lambda, mu, epsilon, MLambda2p, p, q, absMLambda2p, absMp!, aux
#endif
#if defined(NDSU3LIB_CACHE)
INTEGER(KIND=8) :: key
REAL(KIND=8), POINTER :: point2
#endif
#if (defined(NDSU3LIB_CACHE) && (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU)))
TYPE(mp_real), POINTER :: point3
#endif
#if defined(NDSU3LIB_CACHE_C)
INTEGER(C_INT) :: search
INTERFACE
SUBROUTINE cache_search(lm, mu, p, q, absML, K, L, absM, search, coeff) BIND(C)
IMPORT C_INT, C_DOUBLE
INTEGER(C_INT), VALUE :: lm, mu, p, q, absML, K, L, absM
INTEGER(C_INT) :: search
REAL(C_DOUBLE) :: coeff
END SUBROUTINE cache_search
SUBROUTINE cache_insert(lm, mu, p, q, absML, K, L, absM, coeff) BIND(C)
IMPORT C_INT, C_DOUBLE
INTEGER(C_INT), VALUE :: lm, mu, p, q, absML, K, L, absM
REAL(C_DOUBLE), VALUE :: coeff
END SUBROUTINE cache_insert
END INTERFACE
#endif
IF (I == 1) THEN
lambda = irrep%lambda
mu = irrep%mu
epsilon = epsilonx
MLambda2p = MLambda2px
! aux=0
ELSE ! See Eq.(32) in [2] and text below it.
lambda = irrep%mu
mu = irrep%lambda
epsilon = -epsilonx
MLambda2p = -MLambda2px
! aux = lambda + mu
END IF
p = ((2*(lambda - mu) - epsilon)/3 + Lambda2p)/2
q = p + mu - Lambda2p
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
SELECT TYPE (coeff)
TYPE IS (REAL(KIND=8))
#endif
#if defined(NDSU3LIB_CACHE_C)
absMLambda2p = ABS(MLambda2p)
absMp = ABS(Mp)
IF (lambda < 256 .AND. mu < 256 .AND. p < 256 .AND. q < 256 .AND. absMLambda2p < 256 &
.AND. M < 256 .AND. L < 256 .AND. absMp < 256) THEN
CALL cache_search(lambda, mu, p, q, absMLambda2p, M, L, absMp, search, coeff)
IF (search == 0) THEN
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, &
absMLambda2p, M, L, absMp, p, q, coeff)
CALL cache_insert(lambda, mu, p, q, absMLambda2p, M, L, absMp, coeff)
END IF
IF (MLambda2p < 0 .AND. Mp >= 0) THEN
IF (BTEST((Lambda2p + Mp)/2, 0)) coeff = -coeff
ELSE IF (MLambda2p >= 0 .AND. Mp < 0) THEN
! IF (BTEST(q + (Lambda2p + MLambda2p)/2 - aux + L + M, 0)) coeff = -coeff
IF (BTEST(q + (Lambda2p + MLambda2p)/2 + L + M, 0)) coeff = -coeff
ELSE IF (MLambda2p < 0 .AND. Mp < 0) THEN
! IF (BTEST(q + Lambda2p - aux + L + M + (MLambda2p - Mp)/2, 0)) coeff = -coeff
IF (BTEST(q + Lambda2p + L + M + (MLambda2p - Mp)/2, 0)) coeff = -coeff
END IF
ELSE
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
END IF
#elif defined(NDSU3LIB_CACHE)
absMLambda2p = ABS(MLambda2p)
absMp = ABS(Mp)
IF (lambda < 256 .AND. mu < 256 .AND. p < 256 .AND. q < 256 .AND. absMLambda2p < 256 &
.AND. M < 256 .AND. L < 256 .AND. absMp < 256) THEN
key = IOR(ISHFT(INT(IAND(lambda, 255), 8), 56), &
IOR(ISHFT(INT(IAND(mu, 255), 8), 48), &
IOR(ISHFT(INT(IAND(p, 255), 8), 40), &
IOR(ISHFT(INT(IAND(q, 255), 8), 32), &
IOR(ISHFT(INT(IAND(absMLambda2p, 255), 8), 24), &
IOR(ISHFT(INT(IAND(M, 255), 8), 16), &
IOR(ISHFT(INT(IAND(L, 255), 8), 8), &
INT(IAND(absMp, 255), 8))))))))
point2 => cache%Get(key)
IF (ASSOCIATED(point2)) THEN
coeff = point2
ELSE
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, &
absMLambda2p, M, L, absMp, p, q, coeff)
CALL cache%Set(key, coeff)
END IF
IF (MLambda2p < 0 .AND. Mp >= 0) THEN
IF (BTEST((Lambda2p + Mp)/2, 0)) coeff = -coeff
ELSE IF (MLambda2p >= 0 .AND. Mp < 0) THEN
! IF (BTEST(q + (Lambda2p + MLambda2p)/2 - aux + L + M, 0)) coeff = -coeff
IF (BTEST(q + (Lambda2p + MLambda2p)/2 + L + M, 0)) coeff = -coeff
ELSE IF (MLambda2p < 0 .AND. Mp < 0) THEN
! IF (BTEST(q + Lambda2p - aux + L + M + (MLambda2p - Mp)/2, 0)) coeff = -coeff
IF (BTEST(q + Lambda2p + L + M + (MLambda2p - Mp)/2, 0)) coeff = -coeff
END IF
ELSE
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
END IF
#else
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
#endif
IF (I /= J .AND. BTEST((lambda + M)/2, 0)) coeff = -coeff
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS DEFAULT ! CLASS IS (mp_real)
#endif
#if (defined(NDSU3LIB_CACHE) && (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU)))
absMLambda2p = ABS(MLambda2p)
absMp = ABS(Mp)
IF (lambda < 256 .AND. mu < 256 .AND. p < 256 .AND. q < 256 .AND. absMLambda2p < 256 &
.AND. M < 256 .AND. L < 256 .AND. absMp < 256) THEN
key = IOR(ISHFT(INT(IAND(lambda, 255), 8), 56), &
IOR(ISHFT(INT(IAND(mu, 255), 8), 48), &
IOR(ISHFT(INT(IAND(p, 255), 8), 40), &
IOR(ISHFT(INT(IAND(q, 255), 8), 32), &
IOR(ISHFT(INT(IAND(absMLambda2p, 255), 8), 24), &
IOR(ISHFT(INT(IAND(M, 255), 8), 16), &
IOR(ISHFT(INT(IAND(L, 255), 8), 8), &
INT(IAND(absMp, 255), 8))))))))
point3 => cache_mp%Get(key)
IF (ASSOCIATED(point3)) THEN
coeff = point3
ELSE
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, &
absMLambda2p, M, L, absMp, p, q, coeff)
CALL cache_mp%Set(key, coeff)
END IF
point => coeff
IF (MLambda2p < 0 .AND. Mp >= 0) THEN
IF (BTEST((Lambda2p + Mp)/2, 0)) point = -point
ELSE IF (MLambda2p >= 0 .AND. Mp < 0) THEN
! IF (BTEST(q + (Lambda2p + MLambda2p)/2 - aux + L + M, 0)) coeff = -coeff
IF (BTEST(q + (Lambda2p + MLambda2p)/2 + L + M, 0)) point = -point
ELSE IF (MLambda2p < 0 .AND. Mp < 0) THEN
! IF (BTEST(q + Lambda2p - aux + L + M + (MLambda2p - Mp)/2, 0))coeff = -coeff
IF (BTEST(q + Lambda2p + L + M + (MLambda2p - Mp)/2, 0)) point = -point
END IF
ELSE
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
point => coeff
END IF
#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CALL calculate_transformation_coef_internal(lambda, mu, epsilon, Lambda2p, MLambda2p, M, L, Mp, p, q, coeff)
point => coeff
#endif
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
IF (I /= J .AND. BTEST((lambda + M)/2, 0)) point = -point
END SELECT
#endif
END SUBROUTINE calculate_transformation_coef
SUBROUTINE calculate_orthonormalization_matrix(I, J, irrep, L, kappamax, matrix)
!---------------------------------------------------------------------------------------------------
!! Calculate bottom triangle, including diagonal, of orthonormalization matrix for SU(3)-SO(3) basis
! for given lambda,mu,L using Eq.(..) in [1] or equaivalently Eq.(6a),(6b),(6c),(27) in [2]
!
! References: [1] J.Herko et al. in preparation
! [2] J.P.Draayer, Y.Akiyama, J.Math.Phys., Vol.14, No.12 (1973) 1904
!
! Input arguments: I, J, irrep, L, kappamax
! Output argument: matrix
!
! (I,J)=(1,1) => E=HW, (I,J)=(1,0) => E=HW', (I,J)=(0,0) => E=LW, (I,J)=(0,1) => E=LW' in [2]
! irrep%lambda is lambda, irrep%mu is mu
! kappamax is number of occurences of L in SU(3) irrep (lambda,mu)
! matrix(i,j) is element O_ij of orthonormalization matrix
!
! Note: There is typo in Eq.(6b) in [2]: square root should not be there.
!---------------------------------------------------------------------------------------------------
!#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
! USE mpmodule
!#endif
IMPLICIT NONE
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS(*), TARGET, DIMENSION(:, :), INTENT(OUT) :: matrix
!! Orthonormalization matrix in arbitrary precision.
!! Size is kappamax x kappamax.
TYPE(mp_real), POINTER, DIMENSION(:, :) :: point
#else
REAL(KIND=8), DIMENSION(:, :), INTENT(OUT) :: matrix
!! Orthonormalization matrix in double precision.
!! Size is kappamax x kappamax.
#endif
TYPE(su3irrep), INTENT(IN) :: irrep
!! SU(3) irrep
INTEGER, INTENT(IN) :: I
!! Parameter determining from which extremal-weight SU(3)-SU(2)xU(1) basis state the SU(3)-SO(3) basis state is projected.
!! Should be 1 if lambda < mu, otherwise it shuold be 0
INTEGER, INTENT(IN) :: J
!! Parameter determining from which extremal-weight SU(3)-SU(2)xU(1) basis state the SU(3)-SO(3) basis state is projected.
!! Should be 0 if lambda < mu, otherwise it shuold be 1
INTEGER, INTENT(IN) :: L
!! SO(3) irrep label (angular momentum) of SU(3)-SO(3) basis states
INTEGER, INTENT(IN) :: kappamax
!! Number of occurences of L in SU(3) irrep
INTEGER :: ii, jj, k, epsilon, Ki, Kj, Kminm2, Lambda2, MLambda2
REAL(KIND=8) :: sum, coeff
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
TYPE(mp_real) :: summp, coeffmp
#endif
!INTERFACE
! SUBROUTINE calculate_transformation_coef(I, J, irrep, epsilonx, Lambda2p, MLambda2px, M, L, Mp, coeff)
! IMPLICIT NONE
!#if (defined(NDSU3LIB_DBL) || defined(NDSU3LIB_QUAD) || defined(NDSU3LIB_QUAD_GNU))
! REAL(KIND=8), INTENT(OUT) :: coeff
!#elif (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
! CLASS(*), INTENT(OUT) :: coeff
!#endif
! TYPE(su3irrep), INTENT(IN) :: irrep
! INTEGER, INTENT(IN) :: I, J, epsilonx, Lambda2p, MLambda2px, M, L, Mp
! END SUBROUTINE calculate_transformation_coef
!END INTERFACE
IF (I == 1) THEN ! E=HW or HW'
epsilon = -irrep%lambda - 2*irrep%mu ! HW epsilon
Kminm2 = Kmin(irrep%lambda, irrep%mu, L) - 2 ! Kmin(lambda,mu,L) is lowest K
Lambda2 = irrep%lambda ! Lambda2 is 2*Lambda
MLambda2 = irrep%lambda ! MLambda2 is 2*M_Lambda
ELSE ! E=LW or LW'
epsilon = 2*irrep%lambda + irrep%mu ! LW epsilon
Kminm2 = Kmin(irrep%mu, irrep%lambda, L) - 2 ! Kmin(mu,lambda,L) is lowest K
Lambda2 = irrep%mu ! Lambda2 is 2*Lambda
MLambda2 = -irrep%mu ! MLambda2 is 2*M_Lambda
END IF
IF (I /= J) MLambda2 = -MLambda2
Ki = Kminm2
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
SELECT TYPE (matrix)
TYPE IS (REAL(KIND=8))
#endif
! First, upper triangle is calculated including diagonal.
DO ii = 1, kappamax ! loop over columns
Ki = Ki + 2 ! Ki is K_i in Eq.(...)
Kj = Kminm2
DO jj = 1, ii - 1 ! loop over rows
Kj = Kj + 2 ! Kj is K_j in Eq.(...)
sum = 0.D0
DO k = 1, jj - 1
sum = sum + matrix(k, jj)*matrix(k, ii) ! sum is the sum in Eq.(...)
END DO
CALL calculate_transformation_coef(I, J, irrep, epsilon, Lambda2, MLambda2, Ki, L, Kj, coeff)
matrix(jj, ii) = matrix(jj, jj)*(coeff - sum) ! Eq.(...)
END DO
sum = 0.D0
DO jj = 1, ii - 1
sum = sum + matrix(jj, ii)*matrix(jj, ii) ! sum is the sum in Eq.(...)
END DO
CALL calculate_transformation_coef(I, J, irrep, epsilon, Lambda2, MLambda2, Ki, L, Ki, coeff)
matrix(ii, ii) = 1.D0/DSQRT(coeff - sum) ! Eq.(...)
END DO
! Now, bottom triangle is calculated.
DO jj = 1, kappamax - 1 ! loop over columns
DO ii = jj + 1, kappamax ! loop over rows
sum = 0.D0
DO k = jj, ii - 1
sum = sum + matrix(k, jj)*matrix(k, ii) ! sum is the sum in Eq.(...)
END DO
matrix(ii, jj) = -matrix(ii, ii)*sum ! Eq.(...)
END DO
END DO
#if (defined(NDSU3LIB_MP) || defined(NDSU3LIB_MP_GNU))
CLASS DEFAULT ! CLASS IS (mp_real)
point => matrix
! First, upper triangle is calculated including diagonal.
DO ii = 1, kappamax ! loop over columns
Ki = Ki + 2 ! Ki is K_i in Eq.(...)
Kj = Kminm2
DO jj = 1, ii - 1 ! loop over rows
Kj = Kj + 2 ! Kj is K_j in Eq.(...)
summp = mpreal(0.D0, nwds)
DO k = 1, jj - 1
summp = summp + point(k, jj)*point(k, ii) ! summp=summp+matrix(k,jj)*matrix(k,ii) ! sum is the sum in Eq.(...)
END DO
CALL calculate_transformation_coef(I, J, irrep, epsilon, Lambda2, MLambda2, Ki, L, Kj, coeffmp)
point(jj, ii) = point(jj, jj)*(coeffmp - summp) ! matrix(jj,ii)=matrix(jj,jj)*(coeffmp-summp) ! Eq.(...)
END DO
summp = mpreal(0.D0, nwds)
DO jj = 1, ii - 1
summp = summp + point(jj, ii)*point(jj, ii) ! summp=summp+matrix(jj,ii)*matrix(jj,ii) ! sum is the sum in Eq.(...)
END DO
CALL calculate_transformation_coef(I, J, irrep, epsilon, Lambda2, MLambda2, Ki, L, Ki, coeffmp)
point(ii, ii) = 1.D0/SQRT(coeffmp - summp) ! matrix(ii,ii)=1.D0/SQRT(coeffmp-summp) ! Eq.(...)
END DO
! Now, bottom triangle is calculated.
DO jj = 1, kappamax - 1 ! loop over columns
DO ii = jj + 1, kappamax ! loop over rows
summp = mpreal(0.D0, nwds)
DO k = jj, ii - 1
summp = summp + point(k, jj)*point(k, ii) ! summp=summp+matrix(k,jj)*matrix(k,ii) ! sum is the sum in Eq.(...)
END DO