CosmoMC: Likelihood Function
-
- Posts: 14
- Joined: June 08 2007
- Affiliation: CEA
CosmoMC: Likelihood Function
Hi All,
I need to make a few changes to CosmoMC so that it calculates the likelihood function of [tex]C_l[/tex]s in another space, e.g. [tex]w*C_l[/tex] (where w is a dictionary; could be PCA or something). Apart from the changes that I need to make in the cmbdata.F90 file, is there any other changes I need to make? (I only care about CMB data)
Does anyone know? I appreciate your help.
Many thanks,
Paniez
I need to make a few changes to CosmoMC so that it calculates the likelihood function of [tex]C_l[/tex]s in another space, e.g. [tex]w*C_l[/tex] (where w is a dictionary; could be PCA or something). Apart from the changes that I need to make in the cmbdata.F90 file, is there any other changes I need to make? (I only care about CMB data)
Does anyone know? I appreciate your help.
Many thanks,
Paniez
-
- Posts: 14
- Joined: June 08 2007
- Affiliation: CEA
CosmoMC: Likelihood Function
Also, does anyone know if we can call C++/IDL programs from Fortran?
(The programs that take my [tex]C_l[/tex] to [tex]w*C_l[/tex] are in C++/IDL)
Thanks,
Paniez
(The programs that take my [tex]C_l[/tex] to [tex]w*C_l[/tex] are in C++/IDL)
Thanks,
Paniez
-
- Posts: 50
- Joined: March 26 2006
- Affiliation: DESY
- Contact:
CosmoMC: Likelihood Function
Hi Paniez,
as far as I know, calling C++ from Fortran is a bit tricky. However, it is possible to call C from Fortran, see the attached .tgz file for an example. The files will be unpacked into the current working directory. Compile them with "make".
Download here: f90c.tgz
Pascal
as far as I know, calling C++ from Fortran is a bit tricky. However, it is possible to call C from Fortran, see the attached .tgz file for an example. The files will be unpacked into the current working directory. Compile them with "make".
Download here: f90c.tgz
Pascal
-
- Posts: 7
- Joined: March 11 2005
- Affiliation: Centre d'Etude Spatiale des Rayonnements
CosmoMC: Likelihood Function
I've used cosmomc as a sample calling a C++ likelihood function, though the function call itself is not different from a C function, so maybe that's why it's easy. (Caveat: I have no idea what I'm doing. I just google and hack around until it works.) Basically, I add to my C++ code the following definition:
where my_like() is the C++ function. That object can then be linked while compiling cosmomc with the addition of the -cxxlib or -lstdc++ flag (depending on the compiler, apparently) and called in the Fortran as
I've done this variously with ifort and gfortran (4.3+) on Linux and Mac OS X.
I have not, however, ever tried to do this intelligently, calling a C++ class function from Fortran, where the class object is kept around between samples rather than starting from scratch each time. It would make my life easier if I could, so if anybody has an example of that, I'd like to see it.
Code: Select all
extern "C" {
int my_like_(float *inparams,int *n_params, float *lnlike ) {
my_like(inparams,n_params,lnlike);
return(0);
}
}
Code: Select all
call my_like(Params%P,num_hard,thisval)
I have not, however, ever tried to do this intelligently, calling a C++ class function from Fortran, where the class object is kept around between samples rather than starting from scratch each time. It would make my life easier if I could, so if anybody has an example of that, I'd like to see it.
-
- Posts: 14
- Joined: June 08 2007
- Affiliation: CEA
CosmoMC: Likelihood Function
Thanks so much to both of you. I will test them.
Regards
Paniez
Regards
Paniez