Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
1ba5885
Add function set_cosmological_parameters_to_Planck_15_TT_TE_EE_lowP_D…
Feb 4, 2020
dc012b7
added theta_star options to prior parameters
timeifler Jun 23, 2020
18c8808
fix integer divided by integer issue in xipm_TATT
xfangcosmo Jun 30, 2020
7c72e4f
merge
xfangcosmo Jun 30, 2020
a081856
include reduced shear in shear, ggl
elikrause Jul 2, 2020
4bd111d
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
elikrause Jul 2, 2020
10d1548
switch off reduced shear
elikrause Jul 2, 2020
8312a64
better precision due to ell prefactors
xfangcosmo Jul 7, 2020
a838b27
merge
xfangcosmo Jul 7, 2020
149b0d3
add cross survey cov
xfangcosmo Jul 9, 2020
fee1f92
add real2D fullsky datav for CMBlensing
xfangcosmo Jul 12, 2020
e760a58
modified cosmo3D.c to work with CLASS v2.9; compile with -DCLASS_V29
elikrause Jul 16, 2020
387442d
updated source clustering weight functions for 3D source clustering
elikrause Jul 16, 2020
701c7fd
merge
elikrause Jul 16, 2020
6369bce
simplified routine for 6x2pt
xfangcosmo Jul 26, 2020
606f5d3
merge
xfangcosmo Jul 26, 2020
6778d54
temporary cosmo2D_real.c changes
elikrause Aug 3, 2020
86235cf
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
elikrause Aug 3, 2020
ecd7074
modified struct.c, add baryon PCs amplitude Q1 Q2 Q3
Aug 14, 2020
c847f91
cmb x ia fix
xfangcosmo Sep 3, 2020
f7f9000
merge
xfangcosmo Sep 3, 2020
9b7a71e
add aux function to print ztrue distribution for each tomo bin
Sep 14, 2020
0c7c554
test
Sep 14, 2020
c0a2590
add baryon feature
Oct 24, 2020
1d6153d
removed assert command, because it stops chains, added print
timeifler Oct 24, 2020
331ec85
reduced shear hacks
elikrause Oct 26, 2020
7f23c1e
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
elikrause Oct 26, 2020
67ca911
turn off reduced shear
elikrause Oct 26, 2020
d621a90
incorporate TATT integration range - consistent with cosmosis after c…
xfangcosmo Oct 27, 2020
231a7e1
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
xfangcosmo Oct 27, 2020
efa0e4b
separated y3 routines from HOD.c and cosmo2D_fourier.c
elikrause Oct 29, 2020
8c7c285
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
elikrause Oct 29, 2020
4e892b0
N_cdm = 3 for massive neutrino modeing
elikrause Nov 7, 2020
2085d6f
silenced outputs
elikrause Nov 7, 2020
a417c45
silenced outputs
elikrause Nov 7, 2020
84f2d94
add cng to covparam, consistent with CosmoCov
xfangcosmo Feb 20, 2021
a5669f2
fix mix cov bug; add fourier band averaged 6x2pt cov
xfangcosmo Feb 21, 2021
a4402ed
fix a typo in binned cov-simple
xfangcosmo Feb 22, 2021
4e0f57a
add cmb fsky in struct
xfangcosmo Feb 22, 2021
4fb3a44
add cmb fsky in struct
xfangcosmo Feb 22, 2021
464e04c
Update structs.c
chto Mar 26, 2021
29d6fb9
Merge pull request #13 from CosmoLike/Youngsoo's-Y-transform
elikrause Mar 26, 2021
682cb98
avoid memory leak in nonlimber fft
xfangcosmo Apr 29, 2021
f940138
fix a bug in NLA ggl mag - thanks to V. Miranda; not affect DES
xfangcosmo May 12, 2021
a612194
add MGSigma into CMB lensing efficiency func
xfangcosmo May 19, 2021
0e3c2a8
merge outlier nz models and related changes
xfangcosmo Sep 8, 2021
f904cf7
pull updates
Oct 5, 2021
370f613
add Cl func setup - not implemented yet
xfangcosmo Oct 8, 2021
960dfdd
y-related Cl nointerp funcs added
xfangcosmo Oct 8, 2021
115dc6d
add func placeholders
xfangcosmo Oct 8, 2021
2c91a45
Pull updates and add baryon Q123 components to theory/struct.c
Oct 12, 2021
0919225
There's conflict in cosmolike_core, I have to build another branch fo…
Oct 13, 2021
eebedc6
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
Oct 13, 2021
bdf2216
leave out unused fK param in func W_y() declaration
Oct 14, 2021
908a898
correct minor bugs, like extra, wrong variable name, extra argument i…
Oct 14, 2021
c556c3a
an extra pf_histo(0.5,NULL) in pf_photoz() causes an error while read…
Oct 17, 2021
3e2ca5a
fix CMBxLSS_fourier issues introduced by adding Compton-y; merging co…
xfangcosmo Oct 24, 2021
3b99eb4
fix merging issues
xfangcosmo Oct 24, 2021
5e36327
add comments
xfangcosmo Oct 24, 2021
703952e
add comments to specify the usages of cov src files
xfangcosmo Oct 24, 2021
a1f8b95
do some debug prints, but are commented out after debug
Oct 24, 2021
e07470a
Pull updated from Xiao: cleaning the code
Oct 25, 2021
66999fd
improve fftlog and fastpt accuracy by applying asymptotic forms for g…
xfangcosmo Oct 26, 2021
8812c84
turn off debug
xfangcosmo Oct 26, 2021
7f14e97
fix naming
xfangcosmo Oct 26, 2021
ecf349b
add simplified fourier nobin cov module
xfangcosmo Nov 18, 2021
385aec9
cov Gaussian simplified
xfangcosmo Nov 19, 2021
54b3d3f
clean up a bit
xfangcosmo Nov 19, 2021
b0c161f
unify NG covariance fourier
xfangcosmo Nov 22, 2021
bd12a69
NG cov tabulate functions all simplified
xfangcosmo Nov 22, 2021
33e2746
add y noise read-in routine
xfangcosmo Nov 22, 2021
57bfeff
fix compiling issues
xfangcosmo Nov 23, 2021
bba20b9
debug for 6x2pt fourier cov
xfangcosmo Nov 26, 2021
dbf703b
fix a bug in ng cov
xfangcosmo Nov 27, 2021
ea2bae5
add new halo file for gas profile and y
xfangcosmo Nov 30, 2021
66f66c3
change the default CMB beam size to 7arcmin
Dec 8, 2021
9bd75e4
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
Dec 8, 2021
ed702f3
test run for 6x2pt
xfangcosmo Dec 14, 2021
3a4901b
Add CMB Gaussian Beam smoothing. Smothing only applied to gk and sk 2…
Dec 15, 2021
3a8ef8d
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
Dec 15, 2021
6dfbf3b
update the cmb beam in both data vectors (gk, sk) and covariances
Dec 15, 2021
56026d3
pull changes: Gaussian beam smoothing of gk and ks, in both data vect…
Dec 15, 2021
aef8244
debugging gaussian beam
Jan 5, 2022
08047a8
add a flag for turn on/off Gaussian beam smoothing
Jan 10, 2022
bb6e8ff
update GaussianBeam for debugging
Jan 12, 2022
58d7b51
y part DV, still need some work for high-z
xfangcosmo Jan 17, 2022
a2057e5
Merge branch 'master' of github.com:CosmoLike/cosmolike_core
xfangcosmo Jan 17, 2022
de926dd
extensive tests and optimization of halo-related routines, datav; fix…
xfangcosmo Jan 23, 2022
e2c4e38
some test on fftlog - failed
xfangcosmo Jan 30, 2022
6abee60
add smooth transiting function at the edges of Gaussian beam kernel
Jan 30, 2022
d085ddd
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
Jan 30, 2022
fa86d82
fix cov bug in y
xfangcosmo Feb 4, 2022
12b444a
Merge branch 'master' of github.com:CosmoLike/cosmolike_core
xfangcosmo Feb 4, 2022
1400b40
fix sy cov bug
xfangcosmo Feb 5, 2022
91e6bdb
introduce linear angular binning in struct
xfangcosmo Feb 6, 2022
87b86b4
separate halo new routines
xfangcosmo Feb 7, 2022
69e25bd
add macro to allow slow version of halo model for matter
xfangcosmo Feb 13, 2022
a600977
fft KS and more optimization
xfangcosmo Feb 21, 2022
d5bc914
add like.lmin_kappacmb and some debug printfs.
JiachuanXu Mar 9, 2022
de923b9
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
JiachuanXu Mar 9, 2022
0818725
faster gsl integration, growfac optimized
xfangcosmo Mar 28, 2022
9e77cc5
Merge branch 'master' of github.com:CosmoLike/cosmolike_core
xfangcosmo Mar 28, 2022
3fb753d
Ntable.N_a back to 100
xfangcosmo Mar 28, 2022
0770d1f
IA NLA-z for sy
xfangcosmo Mar 29, 2022
992a574
add separate set of gas parameters when testing self calibration
xfangcosmo Mar 29, 2022
b79b63f
implement recompute for halo params and restruct gas params
xfangcosmo Mar 30, 2022
21f1333
add y-related probes in covpar struct
xfangcosmo Mar 30, 2022
e54529d
modify struct and priors for gas params
xfangcosmo Apr 1, 2022
8f62405
reduce niter for low precision gsl integration
xfangcosmo Apr 1, 2022
8d1a449
increase c_max in tabulation for Duffy c(M) relation
xfangcosmo Apr 1, 2022
6b14fc7
add like.lmin_y in struct
xfangcosmo Apr 1, 2022
53ccd30
add CMB lensing band power
JiachuanXu Apr 14, 2022
1a718a5
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
JiachuanXu Apr 14, 2022
13fb0fb
fix bugs related to u_y_ejc units
xfangcosmo Apr 26, 2022
4238788
Merge branch 'master' of https://github.com/CosmoLike/cosmolike_core
JiachuanXu May 18, 2022
dbfe4d1
add radiation components in and
JiachuanXu May 18, 2022
db43d1a
modify y noise file format and readin routine
xfangcosmo Jan 9, 2023
722437e
run with weight turned off
xfangcosmo Feb 23, 2023
80aff05
fix the NG integration range
xfangcosmo Feb 24, 2023
99895c1
add Ludlow16fit c-M relation
xfangcosmo Mar 4, 2023
0eef32d
add several HMF to halo_fast for testing
xfangcosmo Mar 30, 2023
2ff48dd
add halfcalib for halofast
xfangcosmo Apr 2, 2023
e7cf37e
fix halo_fast nocalib setting
xfangcosmo Apr 17, 2023
9be5895
fix halo_fast halfcalib setting
xfangcosmo Apr 19, 2023
a807594
fix halo_fast halfcalib
xfangcosmo Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 59 additions & 47 deletions cfastpt/utils_complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,59 +65,71 @@ Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2

