Skip to content

Last component of calc_mcm_spin0and2_pure always seems to be (practically) zero #97

Open

Description

@mreineck

When playing with the routine calc_mcm_spin0and2_pure I noticed something interesting: no matter which power spectra are fed into the function, the fifth output matrix always seems to contain extremely small values. This can be verified with the following script:

import numpy as np

from pspy.mcm_fortran.mcm_fortran import mcm_compute as mcm_fortran

lmax=100
mcm = np.zeros((5, lmax+1, lmax+1))
spec = np.random.normal(size=(4, 2*lmax+1))
mcm_fortran.calc_mcm_spin0and2_pure(spec[0], spec[1], spec[2], spec[3], mcm.T)
for i in range(5):
    print (np.max(np.abs(mcm[i,:,:])))

Is this due to a bug in the function, or is there actually some kind of symmetry in the Wigner 3j symbols which makes this component vanish by construction? If the latter, it might be good to simply skip its calculation, saving some CPU time and memory.

Activity

  1. zatkins2 commented on Jan 9, 2026

    @zatkins2
    Collaborator

    I'm afraid I don't really know much about how the "pure" matrices are expected to behave. I also don't think we have used these pure methods yet in PSpipe really (though, we may in the future, if/when we use PSpipe on SAT data). I agree I would be surprised if the matrix is basically 0.

    Perhaps @damonge would know for sure if this sounds like a bug?

  2. mreineck commented on Jul 1, 2026

    @mreineck
    Author

    Just for future reference: the script has changed a little for the most recent pspy versions, but the result has not:

    import numpy as np
    
    import pspy
    func = pspy.so_mcm.mcm_fortran.calc_mcm_spin0and2_pure
    
    lmax=100
    mcm = np.zeros((5, lmax+1, lmax+1))
    spec = np.random.normal(size=(4, 2*lmax+1))
    func(spec[0], spec[1], spec[2], spec[3], mcm.T)
    for i in range(5):
        print (np.max(np.abs(mcm[i,:,:])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions