Free Software C++/Python libraries for cosmological calculations
The CosmoBolognaLib documentation

Here you can find the full documentation of the CosmoBolognaLib, a large set of free software C++ libraries for cosmological calculations. Among many other things, these libraries can be used to measure the two-point and three-point correlation functions, and to model redshift-space distortions and baryon acoustic oscillations.

Please have a look at the example codes in CosmoBolognaLib/Examples/ that show how to use the CosmoBolognaLib in either C++ or Python codes.

If you use the CosmoBolognaLib, please reference the code paper: CosmoBolognaLib: C++ libraries for cosmological calculations

The specific tools to analyse cosmic void catalogues are presented in

This is the full list of scientific publications that used the CosmoBolognaLib: publications

Author and BDFL:

Main contributors:

  • Michele Moresco (three-point correlation)
  • Alfonso Veropalumbo (two-point angular correlation, clustering wedges, jackknife and bootstrap, lognormal mocks, BAO modelling, MCMC, three-point correlation modelling, etc.)

Other contributors:

  • Carlo Cannarozzo (void detection)
  • Sofia Contarini (void number counts)
  • Cosimo Fedeli (non-Gaussian cosmologies)
  • Giovanni Gandolfi (HOD modelling)
  • Jorge Enrique GarcĂ­a-Farieta (two-point correlation modelling)
  • Carlo Giocoli (mass accretion history)
  • Jacopo Neri (mass function)
  • Mauro Roncarelli (fast comoving distance estimator)
  • Tommaso Ronconi (void number counts)
  • Elena Sarpa (code validation)
  • Akke Viitanen (code validation)

A configured virtual development environment to use the CosmoBolognaLib is available here:
the password is: cbl

Alternatively, to install the CosmoBolognaLib on a custom Unix/Mac distribution, please follow the instructions below:

first, make sure that the following external libraries are present in your system:

  • GSL (GNU Scientific Library) (v2.1 is required)
  • FFTW (Fastest Fourier Transform in the West)
  • OpenMP (Open Multiprocessing)

if the paths of these libraries are not the default ones, then they have to be added to the LD_LIBRARY_PATH environment variable (e.g. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your_path)

the FFTW have to be compiled as shared libraries and using OpenMP compiler directives (e.g. on Unix systems: ./configure –enable-shared –enable-openmp)


— for Python users

$ pip install CosmoBolognaLib –user

or with sudo privileges:

$ sudo pip install CosmoBolognaLib

— for C++ users and C++/Python developers

  • download the CosmobolognaLib:

either, clone the public GitHub repository of the CosmobolognaLib with:

$ git clone

or, alternatively, download the unzip the archive at

  • enter the folder CosmoBolognaLib/ and type:

$ make

by default, make will compile the full set of libraries using the GNU project g++ compile (>=v4.8.4 is required); both the compiler and the compilation flags can be specified by modifying the variables C and FLAGS defined in the Makefile (e.g.: make C=icpc FLAGS="-O0 -g")

  • other Makefile options are:

$ make lib* [ —> compile the * library (e.g. make libFUNC will compile the library ]

$ make python [ —> compile the Python wrappers (SWIG >=v3.0.7 is required); in this case, CosmoBolognaLib/Python/ has to be added in PYTHONPATH (e.g. in .bashrc add the following line: export PYTHONPATH=$PYTHONPATH:/path_to/CosmoBolognaLib/Python/); to specify a different python version set the PY variable (e.g. make python PY=python3) ]

$ make cleanpy [ —> remove the Python wrappers ]

$ make allExamples [ —> compile all the C++ example codes ]

$ make cleanExamples [ —> remove all the object files of the examples ]

$ make documentation [ —> create the documentation (Doxygen is required) ]

$ make clean [ —> cleanExamples + remove all the object files of the libraries ]

$ make purge [ —> make clean + remove all the library files (i.e. *.so) ]

$ make purgeALL [—> make purge + make cleanpy + remove all the files stored for internal calculations ]

  • optionally, the following external softwares used by the CosmoBolognaLib can be compiled with the following commands:

$ make CUBA

$ make CCfits

$ make CAMB

$ make CLASS

$ make CLASSpy [ —> compile the Python wrapper for CLASS) ]

$ make MPTbreeze

$ make mangle