void g_m_vals(double mu, double q_real, double *q_imag, double complex *gm, long N){
long i;
for(i=0; i<N; i++) {
gm[i] = cexp(lngamma_lanczos((mu+1.+q_real+I*q_imag[i])/2.) - lngamma_lanczos((mu+1.-q_real-I*q_imag[i])/2.) );
// if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
}
}

void gamma_ratios(double l, double nu, double *eta, double complex *gl, long N) {
/* z = nu + I*eta
Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2 - I*eta/2 ) ) */
long i;
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
// gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
gl[i] = cexp(lngamma_lanczos((l+z)/2.) - lngamma_lanczos((3.+l-z)/2.) );
// if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
}
}
double complex plus;
double complex minus;

void g_l(double l, double nu, double *eta, double complex *gl, long N) {
/* z = nu + I*eta
Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2 - I*eta/2 ) ) */
long i;
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
// gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
gl[i] = cexp(z*log(2.) + lngamma_lanczos((l+z)/2.) - lngamma_lanczos((3.+l-z)/2.) );
plus = (mu+1.+q_real+I*q_imag[i])/2.;
minus= (mu+1.-q_real-I*q_imag[i])/2.;
if(fabs(q_imag[i])<200){
gm[i] = cexp(lngamma_lanczos(plus) - lngamma_lanczos(minus));
}else{
gm[i] = cexp((plus-0.5)*clog(plus) - (minus-0.5)*clog(minus) - q_real - I*q_imag[i] \
+1./12 *(1./plus - 1./minus) \
+1./360.*(1./cpow(minus,3) - 1./cpow(plus,3)) \
+1./1260*(1./cpow(plus,5) - 1./cpow(minus,5)));
}
// if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
}
}

