28#include <gsl/gsl_integration.h>
29#include <lal/cs_lambda_cosmo.h>
32#define UNUSED __attribute__ ((unused))
42 double one_plus_z_3 = one_plus_z * one_plus_z * one_plus_z;
43 double one_plus_z_4 = one_plus_z * one_plus_z_3;
46 ans = sqrt( Omega_m * one_plus_z_3 + Omega_r * one_plus_z_4 + Omega_L );
80 gsl_integration_workspace *
w = gsl_integration_workspace_alloc(
WORKSZ);
87 cosmofns.
z = calloc(
n,
sizeof( *cosmofns.
z ) );
88 cosmofns.
phit = calloc(
n,
sizeof( *cosmofns.
phit ) );
89 cosmofns.
phiA = calloc(
n,
sizeof( *cosmofns.
phiA ) );
90 cosmofns.
phiV = calloc(
n,
sizeof( *cosmofns.
phiV ) );
92 F1.params = F2.params = NULL;
96 for (
i = 0;
i <
n; ++
i )
103 cosmofns.
z[
i] = zmin * exp(
i * dlnz );
105 gsl_integration_qag (&F1, 0, cosmofns.
z[
i], 0,
EPS,
WORKSZ, 1,
w, cosmofns.
phiA+
i, &err );
106 gsl_integration_qag (&F2, 0, 1.0/cosmofns.
z[
i], 0,
EPS,
WORKSZ, 1,
w, cosmofns.
phit+
i, &err );
108 one_plus_z = 1.0 + cosmofns.
z[
i];
109 one_plus_z_3 = one_plus_z * one_plus_z * one_plus_z;
111 cosmofns.
phiV[
i] = 4.0 * M_PI * cosmofns.
phiA[
i] * cosmofns.
phiA[
i] / ( one_plus_z_3 * h );
114 gsl_integration_workspace_free(
w );
121 gsl_integration_workspace *
w = gsl_integration_workspace_alloc(
WORKSZ);
125 cosmofns.
zmin = z[0];
128 cosmofns.
z = calloc(
n,
sizeof( *cosmofns.
z ) );
129 cosmofns.
phit = calloc(
n,
sizeof( *cosmofns.
phit ) );
130 cosmofns.
phiA = calloc(
n,
sizeof( *cosmofns.
phiA ) );
131 cosmofns.
phiV = calloc(
n,
sizeof( *cosmofns.
phiV ) );
133 F1.params = F2.params = NULL;
137 for (
i = 0;
i <
n; ++
i )
144 cosmofns.
z[
i] = z[
i];
146 gsl_integration_qag (&F1, 0, cosmofns.
z[
i], 0,
EPS,
WORKSZ, 1,
w, cosmofns.
phiA+
i, &err );
147 gsl_integration_qag (&F2, 0, 1.0/cosmofns.
z[
i], 0,
EPS,
WORKSZ, 1,
w, cosmofns.
phit+
i, &err );
149 one_plus_z = 1.0 + cosmofns.
z[
i];
150 one_plus_z_3 = one_plus_z * one_plus_z * one_plus_z;
152 cosmofns.
phiV[
i] = 4.0 * M_PI * cosmofns.
phiA[
i] * cosmofns.
phiA[
i] / ( one_plus_z_3 * h );
155 gsl_integration_workspace_free(
w );
static double cs_lambda_phit_integrand(double y, void UNUSED *p)
static double cs_lambda_hubble(double one_plus_z)
void XLALCSCosmoFunctionsFree(cs_cosmo_functions_t cosmofns)
cs_cosmo_functions_t XLALCSCosmoFunctionsAlloc(double zmin, double dlnz, size_t n)
static double cs_lambda_phiA_integrand(double z, void UNUSED *p)
cs_cosmo_functions_t XLALCSCosmoFunctions(double *z, size_t n)