Maths utils

This module contains some fast utility functions that are useful in the same contexts as camb. They are entirely independent of the main camb code.

isitgr.mathutils.chi_squared(covinv, x)[source]

Utility function to efficiently calculate x^T covinv x

Parameters:
  • covinv – symmetric inverse covariance matrix
  • x – vector
Returns:

covinv.dot(x).dot(x), but parallelized and using symmetry

isitgr.mathutils.scalar_coupling_matrix(P, lmax)[source]

Get Pseudo-Cl coupling matrix from power spectrum of mask. Uses multiple threads. See Eq A31 of astro-ph/0105302

Parameters:
  • P – power spectrum of mask
  • lmax – lmax for the matrix
Returns:

coupling matrix (square but not symmetric)

isitgr.mathutils.threej(l2, l3, m2, m3)[source]

Convenience wrapper around standard 3j function, returning array for all allowed l1 values

Parameters:
  • l2 – L_2
  • l3 – L_3
  • m2 – M_2
  • m3 – M_3
Returns:

array of 3j from max(abs(l2-l3),abs(m2+m3)) .. l2+l3

isitgr.mathutils.threej_coupling(W, lmax, pol=False)[source]

Calculate symmetric coupling matrix for given weights W (i.e. the mask power power spectrum).

Parameters:
  • W – 1d array of Weights for each L, or array of weights (zero based)
  • lmax – lmax for the output matrix (assumed symmetric, though not in principle)
  • pol – if pol, produce TT, TE, EE, EB couplings for three input mask weights
Returns:

coupling matrix or array of matrices