void g_l_1(double l, double nu, double *eta, double complex *gl1, long N) {
/* z = nu + I*eta
Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-1)/2 + I*eta/2 ) - lngamma( (4+l-nu)/2 - I*eta/2 ) ) */
long i;
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
gl1[i] = -(z-1.)* cexp((z-1.)*log(2.) + lngamma_lanczos((l+z-1.)/2.) - lngamma_lanczos((4.+l-z)/2.));
}
}

void g_l_2(double l, double nu, double *eta, double complex *gl2, long N) {
/* z = nu + I*eta
Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-2)/2 + I*eta/2 ) - lngamma( (5+l-nu)/2 - I*eta/2 ) ) */
long i;
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
gl2[i] = (z-1.)* (z-2.)* cexp((z-2.)*log(2.) + lngamma_lanczos((l+z-2.)/2.) - lngamma_lanczos((5.+l-z)/2.));
}
}
// void gamma_ratios(double l, double nu, double *eta, double complex *gl, long N) {
// /* z = nu + I*eta
// Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2 - I*eta/2 ) ) */
// long i;
// double complex z;
// for(i=0; i<N; i++) {
// z = nu+I*eta[i];
// // gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
// gl[i] = cexp(lngamma_lanczos((l+z)/2.) - lngamma_lanczos((3.+l-z)/2.) );
// // if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
// }
// }

