Skip to content

Commit 0982a44

Browse files
committed
fix toeplitz issues by just using existing code and pasting it into the full array
1 parent c776d2f commit 0982a44

3 files changed

Lines changed: 21 additions & 23 deletions

File tree

pspy/mcm_fortran/mcm_compute.mod

1.74 KB
Binary file not shown.

pspy/mcm_fortran/mcm_fortran.f90

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ subroutine calc_coupling_block_spin0(wcl, l_exact, l_band, l_toeplitz, coupling)
414414
nlmax = size(coupling,1) - 1
415415

416416
!$omp parallel do private(l2, l1) schedule(dynamic)
417-
do l1 = 0, min(nlmax, l_exact)
417+
do l1 = 2, min(nlmax, l_exact)
418418
do l2 = l1, nlmax
419-
call calc_coupling_elem_spin0(wcl, l1, l2, coupling(l1+1, l2+1))
419+
call calc_coupling_elem_spin0(wcl, l1, l2, coupling(l1-1, l2-1))
420420
end do
421421
end do
422422

@@ -430,14 +430,14 @@ subroutine calc_coupling_block_spin0(wcl, l_exact, l_band, l_toeplitz, coupling)
430430
end if
431431

432432
do l2 = l1, lmax_band
433-
call calc_coupling_elem_spin0(wcl, l1, l2, coupling(l1+1, l2+1))
433+
call calc_coupling_elem_spin0(wcl, l1, l2, coupling(l1-1, l2-1))
434434
end do
435435
end do
436436

