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.

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

Utility function to efficiently calculate x^T covinv x

  • covinv – symmetric inverse covariance matrix
  • x – vector
Returns:, but parallelized and using symmetry

camb.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

  • P – power spectrum of mask
  • lmax – lmax for the matrix

coupling matrix (square but not symmetric)

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

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

  • l2 – L_2
  • l3 – L_3
  • m2 – M_2
  • m3 – M_3

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

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

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

  • 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

coupling matrix or array of matrices