// void g_l(double l, double nu, double *eta, double complex *gl, long N) {
// /* z = nu + I*eta
// Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2 - I*eta/2 ) ) */
// long i;
// double complex z;
// for(i=0; i<N; i++) {
// z = nu+I*eta[i];
// // gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
// gl[i] = cexp(z*log(2.) + lngamma_lanczos((l+z)/2.) - lngamma_lanczos((3.+l-z)/2.) );
// // if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
// }
// }

// void g_l_1(double l, double nu, double *eta, double complex *gl1, long N) {
// /* z = nu + I*eta
// Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-1)/2 + I*eta/2 ) - lngamma( (4+l-nu)/2 - I*eta/2 ) ) */
// long i;
// double complex z;
// for(i=0; i<N; i++) {
// z = nu+I*eta[i];
// gl1[i] = -(z-1.)* cexp((z-1.)*log(2.) + lngamma_lanczos((l+z-1.)/2.) - lngamma_lanczos((4.+l-z)/2.));
// }
// }

// void g_l_2(double l, double nu, double *eta, double complex *gl2, long N) {
// /* z = nu + I*eta
// Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-2)/2 + I*eta/2 ) - lngamma( (5+l-nu)/2 - I*eta/2 ) ) */
// long i;
// double complex z;
// for(i=0; i<N; i++) {
// z = nu+I*eta[i];
// gl2[i] = (z-1.)* (z-2.)* cexp((z-2.)*log(2.) + lngamma_lanczos((l+z-2.)/2.) - lngamma_lanczos((5.+l-z)/2.));
// }
// }