437437
if (l_toeplitz .lt. nlmax) then
438438
!$omp parallel do
439439
do l1 = l_toeplitz + 1, nlmax
440-
call calc_coupling_elem_spin0(wcl, l1, l1, coupling(l1+1, l1+1))
440+
call calc_coupling_elem_spin0(wcl, l1, l1, coupling(l1-1, l1-1))
441441
end do
442442
end if
443443
end if
@@ -457,11 +457,9 @@ subroutine calc_coupling_block_spin02(wcl, l_exact, l_band, l_toeplitz, coupling
457457
!$omp parallel do private(l2, l1) schedule(dynamic)
458458
do l1 = 2, min(nlmax, l_exact)
459459
do l2 = l1, nlmax
460-
call calc_coupling_elem_spin02(wcl, l1, l2, coupling(l1+1, l2+1))
460+
call calc_coupling_elem_spin02(wcl, l1, l2, coupling(l1-1, l2-1))
461461
end do
462462
end do
463-
coupling(1,1) = 1
464-
coupling(2,2) = 1
465463

466464
if (l_exact .lt. nlmax) then
467465
!$omp parallel do private(l2, l1, lmax_band) schedule(dynamic)
@@ -473,14 +471,14 @@ subroutine calc_coupling_block_spin02(wcl, l_exact, l_band, l_toeplitz, coupling
473471
end if
474472

475473
do l2 = l1, lmax_band
476-
call calc_coupling_elem_spin02(wcl, l1, l2, coupling(l1+1, l2+1))
474+
call calc_coupling_elem_spin02(wcl, l1, l2, coupling(l1-1, l2-1))
477475
end do
478476
end do
479477

480478
if (l_toeplitz .lt. nlmax) then
481479
!$omp parallel do
482480
do l1 = l_toeplitz + 1, nlmax
483-
call calc_coupling_elem_spin02(wcl, l1, l1, coupling(l1+1, l1+1))
481+
call calc_coupling_elem_spin02(wcl, l1, l1, coupling(l1-1, l1-1))
484482
end do
485483
end if
486484
end if
@@ -500,11 +498,9 @@ subroutine calc_coupling_block_spin2_pp(wcl, l_exact, l_band, l_toeplitz, coupli
500498
!$omp parallel do private(l2, l1) schedule(dynamic)
501499
do l1 = 2, min(nlmax, l_exact)
502500
do l2 = l1, nlmax
503-
call calc_coupling_elem_spin2_pp(wcl, l1, l2, coupling(l1+1, l2+1))
501+
call calc_coupling_elem_spin2_pp(wcl, l1, l2, coupling(l1-1, l2-1))
504502
end do
505503
end do
506-
coupling(1,1) = 1
507-
coupling(2,2) = 1
508504

509505
if (l_exact .lt. nlmax) then
510506
!$omp parallel do private(l2, l1, lmax_band) schedule(dynamic)
@@ -516,14 +512,14 @@ subroutine calc_coupling_block_spin2_pp(wcl, l_exact, l_band, l_toeplitz, coupli
516512
end if
517513

518514
do l2 = l1, lmax_band
519-
call calc_coupling_elem_spin2_pp(wcl, l1, l2, coupling(l1+1, l2+1))
515+
call calc_coupling_elem_spin2_pp(wcl, l1, l2, coupling(l1-1, l2-1))
520516
end do
521517
end do
522518

523519
if (l_toeplitz .lt. nlmax) then
524520
!$omp parallel do
525521
do l1 = l_toeplitz + 1, nlmax
526-
call calc_coupling_elem_spin2_pp(wcl, l1, l1, coupling(l1+1, l1+1))
522+
call calc_coupling_elem_spin2_pp(wcl, l1, l1, coupling(l1-1, l1-1))
527523
end do
528524
end if
529525
end if
@@ -543,11 +539,9 @@ subroutine calc_coupling_block_spin2_mm(wcl, l_exact, l_band, l_toeplitz, coupli
543539
!$omp parallel do private(l2, l1) schedule(dynamic)
544540
do l1 = 2, min(nlmax, l_exact)
545541
do l2 = l1, nlmax
546-
call calc_coupling_elem_spin2_mm(wcl, l1, l2, coupling(l1+1, l2+1))
542+
call calc_coupling_elem_spin2_mm(wcl, l1, l2, coupling(l1-1, l2-1))
547543
end do
548544
end do
549-
coupling(1,1) = 1
550-
coupling(2,2) = 1
551545

552546
if (l_exact .lt. nlmax) then
553547
!$omp parallel do private(l2, l1, lmax_band) schedule(dynamic)
@@ -559,14 +553,14 @@ subroutine calc_coupling_block_spin2_mm(wcl, l_exact, l_band, l_toeplitz, coupli
559553
end if
560554

561555
do l2 = l1, lmax_band
562-
call calc_coupling_elem_spin2_mm(wcl, l1, l2, coupling(l1+1, l2+1))
556+
call calc_coupling_elem_spin2_mm(wcl, l1, l2, coupling(l1-1, l2-1))
563557
end do
564558
end do
565559

566560
if (l_toeplitz .lt. nlmax) then
567561
!$omp parallel do
568562
do l1 = l_toeplitz + 1, nlmax
569-
call calc_coupling_elem_spin2_mm(wcl, l1, l1, coupling(l1+1, l1+1))
563+
call calc_coupling_elem_spin2_mm(wcl, l1, l1, coupling(l1-1, l1-1))
570564
end do
571565
end if
572566
end if

pspy/so_mcm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,7 @@ def coupling_block(
522522
l = np.arange(len(wcl))
523523
wcl *= (2 * l + 1)
524524

525-
526-
mcm = np.zeros((lmax+1, lmax+1))
525+
mcm = np.zeros((lmax, lmax))
527526

528527
if l_toep is None: l_toep = lmax
529528
if l_band is None: l_band = lmax
@@ -542,8 +541,13 @@ def coupling_block(
542541
mcm = format_toepliz_fortran2(mcm, l_toep, l_exact, lmax)
543542

544543
mcm_fortran.fill_upper(mcm.T)
544+
545+
mcm_full = np.zeros((lmax+1, lmax+1))
546+
mcm_full[2:, 2:] = mcm[:-1,:-1]
547+
mcm_full[0,0] = 1.0
548+
mcm_full[1,1] = 1.0
545549

546550
if legacy_ell_range:
547-
return mcm[2:-1, 2:-1]
548-
else:
549551
return mcm
552+
else:
553+
return mcm_full

0 commit comments

Comments
 (0)