void c_window(double complex *out, double c_window_width, long halfN) {
// 'out' is (halfN+1) complex array
Expand Down
6 changes: 0 additions & 6 deletions cfastpt/utils_complex.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include <complex.h>
#include <fftw3.h>
void f_z(double z_real, double *z_imag, double complex *fz, long N);
void g_l(double l, double nu, double *eta, double complex *gl, long N);
void g_l_1(double l, double nu, double *eta, double complex *gl1, long N);
void g_l_2(double l, double nu, double *eta, double complex *gl2, long N);

void c_window(double complex *out, double c_window_width, long halfN);

Expand All @@ -12,9 +9,6 @@ void c_window(double complex *out, double c_window_width, long halfN);
double complex gamma_lanczos(double complex z);
double complex lngamma_lanczos(double complex z);

void gamma_ratios(double l, double nu, double *eta, double complex *gl, long N);


void g_m_vals(double mu, double q_real, double *q_imag, double complex *gm, long N);


Expand Down
91 changes: 91 additions & 0 deletions cfftlog/cfftlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,94 @@ void cfftlog_ells_increment(double *x, double *fx, long N, config *config, int*
free(out_ifft);
free(fb);
}


// same ell but multiple integrands with same x-range
void cfftlog_multiple(double *x, double **fx, long N, long Nf, config *config, int ell, double *y, double **Fy) {

long N_original = N;
long N_pad = config->N_pad;
N += 2*N_pad;

if(N % 2) {printf("Please use even number of x !\n"); exit(0);}
long halfN = N/2;

double x0, y0;
x0 = x[0];

double dlnx;
dlnx = log(x[1]/x0);

// Only calculate the m>=0 part
double eta_m[halfN+1];
long i, j;
for(i=0; i<=halfN; i++) {eta_m[i] = 2*M_PI / dlnx / N * i;}

double complex gl[halfN+1];

switch(config->derivative) {
case 0: g_l_cfft((double)ell, config->nu, eta_m, gl, halfN+1); break;
case 1: g_l_1_cfft((double)ell, config->nu, eta_m, gl, halfN+1); break;
case 2: g_l_2_cfft((double)ell, config->nu, eta_m, gl, halfN+1); break;
default: printf("Integral Not Supported! Please choose config->derivative from [0,1,2].\n");
}
// printf("g2[0]: %.15e+I*(%.15e)\n", creal(g2[0]),cimag(g2[0]));

// calculate y arrays
for(i=0; i<N_original; i++) {y[i] = (ell+1.) / x[N_original-1-i];}
y0 = y[0];

// biased input func
double **fb;
fb = malloc(Nf* sizeof(double*));
for(j=0; j<Nf; j++) {
fb[j] = malloc(N* sizeof(double));

for(i=0; i<N_pad; i++) {
fb[j][i] = 0.;
fb[j][N-1-i] = 0.;
}
for(i=N_pad; i<N_pad+N_original; i++) {
fb[j][i] = fx[j][i-N_pad] / pow(x[i-N_pad], config->nu) ;
}
}

fftw_complex *out;
fftw_plan plan_forward, plan_backward;
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * (halfN+1) );
double *in_fb;
in_fb = malloc(sizeof(double) * N );
plan_forward = fftw_plan_dft_r2c_1d(N, in_fb, out, FFTW_ESTIMATE);

double *out_ifft;
out_ifft = malloc(sizeof(double) * N );
plan_backward = fftw_plan_dft_c2r_1d(N, out, out_ifft, FFTW_ESTIMATE);

for(j=0; j<Nf; j++){
for(i=0; i<N; i++) { in_fb[i] = fb[j][i];}
fftw_execute(plan_forward);

c_window_cfft(out, config->c_window_width, halfN);
// printf("out[1]:%.15e+i*(%.15e)\n", creal(out[1]), cimag(out[1]));

for(i=0; i<=halfN; i++) {
out[i] *= cpow(x0*y0/exp(2*N_pad*dlnx), -I*eta_m[i]) * gl[i] ;
out[i] = conj(out[i]);
}
// printf("out[1]:%.15e+i*(%.15e)\n", creal(out[1]), cimag(out[1]));

fftw_execute(plan_backward);

for(i=0; i<N_original; i++) {
Fy[j][i] = out_ifft[i-N_pad] * sqrt(M_PI) / (4.*N * pow(y[i], config->nu));
}
}

fftw_destroy_plan(plan_forward);
fftw_destroy_plan(plan_backward);
fftw_free(out);
free(out_ifft);
free(in_fb);
for(j=0; j<Nf; j++) { free(fb[j]); }
free(fb);
}
4 changes: 3 additions & 1 deletion cfftlog/cfftlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ void cfftlog(double *x, double *fx, long N, config *config, int ell, double *y,

void cfftlog_ells(double *x, double *fx, long N, config *config, int* ell, long Nell, double **y, double **Fy);

void cfftlog_ells_increment(double *x, double *fx, long N, config *config, int* ell, long Nell, double **y, double **Fy);
void cfftlog_ells_increment(double *x, double *fx, long N, config *config, int* ell, long Nell, double **y, double **Fy);

void cfftlog_multiple(double *x, double **fx, long N, long Nf, config *config, int ell, double *y, double **Fy);
32 changes: 28 additions & 4 deletions cfftlog/utils_complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,31 @@ double complex lngamma_lanczos_cfft(double complex z) {
return log(2*M_PI) /2. + (z+0.5)*clog(t) -t + clog(x);
}

double complex ln_g_m_vals_cfft(double mu, double complex q) {
/* similar routine as python version.
use asymptotic expansion for large |mu+q| */
double complex asym_plus = (mu+1+ q)/2.;
double complex asym_minus= (mu+1- q)/2.;

return (asym_plus-0.5)*clog(asym_plus) - (asym_minus-0.5)*clog(asym_minus) - q \
+1./12 *(1./asym_plus - 1./asym_minus) \
+1./360.*(1./cpow(asym_minus,3) - 1./cpow(asym_plus,3)) \
+1./1260*(1./cpow(asym_plus,5) - 1./cpow(asym_minus,5));
}

void g_l_cfft(double l, double nu, double *eta, double complex *gl, long N) {
/* z = nu + I*eta
Calculate g_l = exp( zln2 + lngamma( (l+nu)/2 + I*eta/2 ) - lngamma( (3+l-nu)/2 - I*eta/2 ) ) */
long i;
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
// gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
gl[i] = cexp(z*log(2.) + lngamma_lanczos_cfft((l+z)/2.) - lngamma_lanczos_cfft((3.+l-z)/2.) );
if(l+fabs(eta[i])<200){
// gl[i] = cexp(z*log(2.) + clog(gamma_lanczos((l+z)/2.) ) - clog(gamma_lanczos((3.+l-z)/2.)));
gl[i] = cexp(z*log(2.) + lngamma_lanczos_cfft((l+z)/2.) - lngamma_lanczos_cfft((3.+l-z)/2.) );
}else{
gl[i] = cexp(z*log(2.) + ln_g_m_vals_cfft(l+0.5, z-1.5));
}
// if(isnan(gl[i])) {printf("nan at l,nu,eta, = %lf %lg %lg %lg %lg\n", l,nu, eta[i], gamma_lanczos((l+z)/2.),gamma_lanczos((3.+l-z)/2.));exit(0);}
}
}
Expand All @@ -68,7 +84,11 @@ Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-1)/2 + I*eta/2 ) - lngamma( (4+l-nu)
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
gl1[i] = -(z-1.)* cexp((z-1.)*log(2.) + lngamma_lanczos_cfft((l+z-1.)/2.) - lngamma_lanczos_cfft((4.+l-z)/2.));
if(l+fabs(eta[i])<200){
gl1[i] = -(z-1.)* cexp((z-1.)*log(2.) + lngamma_lanczos_cfft((l+z-1.)/2.) - lngamma_lanczos_cfft((4.+l-z)/2.));
}else{
gl1[i] = -(z-1.)* cexp((z-1.)*log(2.) + ln_g_m_vals_cfft(l+0.5, z-2.5));
}
}
}

Expand All @@ -79,7 +99,11 @@ Calculate g_l_1 = exp(zln2 + lngamma( (l+nu-2)/2 + I*eta/2 ) - lngamma( (5+l-nu)
double complex z;
for(i=0; i<N; i++) {
z = nu+I*eta[i];
gl2[i] = (z-1.)* (z-2.)* cexp((z-2.)*log(2.) + lngamma_lanczos_cfft((l+z-2.)/2.) - lngamma_lanczos_cfft((5.+l-z)/2.));
if(l+fabs(eta[i])<200){
gl2[i] = (z-1.)* (z-2.)* cexp((z-2.)*log(2.) + lngamma_lanczos_cfft((l+z-2.)/2.) - lngamma_lanczos_cfft((5.+l-z)/2.));
}else{
gl2[i] = (z-1.)* (z-2.)* cexp((z-2.)*log(2.) + ln_g_m_vals_cfft(l+0.5, z-3.5));
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion cfftlog/utils_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ void c_window_cfft(double complex *out, double c_window_width, long halfN);
// void resample_fourier_gauss(double *k, double *fk, config *config);

double complex gamma_lanczos_cfft(double complex z);
double complex lngamma_lanczos_cfft(double complex z);
double complex lngamma_lanczos_cfft(double complex z);
double complex ln_g_m_vals_cfft(double mu, double complex q);
Loading