├── .github ├── CODE_OF_CONDUCT.rst ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── ci.yml │ └── pypi-publish.yml ├── .gitignore ├── .readthedocs.yaml ├── CHANGES.rst ├── Corrfunc ├── __init__.py ├── io.py ├── mocks │ ├── DDrppi_mocks.py │ ├── DDsmu_mocks.py │ ├── DDtheta_mocks.py │ ├── __init__.py │ └── vpf_mocks.py ├── tests │ ├── __init__.py │ ├── common.py │ ├── test_mocks.py │ └── test_theory.py ├── theory │ ├── DD.py │ ├── DDrppi.py │ ├── DDsmu.py │ ├── __init__.py │ ├── vpf.py │ ├── wp.py │ └── xi.py └── utils.py ├── FAQ ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── common.mk ├── corrfunc_logo.png ├── docs ├── Makefile └── source │ ├── all-interfaces.rst │ ├── api │ ├── Corrfunc.mocks.rst │ ├── Corrfunc.rst │ ├── Corrfunc.theory.rst │ └── modules.rst │ ├── apidoc.sh │ ├── commandline-interface.rst │ ├── conf.py │ ├── corrfunc-logo-no-text.ico │ ├── corrfunc_logo_320px_240px.png │ ├── development │ ├── bug_reports.rst │ ├── citing_corrfunc.rst │ ├── contributing.rst │ ├── contributors.rst │ ├── index.rst │ └── staying_up_to_date.rst │ ├── index.rst │ ├── install.rst │ ├── modules │ ├── computing_wp_and_xi.rst │ ├── converting_3d_counts.rst │ ├── converting_ddtheta_mocks.rst │ ├── converting_rp_pi_counts.rst │ ├── converting_rp_pi_mocks.rst │ ├── custom_weighting.rst │ ├── fast_food_binary.rst │ ├── generate_bins.rst │ ├── index.rst │ ├── mock_functions.rst │ ├── read_catalog.rst │ ├── rr_autocorrelations.rst │ ├── theory_functions.rst │ ├── weighted_correlations.rst │ └── which_corrfunc.rst │ ├── python-interface.rst │ ├── quickstart.rst │ ├── requirements.txt │ └── staticlibrary-interface.rst ├── io ├── Makefile ├── ftread.c ├── ftread.h ├── io.c └── io.h ├── mocks.options ├── mocks ├── DDrppi_mocks │ ├── DDrppi_mocks.c │ ├── Makefile │ ├── countpairs_rp_pi_mocks.c │ ├── countpairs_rp_pi_mocks.h │ ├── countpairs_rp_pi_mocks_impl.c.src │ ├── countpairs_rp_pi_mocks_impl.h.src │ ├── countpairs_rp_pi_mocks_kernels.c.src │ └── wprp_mocks.c ├── DDsmu_mocks │ ├── DDsmu_mocks.c │ ├── Makefile │ ├── countpairs_s_mu_mocks.c │ ├── countpairs_s_mu_mocks.h │ ├── countpairs_s_mu_mocks_impl.c.src │ ├── countpairs_s_mu_mocks_impl.h.src │ └── countpairs_s_mu_mocks_kernels.c.src ├── DDtheta_mocks │ ├── DDtheta_mocks.c │ ├── Makefile │ ├── countpairs_theta_mocks.c │ ├── countpairs_theta_mocks.h │ ├── countpairs_theta_mocks_impl.c.src │ ├── countpairs_theta_mocks_impl.h.src │ ├── countpairs_theta_mocks_kernels.c.src │ └── wtheta.c ├── Makefile ├── benchmarks │ ├── timings_Mr19_mocks_openmp.eps │ ├── timings_Mr19_mocks_openmp.tex │ ├── timings_Mr19_mocks_rmax.eps │ ├── timings_Mr19_mocks_rmax.pdf │ └── timings_Mr19_mocks_rmax.txt ├── examples │ ├── Makefile │ └── run_correlations_mocks.c ├── python_bindings │ ├── Makefile │ ├── _countpairs_mocks.c │ └── call_correlation_functions_mocks.py ├── tests │ ├── Makefile │ ├── Mr19_mock.DD │ ├── Mr19_mock.DR │ ├── Mr19_mock_DDsmu.DR │ ├── Mr19_mock_DDsmu.RR │ ├── Mr19_mock_vpf │ ├── Mr19_mock_wtheta.DD │ ├── Mr19_mock_wtheta.DR │ ├── Mr19_randoms_vpf │ ├── angular_bins │ ├── bins │ ├── data │ │ ├── Mr19_centers_xyz_forVPF_rmax_10Mpc.txt │ │ ├── Mr19_mock_northonly.rdcz.dat │ │ ├── Mr19_mock_northonly.rdcz.ff │ │ └── Mr19_randoms_northonly.rdcz.ff │ └── tests_mocks.c └── vpf_mocks │ ├── Makefile │ ├── countspheres_mocks.c │ ├── countspheres_mocks.h │ ├── countspheres_mocks_impl.c.src │ ├── countspheres_mocks_impl.h.src │ ├── vpf_mocks.c │ └── vpf_mocks_kernels.c.src ├── paper ├── figures │ └── generate_sphere_grid.py ├── scripts │ ├── codes_scaling_numpart.npz │ ├── codes_scaling_numpart_parallel.npz │ ├── cute_box_param.txt │ ├── generate_code_comparison.py │ ├── generate_nthreads_scaling.py │ ├── generate_numpart_scaling.py │ ├── generate_rmax_scaling.py │ ├── get_speedups.py │ ├── mocks_scaling_nthreads.npz │ ├── mocks_scaling_nthreads_stampede_icc15.npz │ ├── mocks_scaling_nthreads_stampede_icc15_after_weights.npz │ ├── mocks_scaling_numpart.npz │ ├── mocks_scaling_numpart_stampede_icc15_after_weights.npz │ ├── mocks_scaling_rmax.npz │ ├── mocks_scaling_rmax_stampede_icc15.npz │ ├── mocks_scaling_rmax_stampede_icc15_after_weights.npz │ ├── runtimes_bender_icc14.npz │ ├── runtimes_stampede_icc15.npz │ ├── swot_config.txt │ ├── theory_scaling_nthreads.npz │ ├── theory_scaling_nthreads_stampede_icc15.npz │ ├── theory_scaling_nthreads_stampede_icc15_after_weights.npz │ ├── theory_scaling_numpart.npz │ ├── theory_scaling_numpart_stampede_icc15_after_weights.npz │ ├── theory_scaling_rmax.npz │ ├── theory_scaling_rmax_stampede_icc15.npz │ ├── theory_scaling_rmax_stampede_icc15_after_weights.npz │ └── utils.py └── tables │ ├── timings_Mr19_numpart_theory_simd_speedup.tex │ ├── timings_Mr19_openmp_mocks.tex │ ├── timings_Mr19_openmp_theory.tex │ └── timings_Mr19_rmax_theory_simd_speedup.tex ├── rules.mk ├── setup.py ├── theory.options ├── theory ├── DD │ ├── DD.c │ ├── Makefile │ ├── countpairs.c │ ├── countpairs.h │ ├── countpairs_impl.c.src │ ├── countpairs_impl.h.src │ ├── countpairs_kernels.c.src │ └── xi_of_r_scaling_Mr19.png ├── DDrppi │ ├── DDrppi.c │ ├── Makefile │ ├── countpairs_rp_pi.c │ ├── countpairs_rp_pi.h │ ├── countpairs_rp_pi_impl.c.src │ ├── countpairs_rp_pi_impl.h.src │ ├── countpairs_rp_pi_kernels.c.src │ ├── wprp.c │ └── xi_rp_pi_scaling_Mr19.png ├── DDsmu │ ├── DDsmu.c │ ├── Makefile │ ├── countpairs_s_mu.c │ ├── countpairs_s_mu.h │ ├── countpairs_s_mu_impl.c.src │ ├── countpairs_s_mu_impl.h.src │ └── countpairs_s_mu_kernels.c.src ├── Makefile ├── README.rst ├── benchmarks │ ├── timings_Mr19_numpart.eps │ ├── timings_Mr19_numpart.pdf │ ├── timings_Mr19_numpart.txt │ ├── timings_Mr19_openmp.eps │ ├── timings_Mr19_openmp.pdf │ ├── timings_Mr19_openmp.tex │ ├── timings_Mr19_openmp.txt │ ├── timings_Mr19_rmax.eps │ ├── timings_Mr19_rmax.pdf │ └── timings_Mr19_rmax.txt ├── bins ├── examples │ ├── Makefile │ └── run_correlations.c ├── logbins.c ├── python_bindings │ ├── Makefile │ ├── _countpairs.c │ └── call_correlation_functions.py ├── tests │ ├── Makefile │ ├── Mr19_DD_nonperiodic │ ├── Mr19_DD_periodic │ ├── Mr19_DDrppi_nonperiodic │ ├── Mr19_DDrppi_periodic │ ├── Mr19_DDsmu_nonperiodic │ ├── Mr19_DDsmu_periodic │ ├── Mr19_vpf_periodic │ ├── Mr19_wp │ ├── Mr19_xi │ ├── bins │ ├── cmass_DD_periodic │ ├── cmass_DR_nonperiodic │ ├── cmass_DR_periodic │ ├── cmass_RR_periodic │ ├── data │ │ ├── cmassmock_Zspace.ff │ │ ├── gals_Mr19.ff │ │ └── random_Zspace.ff │ ├── test_nonperiodic.c │ └── test_periodic.c ├── vpf │ ├── Makefile │ ├── countspheres.c │ ├── countspheres.h │ ├── countspheres_impl.c.src │ ├── countspheres_impl.h.src │ ├── vpf.c │ └── vpf_kernels.c.src ├── wp │ ├── Makefile │ ├── countpairs_wp.c │ ├── countpairs_wp.h │ ├── countpairs_wp_impl.c.src │ ├── countpairs_wp_impl.h.src │ ├── wp.c │ ├── wp_kernels.c.src │ └── wp_scaling_Mr19.png └── xi │ ├── Makefile │ ├── countpairs_xi.c │ ├── countpairs_xi.h │ ├── countpairs_xi_impl.c.src │ ├── countpairs_xi_impl.h.src │ ├── xi.c │ └── xi_kernels.c.src └── utils ├── Makefile ├── avx2_calls.h ├── avx512_calls.c ├── avx512_calls.h ├── avx_calls.h ├── cache.c ├── cache.h ├── cell_pair.h.src ├── cellarray.h.src ├── cellarray_mocks.h.src ├── cosmology_params.c ├── cosmology_params.h ├── cpu_features.c ├── cpu_features.h ├── defs.h ├── fast_acos.h ├── function_precision.h ├── gridlink_impl.c.src ├── gridlink_impl.h.src ├── gridlink_mocks_impl.c.src ├── gridlink_mocks_impl.h.src ├── gridlink_utils.c.src ├── gridlink_utils.h.src ├── macros.h ├── progressbar.c ├── progressbar.h ├── set_cosmo_dist.c ├── set_cosmo_dist.h ├── set_cosmology.c ├── set_cosmology.h ├── sglib.h ├── sse_calls.h ├── tests_common.h ├── utils.c ├── utils.h ├── weight_defs.h.src ├── weight_functions.h.src └── write_weights_to_fastfood.c /.github/CODE_OF_CONDUCT.rst: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Contributor Covenant Code of Conduct 3 | ===================================== 4 | 5 | Our Pledge 6 | *********** 7 | 8 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 9 | 10 | Our Standards 11 | ************** 12 | 13 | Examples of behavior that contributes to creating a positive environment include: 14 | 15 | * Using welcoming and inclusive language 16 | * Being respectful of differing viewpoints and experiences 17 | * Gracefully accepting constructive criticism 18 | * Focusing on what is best for the community 19 | * Showing empathy towards other community members 20 | 21 | Examples of unacceptable behavior by participants include: 22 | 23 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 24 | * Trolling, insulting/derogatory comments, and personal or political attacks 25 | * Public or private harassment 26 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 27 | * Other conduct which could reasonably be considered inappropriate in a professional setting 28 | 29 | Our Responsibilities 30 | ********************* 31 | 32 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 33 | 34 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 35 | 36 | Scope 37 | ****** 38 | 39 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 40 | 41 | Enforcement 42 | ************ 43 | 44 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at corrfunc@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 45 | 46 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 47 | 48 | Attribution 49 | ************** 50 | 51 | This Code of Conduct is adapted from the `Contributor Covenant `_, version 1.4, available at `version `_ 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Please describe the bug report to help us improve 4 | 5 | --- 6 | 7 | 12 | 13 | ## General information 14 | 15 | - Corrfunc version: 16 | - platform: 17 | - installation method (pip/source/other?): 18 | 19 | ## Issue description 20 | 21 | ### Expected behavior 22 | 23 | 24 | ### Actual behavior 25 | 26 | 27 | ### What have you tried so far? 28 | 29 | 30 | ## Minimal failing example 31 | 32 | 33 | 34 | ```python 35 | import Corrfunc 36 | 37 | 38 | # rest of sample code goes here... 39 | ``` 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "monthly" 12 | -------------------------------------------------------------------------------- /.github/workflows/pypi-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will upload a Python Package using Twine when a release is created 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Upload Python Package to PyPI 10 | 11 | on: 12 | release: 13 | types: [published] 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | deploy: 20 | 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Set up Python 26 | uses: actions/setup-python@v5 27 | with: 28 | python-version: '3.x' 29 | - name: Install setuptools 30 | run: python -m pip install setuptools 31 | - name: Create source distribution 32 | run: python setup.py sdist 33 | - name: Publish package 34 | uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc 35 | with: 36 | skip-existing: true 37 | user: __token__ 38 | password: ${{ secrets.PyPI_Publish }} 39 | - name: Install package from PyPI 40 | run: python -m pip install Corrfunc==${{ github.event.release.tag_name }} 41 | - name: Verify installed version 42 | run: | 43 | export corrfunc_version=`python -c "import Corrfunc; print(Corrfunc.__version__)"` 44 | echo "Installed Corrfunc version = ${corrfunc_version}" 45 | echo "GitHub Release name = ${{ github.event.release.tag_name }}" 46 | if [[ "$corrfunc_version" != "${{ github.event.release.tag_name }}" ]]; then exit 1; fi 47 | 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.o 3 | *~ 4 | *.a 5 | *.so 6 | *.so.* 7 | *.bak 8 | *.dat* 9 | *xx* 10 | *yy* 11 | *zz* 12 | *.txt* 13 | *dSYM* 14 | .DS_Store 15 | *.pyc 16 | *_float.[ch] 17 | *_double.[ch] 18 | DD 19 | wtheta 20 | DDsmu 21 | build* 22 | paper/* 23 | dist* 24 | *egg* 25 | *_mocks 26 | *.pro 27 | *.patch 28 | logbins 29 | vpf 30 | wp 31 | xi 32 | DDrppi 33 | wprp 34 | DDsmu 35 | bin/* 36 | include/* 37 | run_correlations 38 | test_*period* 39 | *output*integration* 40 | *.tgz 41 | cov-int 42 | *.gcno 43 | *.ipynb 44 | *.log 45 | *.out* 46 | *.d 47 | *.fls 48 | *.aux* 49 | *.*make 50 | *.blg 51 | *.spl 52 | *.toc 53 | *.html 54 | *.old 55 | *.vscode -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the OS, Python version and other tools you might need 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | # You can also specify other tool versions: 13 | # nodejs: "20" 14 | # rust: "1.70" 15 | # golang: "1.20" 16 | 17 | # Build documentation in the "docs/" directory with Sphinx 18 | sphinx: 19 | configuration: docs/source/conf.py 20 | # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs 21 | # builder: "dirhtml" 22 | # Fail on all warnings to avoid broken references 23 | # fail_on_warning: true 24 | 25 | # Optionally build your docs in additional formats such as PDF and ePub 26 | # formats: 27 | # - pdf 28 | # - epub 29 | 30 | # Optional but recommended, declare the Python requirements required 31 | # to build your documentation 32 | # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 33 | python: 34 | install: 35 | - requirements: docs/source/requirements.txt 36 | -------------------------------------------------------------------------------- /Corrfunc/mocks/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Wrapper for all clustering statistic calculations on galaxies 6 | in a mock catalog. 7 | """ 8 | from __future__ import (division, print_function, absolute_import, 9 | unicode_literals) 10 | 11 | __author__ = ('Manodeep Sinha') 12 | __all__ = ("DDrppi_mocks", "DDtheta_mocks", "vpf_mocks", "DDsmu_mocks" ) 13 | 14 | import sys 15 | from .DDrppi_mocks import DDrppi_mocks 16 | from .DDtheta_mocks import DDtheta_mocks 17 | from .vpf_mocks import vpf_mocks 18 | from .DDsmu_mocks import DDsmu_mocks 19 | 20 | if sys.version_info[0] < 3: 21 | __all__ = [n.encode('ascii') for n in __all__] 22 | -------------------------------------------------------------------------------- /Corrfunc/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/Corrfunc/tests/__init__.py -------------------------------------------------------------------------------- /Corrfunc/theory/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Wrapper for all clustering statistic calculations on galaxies 6 | in a simulation volume. 7 | """ 8 | from __future__ import (division, print_function, absolute_import, 9 | unicode_literals) 10 | 11 | __author__ = ('Manodeep Sinha') 12 | __all__ = ('DD', 'DDrppi', 'wp', 'xi', 'vpf', 'DDsmu',) 13 | 14 | import sys 15 | 16 | from .DD import DD 17 | from .DDrppi import DDrppi 18 | from .wp import wp 19 | from .xi import xi 20 | from .vpf import vpf 21 | from .DDsmu import DDsmu 22 | 23 | if sys.version_info[0] < 3: 24 | __all__ = [n.encode('ascii') for n in __all__] 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Manodeep Sinha (manodeep@gmail.com) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to 5 | deal in the Software without restriction, including without limitation the 6 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 | sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst CHANGES.rst Makefile .travis.yml common.mk rules.mk theory.options mocks.options FAQ INSTALL LICENSE 2 | include theory/python_bindings/call_correlation_functions.py mocks/python_bindings/call_correlation_functions_mocks.py 3 | 4 | include docs Makefile 5 | recursive-include docs/source *.rst *.py 6 | 7 | recursive-include theory *.c *.h *.c.src *.h.src Makefile 8 | recursive-include mocks *.c *.h *.c.src *.h.src Makefile 9 | recursive-include io *.c *.h Makefile 10 | recursive-include utils *.c *.h *.c.src *.h.src Makefile 11 | 12 | recursive-include theory/tests Mr19_* cmass* bins 13 | recursive-include theory/tests/data *.ff 14 | recursive-include mocks/tests bins angular_bins Mr19* 15 | recursive-include mocks/tests/data *.txt *.dat 16 | 17 | exclude theory/tests/data/random_Zspace.ff 18 | exclude mocks/tests/data/Mr19_randoms_northonly.rdcz.ff 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: dirs theory mocks 2 | 3 | dirs: | lib bin include 4 | 5 | lib bin include: 6 | mkdir -p $@ 7 | 8 | theory: | dirs 9 | $(MAKE) -C theory 10 | 11 | mocks: | dirs 12 | $(MAKE) -C mocks 13 | 14 | install: | dirs 15 | $(MAKE) -C theory install 16 | $(MAKE) -C mocks install 17 | 18 | libs: | dirs 19 | $(MAKE) -C theory libs 20 | $(MAKE) -C mocks libs 21 | 22 | tests: 23 | $(MAKE) -C theory tests 24 | $(MAKE) -C mocks tests 25 | 26 | 27 | .PHONY: clean celna clena celan theory mocks install distclean realclean libs lib 28 | 29 | distclean:realclean 30 | distclena:realclean 31 | realclena:realclean 32 | 33 | realclean:|dirs 34 | $(MAKE) -C theory distclean 35 | $(MAKE) -C mocks distclean 36 | @{\ 37 | if [ 0 -eq $$(ls -1 lib/lib*.a 2>/dev/null | wc -l) ]; then \ 38 | echo "No static libs in lib/. Removing defs.h " ;\ 39 | rm -f include/defs.h;\ 40 | fi;\ 41 | } 42 | $(MAKE) -C utils clean 43 | $(MAKE) -C io clean 44 | 45 | clean: 46 | $(MAKE) -C theory clean 47 | $(MAKE) -C mocks clean 48 | 49 | clena: clean 50 | celan: clean 51 | celna: clean 52 | 53 | 54 | -------------------------------------------------------------------------------- /corrfunc_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/corrfunc_logo.png -------------------------------------------------------------------------------- /docs/source/api/Corrfunc.mocks.rst: -------------------------------------------------------------------------------- 1 | Corrfunc.mocks package 2 | ====================== 3 | 4 | .. automodule:: Corrfunc.mocks 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | -------------------------------------------------------------------------------- /docs/source/api/Corrfunc.rst: -------------------------------------------------------------------------------- 1 | Corrfunc package 2 | ================ 3 | 4 | .. automodule:: Corrfunc 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | Subpackages 10 | ----------- 11 | 12 | .. toctree:: 13 | 14 | Corrfunc.mocks 15 | Corrfunc.theory 16 | 17 | Corrfunc.io module 18 | ------------------ 19 | 20 | .. automodule:: Corrfunc.io 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | 25 | Corrfunc.utils module 26 | --------------------- 27 | 28 | .. automodule:: Corrfunc.utils 29 | :members: 30 | :undoc-members: 31 | :show-inheritance: 32 | 33 | -------------------------------------------------------------------------------- /docs/source/api/Corrfunc.theory.rst: -------------------------------------------------------------------------------- 1 | Corrfunc.theory package 2 | ======================= 3 | 4 | .. automodule:: Corrfunc.theory 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | -------------------------------------------------------------------------------- /docs/source/api/modules.rst: -------------------------------------------------------------------------------- 1 | Comprehensive API reference 2 | =========================== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | Corrfunc 8 | -------------------------------------------------------------------------------- /docs/source/apidoc.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if ! python -c 'import numpydoc'; then easy_install --user numpydoc; fi 4 | if ! python -c 'import sphinx'; then easy_install --user sphinx; fi 5 | 6 | outdir=source/api 7 | sphinx-apidoc -H "Comprehensive API reference" -M -f -o "$outdir" ../Corrfunc/ ../Corrfunc/tests.py ../Corrfunc/call_correlation_functions.py ../Corrfunc/call_correlation_functions_mocks.py 8 | 9 | tmpfile="$(mktemp)" 10 | # Fix the blank sub-modules in the Corrfunc file 11 | for docfile in "$outdir/Corrfunc.rst" 12 | do 13 | # Delete three lines following the "submodules" 14 | sed -e '/Submodules/{N;N;d;}' "$docfile" > "$tmpfile" 15 | mv "$tmpfile" "$docfile" 16 | done 17 | 18 | 19 | # Fix the duplicate entries for the various pair-counters 20 | # (e.g., Corrfunc.theory.DD *and* Corrfunc.theory.DD.DD) 21 | for docfile in "$outdir/Corrfunc.mocks.rst" "$outdir/Corrfunc.theory.rst" 22 | do 23 | # Delete ALL lines following this "submodule" line in the theory/mocks 24 | # auto-generated documentation 25 | sed -n '/Submodules/q;p' "$docfile" > "$tmpfile" 26 | mv "$tmpfile" "$docfile" 27 | done 28 | -------------------------------------------------------------------------------- /docs/source/commandline-interface.rst: -------------------------------------------------------------------------------- 1 | .. _commandline-interface: 2 | 3 | ********************************************* 4 | Using the command-line interface in Corrfunc 5 | ********************************************* 6 | 7 | This guide assumes that you already followed the :ref:`step_by_step_install` 8 | section of the documentation to get the package and its dependencies set 9 | up on your machine. 10 | 11 | Calculating spatial clustering statistics in simulation boxes 12 | ============================================================== 13 | 14 | Corrfunc can compute a range of spatial correlation functions and the 15 | counts-in-cells. The easiest way to get help on the command-line is by calling 16 | the executables without any input parameters. Here is the list of executables 17 | associated with each type of clustering statistic: 18 | 19 | ====================== ========================== 20 | Clustering Statistic Full path to executable 21 | ====================== ========================== 22 | :math:`DD(r)` ``theory/DD/DD`` 23 | :math:`DD(r_p,\pi)` ``theory/DDrppi/DDrppi`` 24 | :math:`w_p(r_p)` ``theory/wp/wp`` 25 | :math:`\xi(r)` ``theory/xi/xi`` 26 | :math:`pN(n)` ``theory/vpf/vpf`` 27 | ====================== ========================== 28 | 29 | 30 | Calculating clustering statistics in mock catalogs 31 | =================================================== 32 | The list of clustering statistics supported on mock catalogs and the associated 33 | command-line executables are: 34 | 35 | ====================== ======================================= 36 | Clustering Statistic Full path to executable 37 | ====================== ======================================= 38 | :math:`DD(r_p,\pi)` ``mocks/DDrppi_mocks/DDrppi_mocks`` 39 | :math:`DD(\theta)` ``mocks/DDtheta_mocks/DDtheta_mocks`` 40 | :math:`pN(n)` ``mocks/vpf_mocks/vpf_mocks`` 41 | ====================== ======================================= 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/source/corrfunc-logo-no-text.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/docs/source/corrfunc-logo-no-text.ico -------------------------------------------------------------------------------- /docs/source/corrfunc_logo_320px_240px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/docs/source/corrfunc_logo_320px_240px.png -------------------------------------------------------------------------------- /docs/source/development/bug_reports.rst: -------------------------------------------------------------------------------- 1 | .. _bug_reports: 2 | 3 | ************************* 4 | Submitting a Bug Report 5 | ************************* 6 | 7 | If you find or just suspect buggy behavior in Corrfunc, 8 | please raise an issue on GitHub. Navigate to the 9 | `Corrfunc Issues page `_, 10 | create a new issue with a description of the problem and 11 | the full Traceback (if applicable), and attach a *bug* label to the issue. 12 | 13 | -------------------------------------------------------------------------------- /docs/source/development/citing_corrfunc.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _citing_corrfunc: 4 | 5 | ============================================== 6 | License and Citation Information 7 | ============================================== 8 | 9 | Citing Corrfunc 10 | ------------------ 11 | 12 | 13 | If you use ``Corrfunc`` for research, please cite using the MNRAS code paper with the following 14 | bibtex entry: 15 | 16 | :: 17 | 18 | @ARTICLE{2020MNRAS.491.3022S, 19 | author = {{Sinha}, Manodeep and {Garrison}, Lehman H.}, 20 | title = "{CORRFUNC - a suite of blazing fast correlation functions on 21 | the CPU}", 22 | journal = {\mnras}, 23 | keywords = {methods: numerical, galaxies: general, galaxies: 24 | haloes, dark matter, large-scale structure of Universe, cosmology: 25 | theory}, 26 | year = "2020", 27 | month = "Jan", 28 | volume = {491}, 29 | number = {2}, 30 | pages = {3022-3041}, 31 | doi = {10.1093/mnras/stz3157}, 32 | adsurl = 33 | {https://ui.adsabs.harvard.edu/abs/2020MNRAS.491.3022S}, 34 | adsnote = {Provided by the SAO/NASA 35 | Astrophysics Data System} 36 | } 37 | 38 | 39 | The MNRAS paper (also on `arXiv:1911.03545 40 | `_) targets ``Corrfunc v2.0.0``. If you are 41 | using ``Corrfunc v2.3.0`` or later, **and** you benefit from the 42 | enhanced vectorised kernels, then please additionally cite this paper: 43 | 44 | :: 45 | 46 | @InProceedings{10.1007/978-981-13-7729-7_1, 47 | author="Sinha, Manodeep and Garrison, Lehman", 48 | editor="Majumdar, Amit and Arora, Ritu", 49 | title="CORRFUNC: Blazing Fast Correlation Functions with AVX512F SIMD Intrinsics", 50 | booktitle="Software Challenges to Exascale Computing", 51 | year="2019", 52 | publisher="Springer Singapore", 53 | address="Singapore", 54 | pages="3--20", 55 | isbn="978-981-13-7729-7", 56 | url={https://doi.org/10.1007/978-981-13-7729-7_1} 57 | } 58 | 59 | 60 | 61 | Corrfunc License 62 | --------------------- 63 | 64 | Corrfunc comes with a MIT LICENSE - see the LICENSE file. 65 | 66 | Copyright (C) 2014 Manodeep Sinha (manodeep@gmail.com) 67 | 68 | Permission is hereby granted, free of charge, to any person obtaining a copy 69 | of this software and associated documentation files (the "Software"), to 70 | deal in the Software without restriction, including without limitation the 71 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 72 | sell copies of the Software, and to permit persons to whom the Software is 73 | furnished to do so, subject to the following conditions: 74 | 75 | The above copyright notice and this permission notice shall be included in 76 | all copies or substantial portions of the Software. 77 | 78 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 79 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 80 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 81 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 82 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 83 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 84 | DEALINGS IN THE SOFTWARE. 85 | -------------------------------------------------------------------------------- /docs/source/development/contributors.rst: -------------------------------------------------------------------------------- 1 | .. _contributor_list: 2 | 3 | ************************** 4 | Package contributors 5 | ************************** 6 | 7 | Corrfunc project coordinator 8 | =============================== 9 | 10 | * Manodeep Sinha 11 | 12 | Lead developers 13 | ========================== 14 | 15 | * Manodeep Sinha 16 | 17 | Core package contributors 18 | ========================== 19 | 20 | * Manodeep Sinha (@manodeep) 21 | * Lehman Garrison (@lgarrison) 22 | * Nick Hand (@nickhand) 23 | 24 | Other credits 25 | ============= 26 | 27 | * Corrfunc contains code from `Agner Fog `_, `GeometricTools 28 | `_, and the package `SGLIB 29 | `_. The LICENSE for these external files 30 | remains with the original author of the package. 31 | 32 | * The entirety of the docs for Corrfunc is derived from `halotools 33 | `_. I know, first-hand, how much of an 34 | effort it was for the developers of `halotools` to generate all of this 35 | documentation. Having such a template made creating the docs for Corrfunc a 36 | lot easier process. 37 | 38 | * The API generation script for Corrfunc was lifted directly out of the 39 | repo `bccp/nbodykit/ `_. 40 | -------------------------------------------------------------------------------- /docs/source/development/index.rst: -------------------------------------------------------------------------------- 1 | .. _developer-docs: 2 | 3 | ======================= 4 | Developer documentation 5 | ======================= 6 | 7 | The developer documentation contains guidlines for how to 8 | stay up-to-date on Corrfunc development, submit bug reports and 9 | contribute to the Corrfunc code base. 10 | 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | citing_corrfunc 16 | contributors 17 | bug_reports 18 | staying_up_to_date 19 | contributing 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/source/development/staying_up_to_date.rst: -------------------------------------------------------------------------------- 1 | .. _staying_up_to_date: 2 | 3 | ************************* 4 | Staying Up to Date 5 | ************************* 6 | 7 | If you would like to receive notifications of new code releases, sign up for the google group 8 | 9 | https://groups.google.com/forum/#!forum/Corrfunc 10 | 11 | Feel free to ask questions about the code on the group. However, note that all 12 | exchanges on the groups are subject to `Astropy Community Code of Conduct `_, 13 | which is basically, "Be nice!". If you are unsure about some technical aspect 14 | of the code, then feel free to email the author (`Manodeep Sinha 15 | `_). 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | |corrfunc logo| 2 | 3 | ======================= 4 | Corrfunc Documentation 5 | ======================= 6 | 7 | Corrfunc is a set of high-performance routines to measure clustering statistics. 8 | The main features of Corrfunc are: 9 | 10 | * **Fast** All theory pair-counting is at least an order of magnitude faster than all existing public codes. Particularly suited for MCMC. 11 | * **OpenMP Parallel** All pair-counting codes can be done in parallel (with strong scaling efficiency >~ 95% up to 10 cores) 12 | * **Python Extensions** Python extensions allow you to do the compute-heavy bits using C while retaining all of the user-friendliness of python. 13 | * **Modular** The code is written in a modular fashion and is easily extensible to compute arbitrary clustering statistics. 14 | * **Future-proof** As I get access to newer instruction-sets, the codes will 15 | get updated to use the latest and greatest CPU features. 16 | 17 | The source code is publicly available at https://github.com/manodeep/Corrfunc. 18 | 19 | ********************* 20 | Overview of Corrfunc 21 | ********************* 22 | 23 | .. toctree:: 24 | :maxdepth: 1 25 | 26 | install 27 | quickstart 28 | modules/index 29 | development/index 30 | 31 | ********* 32 | Reference 33 | ********* 34 | 35 | .. toctree:: 36 | :maxdepth: 1 37 | 38 | api/modules 39 | 40 | ********************* 41 | License and Credits 42 | ********************* 43 | 44 | .. toctree:: 45 | :maxdepth: 1 46 | 47 | development/contributors 48 | development/citing_corrfunc 49 | 50 | .. |corrfunc logo| image:: corrfunc_logo_320px_240px.png 51 | :width: 160 52 | :alt: Corrfunc logo 53 | -------------------------------------------------------------------------------- /docs/source/install.rst: -------------------------------------------------------------------------------- 1 | .. _step_by_step_install: 2 | 3 | ************************ 4 | Package Installation 5 | ************************ 6 | 7 | To install Corrfunc, you can either use pip or clone the repo from GitHub and build the source code. 8 | Either way, be sure to read the :ref:`Corrfunc_dependencies` section prior to installation. 9 | 10 | Using pip 11 | ==================== 12 | 13 | The simplest way to install the latest release of the code is with pip. Before installation, be sure you have installed the package dependencies described in the :ref:`Corrfunc_dependencies` section 14 | 15 | .. code:: python 16 | 17 | python -m pip install Corrfunc 18 | 19 | This will install the latest official release of the code. 20 | If you want the latest master branch, 21 | you will need to build the code from source following the instructions in the next section. 22 | 23 | Building from source 24 | ==================== 25 | 26 | If you don't install the latest release using pip, 27 | you can instead clone the cource code and call the setup file. 28 | Before installation, be sure you have installed the package dependencies 29 | described in the :ref:`corrfunc_dependencies` section. 30 | The first step is to clone the Corrfunc repository 31 | 32 | .. code:: 33 | 34 | git clone https://github.com/manodeep/Corrfunc.git 35 | cd Corrfunc 36 | make install 37 | python -m pip install . (--user) 38 | 39 | 40 | .. _corrfunc_dependencies: 41 | 42 | Dependencies 43 | ============ 44 | 45 | The command-line version of Corrfunc needs the following packages to be installed: 46 | 47 | - `make `_: 3.80 or later 48 | - `C compiler `_: gcc >=4.6, clang, icc. Multi-threading 49 | will be disabled if the compiler does not support OpenMP. 50 | - `gsl `_: any recent version 51 | 52 | 53 | If you plan to use the C extensions, then the following are required: 54 | 55 | - `Python `_: 2.7 or later 56 | - `Numpy `_: 1.7 or later 57 | 58 | Any of the above can be installed with either pip or conda. 59 | 60 | Google Colab Dependency Installation 61 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 | 63 | The following command has been known to work to instal GSL in Google Colab. 64 | GSL is usually the missing dependency that causes Colab installations to fail. 65 | 66 | .. code:: console 67 | 68 | !apt install libgsl-dev 69 | 70 | .. _verifying_your_installation: 71 | 72 | Verifying your installation 73 | ============================== 74 | 75 | After installing Corrfunc, you should run the integrated test suite to make 76 | sure that the package was installed correctly. If you installed from source, 77 | then run the following sequence from the repository root directory: 78 | 79 | .. code:: console 80 | 81 | make tests # run the C tests 82 | python -m pip install pytest 83 | python -m pytest # run the Python tests 84 | 85 | If you installed using pip/conda, then use the following to run the tests 86 | from your shell: 87 | 88 | .. code:: console 89 | 90 | python -m pytest --pyargs Corrfunc 91 | 92 | 93 | Once you have installed the package, see :ref:`quickstart` for instructions on how to get up and running. 94 | -------------------------------------------------------------------------------- /docs/source/modules/computing_wp_and_xi.rst: -------------------------------------------------------------------------------- 1 | .. _computing_wp_and_xi: 2 | 3 | Directly Computing :math:`\xi(r)` and :math:`wp(rp)` 4 | ==================================================== 5 | 6 | For a periodic cosmological box, the 3-d auto correlation, :math:`\xi(r)`, and 7 | the projected auto correlation function, :math:`wp(rp)`, can be directly computed 8 | using the Natural Estimator. The relevant python wrappers are present in 9 | :py:mod:`Corrfunc.theory.xi` and :py:mod:`Corrfunc.theory.wp`. See :ref:`rr_autocorrelations` 10 | for details on how the Natural Estimator is computed. 11 | 12 | .. code-block:: python 13 | 14 | >>> import numpy as np 15 | >>> from Corrfunc.theory.wp import wp 16 | >>> from Corrfunc.theory.xi import xi 17 | >>> from Corrfunc.io import read_catalog 18 | >>> X, Y, Z = read_catalog() 19 | >>> boxsize = 420.0 20 | >>> nthreads = 2 21 | >>> pimax = 40.0 22 | >>> nbins = 10 23 | >>> bins = np.linspace(0.1, 10.0, nbins + 1) # Note the + 1 to nbins 24 | >>> wp_counts = wp(boxsize, pimax, nthreads, bins, X, Y, Z) 25 | >>> xi_counts = xi(boxsize, nthreads, bins, X, Y, Z) 26 | 27 | 28 | See the complete reference here :py:mod:`Corrfunc`. 29 | -------------------------------------------------------------------------------- /docs/source/modules/converting_3d_counts.rst: -------------------------------------------------------------------------------- 1 | .. _converting_3d_counts: 2 | 3 | Converting 3D pair counts into a correlation function 4 | ====================================================== 5 | 6 | 3D pair counts can be converted into a correlation function 7 | by using the helper function :py:mod:`Corrfunc.utils.convert_3d_counts_to_cf`. 8 | First, we have to compute the relevant pair counts using the python 9 | wrapper :py:mod:`Corrfunc.theory.DD` 10 | 11 | .. code-block:: python 12 | 13 | >>> import numpy as np 14 | >>> from os.path import dirname, abspath, join as pjoin 15 | >>> from Corrfunc.theory.DD import DD 16 | >>> from Corrfunc.io import read_catalog 17 | >>> from Corrfunc.utils import convert_3d_counts_to_cf 18 | 19 | >>> # Read the supplied galaxies on a periodic box 20 | >>> X, Y, Z = read_catalog() 21 | >>> N = len(X) 22 | >>> boxsize = 420.0 23 | >>> nthreads = 2 24 | 25 | # Generate randoms on the box 26 | >>> rand_N = 3*N 27 | >>> rand_X = np.random.uniform(0, boxsize, rand_N) 28 | >>> rand_Y = np.random.uniform(0, boxsize, rand_N) 29 | >>> rand_Z = np.random.uniform(0, boxsize, rand_N) 30 | 31 | # Setup the bins 32 | >>> nbins = 10 33 | >>> bins = np.linspace(0.1, 10.0, nbins + 1) # note that +1 to nbins 34 | 35 | # Auto pair counts in DD 36 | >>> autocorr=1 37 | >>> DD_counts = DD(autocorr, nthreads, bins, X, Y, Z, 38 | ... periodic=False, verbose=True) 39 | 40 | # Cross pair counts in DR 41 | >>> autocorr=0 42 | >>> DR_counts = DD(autocorr, nthreads, bins, X, Y, Z, 43 | ... X2=rand_X, Y2=rand_Y, Z2=rand_Z, 44 | ... periodic=False, verbose=True) 45 | 46 | # Auto pairs counts in RR 47 | >>> autocorr=1 48 | >>> RR_counts = DD(autocorr, nthreads, bins, rand_X, rand_Y, rand_Z, 49 | ... periodic=False, verbose=True) 50 | 51 | # All the pair counts are done, get the correlation function 52 | >>> cf = convert_3d_counts_to_cf(N, N, rand_N, rand_N, 53 | ... DD_counts, DR_counts, 54 | ... DR_counts, RR_counts) 55 | 56 | See the complete reference here :py:mod:`Corrfunc`. 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/source/modules/converting_ddtheta_mocks.rst: -------------------------------------------------------------------------------- 1 | .. _converting_ddtheta_mocks: 2 | 3 | Calculating the angular correlation function, :math:`\omega(\theta)` 4 | ==================================================================== 5 | 6 | Angular pair counts can be converted into a :math:`\omega(\theta)` 7 | by using the helper function :py:mod:`Corrfunc.utils.convert_3d_counts_to_cf`. 8 | First, we have to compute the relevant pair counts using the python 9 | wrapper :py:mod:`Corrfunc.mocks.DDtheta_mocks` 10 | 11 | 12 | .. code-block:: python 13 | 14 | >>> from os.path import dirname, abspath, join as pjoin 15 | >>> import numpy as np 16 | >>> import Corrfunc 17 | >>> from Corrfunc.mocks.DDtheta_mocks import DDtheta_mocks 18 | >>> from Corrfunc.io import read_catalog 19 | >>> from Corrfunc.utils import convert_3d_counts_to_cf 20 | 21 | >>> galaxy_catalog=pjoin(dirname(abspath(Corrfunc.__file__)), 22 | ... "../mocks/tests/data", 23 | ... "Mr19_mock_northonly.rdcz.ff") 24 | 25 | # Read the supplied galaxies on a periodic box 26 | >>> RA, DEC, _ = read_catalog(galaxy_catalog) 27 | 28 | # Read the supplied randoms catalog 29 | >>> random_catalog=pjoin(dirname(abspath(Corrfunc.__file__)), 30 | ... "../mocks/tests/data", "Mr19_randoms_northonly.rdcz.ff") 31 | >>> rand_RA, rand_DEC, _ = read_catalog(random_catalog) 32 | >>> rand_N = len(rand_RA) 33 | 34 | # Setup the bins 35 | >>> nbins = 10 36 | >>> bins = np.linspace(0.1, 10.0, nbins + 1) # note the +1 to nbins 37 | 38 | # Number of threads to use 39 | >>> nthreads = 2 40 | 41 | # Auto pair counts in DD 42 | >>> autocorr=1 43 | >>> DD_counts = DDtheta_mocks(autocorr, nthreads, bins, 44 | ... RA, DEC) 45 | 46 | # Cross pair counts in DR 47 | >>> autocorr=0 48 | >>> DR_counts = DDtheta_mocks(autocorr, nthreads, bins, 49 | ... RA, DEC, 50 | ... RA2=rand_RA, DEC2=rand_DEC) 51 | 52 | # Auto pairs counts in RR 53 | >>> autocorr=1 54 | >>> RR_counts = DDtheta_mocks(autocorr, nthreads, bins, 55 | ... rand_RA, rand_DEC) 56 | 57 | # All the pair counts are done, get the angular correlation function 58 | >>> wtheta = convert_3d_counts_to_cf(N, N, rand_N, rand_N, 59 | ... DD_counts, DR_counts, 60 | ... DR_counts, RR_counts) 61 | 62 | See the complete reference here :py:mod:`Corrfunc`. 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /docs/source/modules/converting_rp_pi_counts.rst: -------------------------------------------------------------------------------- 1 | .. _converting_rp_pi_counts: 2 | 3 | Converting :math:`(r_p, \pi)` pairs into a projected correlation function 4 | ========================================================================== 5 | 6 | Pair counts in :math:`(r_p, \pi)` can be converted into a projected correlation function 7 | by using the helper function :py:mod:`Corrfunc.utils.convert_rp_pi_counts_to_wp`. 8 | 9 | .. code-block:: python 10 | 11 | >>> import numpy as np 12 | >>> from Corrfunc.theory import DDrppi 13 | >>> from Corrfunc.io import read_catalog 14 | >>> from Corrfunc.utils import convert_rp_pi_counts_to_wp 15 | 16 | # Read the supplied galaxies on a periodic box 17 | >>> X, Y, Z = read_catalog() 18 | >>> N = len(X) 19 | >>> boxsize = 420.0 20 | 21 | # Generate randoms on the box 22 | >>> rand_N = 3*N 23 | >>> rand_X = np.random.uniform(0, boxsize, rand_N) 24 | >>> rand_Y = np.random.uniform(0, boxsize, rand_N) 25 | >>> rand_Z = np.random.uniform(0, boxsize, rand_N) 26 | >>> nthreads = 2 27 | >>> pimax = 40.0 28 | 29 | # Setup the bins 30 | >>> nrpbins = 10 31 | >>> bins = np.linspace(0.1, 10.0, nrpbins + 1) 32 | 33 | # Auto pair counts in DD 34 | >>> autocorr=1 35 | >>> DD_counts = DDrppi(autocorr, nthreads, pimax, bins, X, Y, Z, 36 | ... periodic=False, verbose=True) 37 | 38 | # Cross pair counts in DR 39 | >>> autocorr=0 40 | >>> DR_counts = DDrppi(autocorr, nthreads, pimax, bins, X, Y, Z, 41 | ... X2=rand_X, Y2=rand_Y, Z2=rand_Z, 42 | ... periodic=False, verbose=True) 43 | 44 | # Auto pairs counts in RR 45 | >>> autocorr=1 46 | >>> RR_counts = DDrppi(autocorr, nthreads, pimax, bins, rand_X, rand_Y, rand_Z, 47 | ... periodic=False, verbose=True) 48 | 49 | # All the pair counts are done, get the correlation function 50 | >>> wp = convert_rp_pi_counts_to_wp(N, N, rand_N, rand_N, 51 | ... DD_counts, DR_counts, 52 | ... DR_counts, RR_counts, nrpbins, pimax) 53 | 54 | See the complete reference here :py:mod:`Corrfunc`. 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/source/modules/converting_rp_pi_mocks.rst: -------------------------------------------------------------------------------- 1 | .. _converting_rp_pi_mocks: 2 | 3 | Calculating the projected correlation function, :math:`wp(rp)` 4 | ============================================================== 5 | 6 | 2-D Pair counts can be converted into a :math:`wp(rp)` 7 | by using the helper function :py:mod:`Corrfunc.utils.convert_rp_pi_counts_to_wp`. 8 | First, we have to compute the relevant pair counts using the python 9 | wrapper :py:mod:`Corrfunc.mocks.DDrppi_mocks` 10 | 11 | .. code-block:: python 12 | 13 | >>> import numpy as np 14 | >>> from os.path import dirname, abspath, join as pjoin 15 | >>> import Corrfunc 16 | >>> from Corrfunc.mocks.DDrppi_mocks import DDrppi_mocks 17 | >>> from Corrfunc.io import read_catalog 18 | >>> from Corrfunc.utils import convert_rp_pi_counts_to_wp 19 | 20 | >>> galaxy_catalog=pjoin(dirname(abspath(Corrfunc.__file__)), 21 | ... "../mocks/tests/data", "Mr19_mock_northonly.rdcz.ff") 22 | 23 | # Read the supplied galaxies on a periodic box 24 | >>> RA, DEC, CZ = read_catalog(galaxy_catalog) 25 | >>> N = len(RA) 26 | 27 | # Read the supplied randoms catalog 28 | >>> random_catalog=pjoin(dirname(abspath(Corrfunc.__file__)), 29 | ... "../mocks/tests/data", "Mr19_randoms_northonly.rdcz.ff") 30 | >>> rand_RA, rand_DEC, rand_CZ = read_catalog(random_catalog) 31 | >>> rand_N = len(rand_RA) 32 | 33 | # Setup the bins 34 | >>> nbins = 10 35 | >>> bins = np.linspace(0.1, 20.0, nbins + 1) 36 | >>> pimax = 40.0 37 | 38 | >>> cosmology = 1 39 | >>> nthreads = 2 40 | 41 | # Auto pair counts in DD 42 | >>> autocorr=1 43 | >>> DD_counts = DDrppi_mocks(autocorr, cosmology, nthreads, pimax, bins, 44 | ... RA, DEC, CZ) 45 | 46 | 47 | # Cross pair counts in DR 48 | >>> autocorr=0 49 | >>> DR_counts = DDrppi_mocks(autocorr, cosmology, nthreads, pimax, bins, 50 | ... RA, DEC, CZ, 51 | ... RA2=rand_RA, DEC2=rand_DEC, CZ2=rand_CZ) 52 | 53 | 54 | # Auto pairs counts in RR 55 | >>> autocorr=1 56 | >>> RR_counts = DDrppi_mocks(autocorr, cosmology, nthreads, pimax, bins, 57 | ... rand_RA, rand_DEC, rand_CZ) 58 | 59 | # All the pair counts are done, get the angular correlation function 60 | >>> wp = convert_rp_pi_counts_to_wp(N, N, rand_N, rand_N, 61 | ... DD_counts, DR_counts, 62 | ... DR_counts, RR_counts, nbins, pimax) 63 | 64 | See the complete reference here :py:mod:`Corrfunc`. 65 | 66 | 67 | -------------------------------------------------------------------------------- /docs/source/modules/fast_food_binary.rst: -------------------------------------------------------------------------------- 1 | .. _fast_food_binary: 2 | 3 | ************************ 4 | Fast-food binary format 5 | ************************ 6 | 7 | The fast-food format is a fortran binary format -- all fields are surrounded 8 | with 4 bytes padding. These value of these padding bytes 9 | is the number of bytes of data contained in between the padding bytes. For 10 | example, to write out ``20 bytes of data`` in 11 | a fast-food file format would require a total of ``4+20+4=28`` bytes. The first 12 | and last 4 bytes of the file will contain the value 20 -- 13 | showing that 20 bytes of real data are contained in between the two paddings. 14 | 15 | The ``fast-food`` file consists of a header: 16 | 17 | .. code:: C 18 | 19 | int idat[5]; 20 | float fdat[9]; 21 | float znow; 22 | 23 | For the purposes of these correlation function codes, the only useful quantity 24 | is ``idat[1]`` which contains ``N`` -- the number of particles 25 | in the file. The rest can simply filled with `0`. 26 | 27 | After this header, the actual ``X/Y/Z`` values are stored. The first 4 28 | bytes after the header contains ``4*N`` for float precision or 29 | ``8*N`` for double precision where ``N=idat[1]``, is the number 30 | of particles in the file. After all of the ``X`` values there will 31 | be another 4 bytes containing ``4*N`` or ``8*N``. 32 | 33 | .. note:: Even when the ``X/Y/Z`` arrays are written out in double-precision, the padding is still 4 bytes. 34 | The blocks for ``Y/Z`` similarly follow after the ``X`` block. 35 | -------------------------------------------------------------------------------- /docs/source/modules/generate_bins.rst: -------------------------------------------------------------------------------- 1 | .. _generate_bins: 2 | 3 | ******************************************* 4 | Specifying the separation bins in Corrfunc 5 | ******************************************* 6 | 7 | All of the python extensions for `Corrfunc` accept 8 | either a filename or an array for specifying the 9 | :math:`r_p` or :math:`\theta`. 10 | 11 | Manually creating a file with arbitrary bins 12 | -------------------------------------------- 13 | This manual method lets you specify generic bins 14 | as long as the upper-edge of one bin is the 15 | same as the lower-edge of the next (i.e., continuous bins). The 16 | bins themselves can have arbitrary widths, and the 17 | smallest bin can start from 0.0. 18 | 19 | * Open a text editor with a new file 20 | * Add two columns per bin you want, the first 21 | column should be low-edge of the bin while 22 | the second column should be the high-edge 23 | of the bin. Like so: 24 | 25 | :: 26 | 27 | 0.10 0.15 28 | 29 | * Now add as many such lines as the number of bins you 30 | want. Here is a valid example: 31 | 32 | :: 33 | 34 | 0.10 0.15 35 | 0.15 0.50 36 | 0.50 5.00 37 | 38 | This example specifies 3 bins, with the individual 39 | bin limits specified on each line. Notice that the 40 | width of each bin can be independently specified (but 41 | the bins **do** have to be continuous) 42 | 43 | .. note:: Make sure that the bins are in increasing order -- smallest bin first, then the next smallest 44 | bin and so on up to the largest bin. 45 | 46 | Specifying bins as an array 47 | --------------------------- 48 | 49 | You can specify the bins using ``numpy.linspace`` or 50 | ``numpy.logspace``. 51 | 52 | .. code:: python 53 | 54 | import numpy as np 55 | rmin = 0.1 56 | rmax = 10.0 57 | nbins = 20 58 | rbins = np.linspace(rmin, rmax, nbins + 1) 59 | log_rbins = np.logspace(np.log10(rmin), np.log10(rmax), nbins + 1) 60 | -------------------------------------------------------------------------------- /docs/source/modules/index.rst: -------------------------------------------------------------------------------- 1 | .. _function_usage_examples: 2 | 3 | ************************************************** 4 | Typical Tasks for Computing Correlation Functions 5 | ************************************************** 6 | 7 | Here we present docstrings of the most commonly used functions and classes 8 | grouped together by functionality. 9 | Many docstrings contain example code to demonstrate basic usage. 10 | For documentation of functions not listed here, see :py:mod:`Corrfunc`. 11 | 12 | Reading input data 13 | ~~~~~~~~~~~~~~~~~~ 14 | 15 | .. toctree:: 16 | :maxdepth: 1 17 | 18 | read_catalog 19 | 20 | Creating a file with bins for the clustering statistics 21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 | 23 | .. toctree:: 24 | :maxdepth: 1 25 | 26 | generate_bins 27 | 28 | Choosing the correlation function 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | .. toctree:: 32 | :maxdepth: 1 33 | 34 | which_corrfunc 35 | 36 | 37 | Calculating Correlation Functions on Simulations 38 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 | 40 | .. toctree:: 41 | :maxdepth: 1 42 | 43 | converting_3d_counts 44 | converting_rp_pi_counts 45 | computing_wp_and_xi 46 | theory_functions 47 | rr_autocorrelations 48 | 49 | Calculating Correlation Functions on Mock Catalogs 50 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 51 | 52 | .. toctree:: 53 | :maxdepth: 1 54 | 55 | converting_rp_pi_mocks 56 | converting_ddtheta_mocks 57 | mock_functions 58 | 59 | Weighted Correlation Functions 60 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 | 62 | .. toctree:: 63 | :maxdepth: 1 64 | 65 | weighted_correlations 66 | custom_weighting 67 | -------------------------------------------------------------------------------- /docs/source/modules/mock_functions.rst: -------------------------------------------------------------------------------- 1 | .. _mock_functions: 2 | 3 | Detailed API for Clustering Statistics on Mock Catalogs 4 | ========================================================= 5 | 6 | All of these can be imported from :py:mod:`Corrfunc.mocks`. See the complete reference here :py:mod:`Corrfunc`.` 7 | 8 | .. currentmodule:: Corrfunc.mocks 9 | 10 | Clustering in 2-D 11 | ------------------- 12 | 13 | * Pair counts (auto or cross) correlations for :math:`\xi(rp, \pi)` -- :py:mod:`Corrfunc.mocks.DDrppi_mocks` 14 | * Pair counts (auto or cross) correlations for :math:`\xi(s, \mu)` -- :py:mod:`Corrfunc.mocks.DDsmu_mocks` 15 | 16 | Angular clustering 17 | -------------------- 18 | 19 | * Pair counts (auto or cross) correlations for :math:`\omega(\theta)` -- :py:mod:`Corrfunc.mocks.DDtheta_mocks` 20 | 21 | 22 | Counts-in-cells 23 | ---------------- 24 | 25 | * Void Probability functions and counts-in-cells stats :math:`pN(r)` -- :py:mod:`Corrfunc.mocks.vpf_mocks` 26 | 27 | -------------------------------------------------------------------------------- /docs/source/modules/read_catalog.rst: -------------------------------------------------------------------------------- 1 | .. _read_catalog: 2 | 3 | ****************************** 4 | Reading Catalogs for Corrfunc 5 | ****************************** 6 | 7 | All of the ``Corrfunc`` routines require some sort of 8 | position arrays, X/Y/Z, as input. These arrays are 9 | expected to be 1-D arrays of type ``np.array``. If 10 | you already have have the required ``numpy`` arrays, 11 | then you can just pass them straight to ``Corrfunc``. 12 | If you need to read the arrays in from disk, then read 13 | on. For the command-line interface, the input files can only 14 | be in ASCII or fast-food format (for description of fast-food 15 | binaries, see :ref:`fast_food_binary`). 16 | 17 | .. toctree:: 18 | :maxdepth: 1 19 | 20 | fast_food_binary 21 | 22 | 23 | Reading from ASCII files 24 | ======================== 25 | 26 | This is the most straight forward way -- you need an ASCII 27 | file with columns X/Y/Z (white-space separated). 28 | 29 | Using ``numpy.genfromtxt`` 30 | --------------------------- 31 | 32 | .. code:: python 33 | 34 | import numpy as np 35 | fname = "myfile_containing_xyz_columns.dat" 36 | 37 | # For double precision calculations 38 | dtype = np.float64 ## change to np.float32 for single precision 39 | 40 | X, Y, Z = np.genfromtxt(fname, dtype=dtype, unpack=True) 41 | 42 | 43 | .. note:: :py:mod:`Corrfunc.read_catalog` uses this exact code-snippet to read in ASCII files in python. 44 | 45 | 46 | Reading from fast-food files 47 | ============================= 48 | 49 | If you are using the command-line interface, then the code will **have** to 50 | read the arrays from files. While ``Corrfunc`` natively supports both 51 | ASCII and fast-food formats (for description of fast-food binaries, see 52 | :ref:`fast_food_binary`), the following python utility is intended to 53 | read both these types of files. 54 | 55 | 56 | Using utility: :py:mod:`Corrfunc.io.read_catalog` 57 | ------------------------------------------------- 58 | 59 | :py:mod:`Corrfunc.io.read_catalog` can directly read ASCII files or fast-food binary 60 | files. 61 | 62 | .. code:: python 63 | 64 | from Corrfunc.io import read_catalog 65 | 66 | # Read the standard theory catalog (on a box) 67 | # supplied with Corrfunc 68 | X, Y, Z = read_catalog() 69 | 70 | # Read some other format -> have to specify 71 | # filename 72 | fname = "myfile_containing_xyz_columns.dat" 73 | X, Y, Z = read_catalog(fname) 74 | -------------------------------------------------------------------------------- /docs/source/modules/theory_functions.rst: -------------------------------------------------------------------------------- 1 | .. _theory_functions: 2 | 3 | Detailed API for Clustering Statistics on Simulations 4 | ======================================================= 5 | 6 | All of these can be imported from :py:mod:`Corrfunc.theory`. See the complete reference here :py:mod:`Corrfunc`. 7 | 8 | .. currentmodule:: Corrfunc.theory 9 | 10 | Clustering in 3-D 11 | ------------------ 12 | 13 | * Pair counts for (auto or cross) correlations for :math:`\xi(r)` -- :py:mod:`Corrfunc.theory.DD` 14 | * Auto-correlation on periodic, cosmological boxes, :math:`\xi(r)`, -- :py:mod:`Corrfunc.theory.xi` 15 | 16 | Clustering in 2-D 17 | ------------------ 18 | 19 | * Pair counts (auto or cross) correlations for :math:`\xi(rp, \pi)` -- :py:mod:`Corrfunc.theory.DDrppi` 20 | * Pair counts (auto or cross) correlations for :math:`\xi(s, \mu)` -- :py:mod:`Corrfunc.theory.DDsmu` 21 | * Projected auto-correlation function, :math:`wp(rp)` -- :py:mod:`Corrfunc.theory.wp` 22 | 23 | Counts-in-cells 24 | ---------------- 25 | 26 | * Void Probability functions and counts-in-cells stats :math:`pN(r)` -- :py:mod:`Corrfunc.theory.vpf` 27 | -------------------------------------------------------------------------------- /docs/source/quickstart.rst: -------------------------------------------------------------------------------- 1 | .. _quickstart: 2 | 3 | ****************************** 4 | Getting started with Corrfunc 5 | ****************************** 6 | 7 | Corrfunc is a set of high-performance routines to measure clustering 8 | statistics. The codes are divided conceptually into two different segments: 9 | 10 | * theory - calculates clustering statistics on **simulation** volumes. Input 11 | positions are expected to be Cartesian X/Y/Z. Periodic boundary conditions 12 | are supported. Relevant C codes are in directory ``theory/`` 13 | 14 | * mocks - calculates clustering statistics on **observation** volumes. Input 15 | positions are assumed to be in obverser frame, ``Right Ascension``, ``Declination`` 16 | and ``SpeedofLight*Redshift`` (where required; :math:`\omega(\theta)` 17 | only needs ``RA`` and ``DEC``). Relevant C codes are in directory ``mocks/`` 18 | 19 | This getting-started guide assumes you have already followed the 20 | :ref:`step_by_step_install` section of the documentation to get the package 21 | and its dependencies set up on your machine. 22 | 23 | If you want to compute correlation functions and have installed the python 24 | extensions, then see :ref:`function_usage_examples` for typical 25 | tasks. Otherwise, read on for the various interfaces available within Corrfunc. 26 | 27 | 28 | Computing Clustering Statistics with Corrfunc 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | Corrfunc supports three separate mechanisms to compute the clustering statistics: 32 | 33 | * **Via python** (if you have ``python`` and ``numpy`` installed) 34 | 35 | Pros: Fully flexible API to modulate code behaviour at runtime. For instance, 36 | calculations can be performed in double-precision simply by passing arrays of 37 | doubles (rather than floats). 38 | 39 | Cons: Has fixed python overhead. For low particle numbers, can be as much as 40 | 20% slower compared to the command-line executables. 41 | 42 | See :ref:`python-interface` for details on how to use the python interface. 43 | 44 | * **Via static libraries directly in C codes** 45 | 46 | Pros: Fully flexible API to modulate code behaviour at runtime. All features supported by the python extensions are also supported here. 47 | 48 | Cons: Requires coding in C. See example C codes invoking the ``theory`` and 49 | ``mocks`` in the directories: ``theory/examples/run_correlations.c`` and ``mocks/examples/run_correlations_mocks.c``. 50 | 51 | See :ref:`staticlibrary-interface` for details on how to use the static library interface. 52 | 53 | * **Command-line executables** 54 | 55 | Pros: Fastest possible implementations of all clustering statistics 56 | 57 | Cons: API is fixed. Any changes require full re-compilation. 58 | 59 | See :ref:`commandline-interface` for details on how to use the command-line executables. 60 | 61 | Available Corrfunc interfaces 62 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 63 | 64 | .. toctree:: 65 | :maxdepth: 1 66 | 67 | python-interface 68 | staticlibrary-interface 69 | commandline-interface 70 | all-interfaces 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /docs/source/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.16 2 | future 3 | wurlitzer 4 | -------------------------------------------------------------------------------- /io/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := .. 2 | UTILS_DIR := $(ROOT_DIR)/utils 3 | 4 | include $(ROOT_DIR)/common.mk 5 | SRC := ftread.c io.c 6 | OBJS := $(SRC:.c=.o) 7 | INCL := ftread.h io.h $(UTILS_DIR)/utils.h 8 | 9 | all: $(OBJS) $(INCL) $(SRC) Makefile 10 | 11 | %.o: %.c $(INCL) Makefile $(ROOT_DIR)/common.mk 12 | $(CC) $(CFLAGS) -I$(UTILS_DIR) -c $< -o $@ 13 | clean: 14 | $(RM) $(OBJS) 15 | -------------------------------------------------------------------------------- /io/ftread.c: -------------------------------------------------------------------------------- 1 | /* File: ftread.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | /* ftread reads unformatted data that has been written by fortran 10 | or in fortran convention -- i.e. an integer with the number of 11 | bytes in the record, the record data, and another integer with 12 | the number of bytes in the record. ftread does various error 13 | checks, writing a message to stderr and returning a negative 14 | value if an error or warning occurs. The call is identical to 15 | the standard i/o library routine fread. 16 | */ 17 | 18 | #include "ftread.h" 19 | 20 | 21 | int my_ftread(void *ptr,size_t size,size_t nitems,FILE *stream) 22 | { 23 | int err = ftread(ptr,size,nitems,stream); 24 | if(err != 0){ 25 | fprintf(stderr,"ERROR: In %s> Read error in ftread while trying to read nitems = %zu " 26 | "of %zu bytes each\n", __FUNCTION__, nitems, size); 27 | return EXIT_FAILURE; 28 | } 29 | 30 | return EXIT_SUCCESS; 31 | } 32 | 33 | 34 | int ftread(void *ptr,size_t size,size_t nitems,FILE *stream) 35 | { 36 | unsigned int nbyte1, nbyte2; 37 | size_t nitem1 ; 38 | int errno ; 39 | errno = 0 ; 40 | if ( fread(&nbyte1,sizeof(nbyte1),1,stream) != 1 ) { 41 | errno = -10 ; 42 | fprintf(stderr,"read error, file empty ? \n") ; 43 | } 44 | nitem1 = fread(ptr,size,nitems,stream) ; 45 | if ( nitem1 != nitems ) { 46 | errno = -20 ; 47 | fprintf(stderr,"read error, %zu items expected, %zu items read. \n", 48 | nitems,nitem1) ; 49 | } 50 | if ( fread(&nbyte2,sizeof(nbyte2),1,stream) != 1 ) { 51 | errno = -30 ; 52 | fprintf(stderr,"read error, file too short ? \n") ; 53 | } 54 | if ( nbyte1 != nbyte2 ) { 55 | errno = errno - 1 ; 56 | fprintf(stderr,"read warning, byte # do not match, nbyte1 = %u, nbyte2 = %u \n", 57 | nbyte1,nbyte2) ; 58 | } 59 | if ( nbyte1 != size*nitems) { 60 | errno = errno - 2 ; 61 | fprintf(stderr, "read warning, byte # does not match item #, nbyte1 = %u, nitems = %zu \n", 62 | nbyte1,nitems) ; 63 | } 64 | 65 | return(errno) ; 66 | 67 | } 68 | -------------------------------------------------------------------------------- /io/ftread.h: -------------------------------------------------------------------------------- 1 | /* File: ftread.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | int ftread(void *ptr,size_t size,size_t nitems,FILE *stream) __attribute__((warn_unused_result)); 19 | int my_ftread(void *ptr,size_t size,size_t nitems,FILE *stream) __attribute__((warn_unused_result)); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /io/io.h: -------------------------------------------------------------------------------- 1 | /* File: io.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | int64_t read_positions(const char *filename, const char *format, const size_t size, const int num_fields, ...) __attribute__((warn_unused_result)); 17 | int64_t read_columns_into_array(const char *filename, const char *format, const size_t size, const int num_fields, void **data) __attribute__((warn_unused_result)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /mocks.options: -------------------------------------------------------------------------------- 1 | ### Special option for DDrppi_mocks/DDsmu_mocks 2 | OPT += -DOUTPUT_RPAVG ### Enabling this DOES NOT cause too much of a runtime-hit for DDrppi (<= 10% performance hit) 3 | #OPT += -DFAST_DIVIDE=2 ##replaces a divide with approximate reciprocals, followed by 'FAST_DIVIDE' number of Newton-Raphson steps. Trade-off between speed and accuracy; may be slower on newer computers 4 | 5 | OPT += -DENABLE_MIN_SEP_OPT ## Enable optimizations relating to min. separations between cell-pairs (introduced in v2.3) 6 | 7 | OPT += -DCOPY_PARTICLES ## Make a copy of particles positions and weights (doubles the memory required, introduced in v2.3) 8 | 9 | ### Specific options for wtheta (DDtheta_mocks.c) 10 | #OPT += -DOUTPUT_THETAAVG 11 | OPT += -DLINK_IN_DEC 12 | OPT += -DLINK_IN_RA #link_in_dec must be enabled before link_in_ra 13 | #OPT += -DFAST_ACOS ## replaces acos by an 8th order REMEZ polynomial. Results are approximate (max. absolute error 3.6e-9) ~50% boost, but obviously approximate 14 | 15 | #### Floating point precision to use 16 | OPT += -DDOUBLE_PREC 17 | 18 | #### If input distances are already in co-moving (relevant for DDrppi_mocks, DDsmu_mocks and vpf) 19 | #OPT += -DCOMOVING_DIST 20 | -------------------------------------------------------------------------------- /mocks/DDrppi_mocks/countpairs_rp_pi_mocks.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_rp_pi_mocks.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" 16 | #include //for uint64_t 17 | 18 | //define the results structure 19 | typedef struct{ 20 | uint64_t *npairs; 21 | double *rupp; 22 | double *rpavg; 23 | double *weightavg; 24 | double pimax; 25 | int nbin; 26 | int npibin; 27 | } results_countpairs_mocks; 28 | 29 | int countpairs_mocks(const int64_t ND1, void *theta1, void *phi1, void *czD1, 30 | const int64_t ND2, void *theta2, void *phi2, void *czD2, 31 | const int numthreads, 32 | const int autocorr, 33 | const char *binfile, 34 | const double pimax, 35 | const int cosmology, 36 | results_countpairs_mocks *results, 37 | struct config_options *options, struct extra_options *extra); 38 | 39 | void free_results_mocks(results_countpairs_mocks *results); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /mocks/DDrppi_mocks/countpairs_rp_pi_mocks_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_rp_pi_mocks_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for struct config_options 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_rp_pi_mocks.h" //for definition of results_countpairs_mocks 21 | 22 | extern void interrupt_handler_countpairs_rp_pi_mocks_DOUBLE(int signo); 23 | 24 | typedef int (*countpairs_mocks_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, 25 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, 26 | const int same_cell, 27 | const unsigned int fast_divide_and_NR_steps, 28 | const DOUBLE sqr_rpmax, const DOUBLE sqr_rpmin, const int nbin, 29 | const int npibin, const DOUBLE *rupp_sqr, const DOUBLE pimax, 30 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 31 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 32 | DOUBLE *src_rpavg, uint64_t *src_npairs, 33 | DOUBLE *src_weightavg, const weight_method_t weight_method); 34 | 35 | extern countpairs_mocks_func_ptr_DOUBLE countpairs_rp_pi_mocks_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 36 | 37 | extern int countpairs_mocks_DOUBLE(const int64_t ND1, DOUBLE *theta1, DOUBLE *phi1, DOUBLE *czD1, 38 | const int64_t ND2, DOUBLE *theta2, DOUBLE *phi2, DOUBLE *czD2, 39 | const int numthreads, 40 | const int autocorr, 41 | const char *binfile, 42 | const DOUBLE pimax, 43 | const int cosmology, 44 | results_countpairs_mocks *results, 45 | struct config_options *options, struct extra_options *extra); 46 | 47 | extern int check_ra_dec_cz_DOUBLE(const int64_t N, DOUBLE *phi, DOUBLE *theta, DOUBLE *cz, const uint8_t is_comoving_dist); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /mocks/DDsmu_mocks/countpairs_s_mu_mocks.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_s_mu_mocks.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" 16 | #include //for uint64_t 17 | 18 | //define the results structure 19 | typedef struct{ 20 | uint64_t *npairs; 21 | double *supp; 22 | double *savg; 23 | double mu_max; 24 | double mu_min;//not used -> assumed to be 0.0 25 | double *weightavg; 26 | int nsbin; 27 | int nmu_bins; 28 | } results_countpairs_mocks_s_mu; 29 | 30 | int countpairs_mocks_s_mu(const int64_t ND1, void *theta1, void *phi1, void *czD1, 31 | const int64_t ND2, void *theta2, void *phi2, void *czD2, 32 | const int numthreads, 33 | const int autocorr, 34 | const char *sbinfile, 35 | const double mu_max, 36 | const int nmu_bins, 37 | const int cosmology, 38 | results_countpairs_mocks_s_mu *results, 39 | struct config_options *options, 40 | struct extra_options *extra); 41 | 42 | void free_results_mocks_s_mu(results_countpairs_mocks_s_mu *results); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /mocks/DDsmu_mocks/countpairs_s_mu_mocks_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_s_mu_mocks_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for struct config_options 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_s_mu_mocks.h" //for definition of results_countpairs_mocks 21 | 22 | extern void interrupt_handler_countpairs_s_mu_mocks_DOUBLE(int signo); 23 | 24 | typedef int (*countpairs_mocks_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, 25 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, 26 | const int same_cell, 27 | const unsigned int fast_divide_and_NR_steps, 28 | const DOUBLE smax, const DOUBLE smin, const int nsbin, 29 | const int nmu_bins, const DOUBLE *supp_sqr, 30 | const DOUBLE mu_max, 31 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 32 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 33 | DOUBLE *src_savg, uint64_t *src_npairs, 34 | DOUBLE *src_weightavg, const weight_method_t weight_method); 35 | 36 | extern countpairs_mocks_func_ptr_DOUBLE countpairs_s_mu_mocks_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 37 | 38 | extern int countpairs_mocks_s_mu_DOUBLE(const int64_t ND1, DOUBLE *theta1, DOUBLE *phi1, DOUBLE *czD1, 39 | const int64_t ND2, DOUBLE *theta2, DOUBLE *phi2, DOUBLE *czD2, 40 | const int numthreads, 41 | const int autocorr, 42 | const char *sbinfile, 43 | const double mu_max, 44 | const int nmu_bins, 45 | const int cosmology, 46 | results_countpairs_mocks_s_mu *results, 47 | struct config_options *options, struct extra_options *extra); 48 | 49 | extern int check_ra_dec_cz_s_mu_DOUBLE(const int64_t N, DOUBLE *phi, DOUBLE *theta, DOUBLE *cz, const uint8_t is_comoving_dist); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /mocks/DDtheta_mocks/countpairs_theta_mocks.c: -------------------------------------------------------------------------------- 1 | /* File: countpairs_theta_mocks.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "countpairs_theta_mocks.h" //function proto-type for API 14 | #include "countpairs_theta_mocks_impl_double.h"//actual implementations for double 15 | #include "countpairs_theta_mocks_impl_float.h"//actual implementations for float 16 | 17 | void free_results_countpairs_theta(results_countpairs_theta *results) 18 | { 19 | if(results == NULL) 20 | return; 21 | 22 | free(results->theta_upp);results->theta_upp = NULL; 23 | free(results->npairs);results->npairs = NULL; 24 | free(results->theta_avg);results->theta_avg = NULL; 25 | free(results->weightavg);results->weightavg = NULL; 26 | 27 | results->nbin = 0; 28 | } 29 | 30 | 31 | 32 | int countpairs_theta_mocks(const int64_t ND1, void *phi1, void *theta1, 33 | const int64_t ND2, void *phi2, void *theta2, 34 | const int numthreads, 35 | const int autocorr, 36 | const char *binfile, 37 | results_countpairs_theta *results, 38 | struct config_options *options, struct extra_options *extra) 39 | { 40 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 41 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 42 | __FUNCTION__, options->float_type); 43 | return EXIT_FAILURE; 44 | } 45 | 46 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1) != 0) { 47 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 48 | return EXIT_FAILURE; 49 | } 50 | 51 | if(options->float_type == sizeof(float)) { 52 | return countpairs_theta_mocks_float(ND1, (float *) phi1, (float *) theta1, 53 | ND2, (float *) phi2, (float *) theta2, 54 | numthreads, 55 | autocorr, 56 | binfile, 57 | results, 58 | options, 59 | extra); 60 | } else { 61 | return countpairs_theta_mocks_double(ND1, (double *) phi1, (double *) theta1, 62 | ND2, (double *) phi2, (double *) theta2, 63 | numthreads, 64 | autocorr, 65 | binfile, 66 | results, 67 | options, 68 | extra); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /mocks/DDtheta_mocks/countpairs_theta_mocks.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_theta_mocks.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" 16 | #include //for uint64_t 17 | 18 | //define the results structure 19 | typedef struct{ 20 | uint64_t *npairs; 21 | double *theta_upp; 22 | double *theta_avg; 23 | double *weightavg; 24 | int nbin; 25 | } results_countpairs_theta; 26 | 27 | extern int countpairs_theta_mocks(const int64_t ND1, void *phi1, void *theta1, 28 | const int64_t ND2, void *phi2, void *theta2, 29 | const int numthreads, 30 | const int autocorr, 31 | const char *binfile, 32 | results_countpairs_theta *results, 33 | struct config_options *options, struct extra_options *extra); 34 | 35 | extern void free_results_countpairs_theta(results_countpairs_theta *results); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /mocks/DDtheta_mocks/countpairs_theta_mocks_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_theta_mocks_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for struct config_options 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_theta_mocks.h" 21 | 22 | extern void interrupt_handler_wtheta_mocks_DOUBLE(int signo); 23 | 24 | typedef int (*countpairs_theta_mocks_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, 25 | DOUBLE *z0, const weight_struct_DOUBLE *weights0, 26 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, 27 | DOUBLE *z1, const weight_struct_DOUBLE *weights1, 28 | const int same_cell, const int order, 29 | const DOUBLE costhetamax, const DOUBLE costhetamin, const int nthetabin, 30 | const DOUBLE *costheta_upp, 31 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, 32 | const DOUBLE min_zdiff, const DOUBLE closest_icell_xpos, 33 | const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 34 | DOUBLE *src_rpavg, uint64_t *src_npairs, 35 | DOUBLE *src_weightavg, const weight_method_t weight_method); 36 | 37 | extern countpairs_theta_mocks_func_ptr_DOUBLE countpairs_theta_mocks_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 38 | 39 | extern int countpairs_theta_mocks_DOUBLE(const int64_t ND1, DOUBLE *phi1, DOUBLE *theta1, 40 | const int64_t ND2, DOUBLE *phi2, DOUBLE *theta2, 41 | const int numthreads, 42 | const int autocorr, 43 | const char *binfile, 44 | results_countpairs_theta *results, 45 | struct config_options *options, struct extra_options *extra); 46 | 47 | extern int check_ra_dec_DOUBLE(const int64_t N, DOUBLE *phi, DOUBLE *theta); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /mocks/Makefile: -------------------------------------------------------------------------------- 1 | include ../mocks.options ../common.mk 2 | 3 | TARGETS:= DDrppi_mocks DDtheta_mocks DDsmu_mocks vpf_mocks examples 4 | ifneq ($(COMPILE_PYTHON_EXT), 0) 5 | TARGETS += python_bindings 6 | else 7 | $(warning $(ccmagenta) Not compiling C extensions for mocks. Either python or numpy not available $(ccreset)) 8 | endif 9 | 10 | all: $(TARGETS) 11 | 12 | dirs: | ../lib ../bin ../include 13 | 14 | ../lib ../bin ../include: 15 | mkdir -p $@ 16 | 17 | .PHONY: clean celna clena celan $(TARGETS) tests distclean realclean distclena realclena dirs test python_bindings libs all 18 | 19 | DDrppi_mocks DDtheta_mocks vpf_mocks DDsmu_mocks: | dirs 20 | $(MAKE) -C $@ 21 | 22 | examples: libs 23 | $(MAKE) -C examples 24 | 25 | python_bindings: libs 26 | $(MAKE) -C $@ 27 | 28 | distclena realclena distclean:realclean 29 | 30 | realclean: 31 | $(MAKE) clean 32 | for dir in $(TARGETS); do \ 33 | $(MAKE) -C $$dir distclean; \ 34 | done 35 | $(MAKE) -C ../utils clean 36 | $(MAKE) -C ../io clean 37 | 38 | clena celan celna: clean 39 | 40 | clean: 41 | for dir in $(TARGETS); do \ 42 | $(MAKE) -C $$dir clean; \ 43 | done 44 | $(MAKE) -C tests clean 45 | $(MAKE) -C python_bindings clean 46 | 47 | 48 | install: examples | dirs 49 | for dir in $(TARGETS); do \ 50 | $(MAKE) -C $$dir install; \ 51 | done 52 | ifneq ($(COMPILE_PYTHON_EXT), 0) 53 | $(MAKE) -C python_bindings install 54 | endif 55 | 56 | libs: | dirs 57 | for dir in $(TARGETS); do \ 58 | $(MAKE) -C $$dir lib; \ 59 | done 60 | 61 | test: tests 62 | tests: 63 | $(MAKE) -C tests 64 | -------------------------------------------------------------------------------- /mocks/benchmarks/timings_Mr19_mocks_openmp.tex: -------------------------------------------------------------------------------- 1 | 1 & 100 & 100 & 100 & 100 \\ 2 | 2 & 96 & 94 & 97 & 98 \\ 3 | 3 & 91 & 83 & 91 & 92 \\ 4 | 4 & 85 & 78 & 92 & 89 \\ 5 | 5 & 87 & 76 & 86 & 87 \\ 6 | 6 & 89 & 70 & 84 & 77 \\ 7 | 7 & 84 & 68 & 97 & 80 \\ 8 | 8 & 76 & 59 & 95 & 75 \\ 9 | 9 & 72 & 65 & 89 & 75 \\ 10 | 10 & 72 & 57 & 78 & 75 \\ 11 | 11 & 74 & 56 & 77 & 69 \\ 12 | 12 & 70 & 53 & 79 & 69 \\ 13 | 13 & 67 & 47 & 73 & 71 \\ 14 | 14 & 67 & 44 & 78 & 63 \\ 15 | 15 & 62 & 43 & 66 & 61 \\ 16 | 16 & 57 & 44 & 66 & 58 \\ 17 | -------------------------------------------------------------------------------- /mocks/benchmarks/timings_Mr19_mocks_rmax.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/mocks/benchmarks/timings_Mr19_mocks_rmax.pdf -------------------------------------------------------------------------------- /mocks/examples/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := ../.. 2 | UTILS_DIR := $(ROOT_DIR)/utils 3 | IO_DIR := $(ROOT_DIR)/io 4 | INCLUDE_DIR := $(ROOT_DIR)/include 5 | LIB_DIR := $(ROOT_DIR)/lib 6 | DATA_DIR := ../tests/data 7 | 8 | MOCKS_DIR := $(ROOT_DIR)/mocks 9 | DDrppi_mocks_DIR := $(MOCKS_DIR)/DDrppi_mocks 10 | DDsmu_mocks_DIR := $(MOCKS_DIR)/DDsmu_mocks 11 | DDTHETA_mocks_DIR := $(MOCKS_DIR)/DDtheta_mocks 12 | VPF_mocks_DIR := $(MOCKS_DIR)/vpf_mocks 13 | 14 | DDrppi_mocks_LIB := countpairs_rp_pi_mocks 15 | DDsmu_mocks_LIB := countpairs_s_mu_mocks 16 | DDTHETA_mocks_LIB := countpairs_theta_mocks 17 | VPF_mocks_LIB := countspheres_mocks 18 | 19 | GSL_REQUIRED := true 20 | include $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk 21 | 22 | TARGET := run_correlations_mocks 23 | TARGETSRC := $(TARGET).c $(IO_DIR)/ftread.c $(IO_DIR)/io.c $(UTILS_DIR)/utils.c $(UTILS_DIR)/progressbar.c \ 24 | $(UTILS_DIR)/cosmology_params.c 25 | TARGETOBJS := $(TARGETSRC:.c=.o) 26 | C_LIBRARIES := $(DDrppi_mocks_DIR)/lib$(DDrppi_mocks_LIB).a $(DDsmu_mocks_DIR)/lib$(DDsmu_mocks_LIB).a \ 27 | $(DDTHETA_mocks_DIR)/lib$(DDTHETA_mocks_LIB).a $(VPF_mocks_DIR)/lib$(VPF_mocks_LIB).a 28 | INCL := $(DDrppi_mocks_DIR)/$(DDrppi_mocks_LIB).h $(DDsmu_mocks_DIR)/$(DDsmu_mocks_LIB).h \ 29 | $(DDTHETA_mocks_DIR)/$(DDTHETA_mocks_LIB).h $(VPF_mocks_DIR)/$(VPF_mocks_LIB).h \ 30 | $(UTILS_DIR)/defs.h $(IO_DIR)/io.h $(IO_DIR)/ftread.h \ 31 | $(UTILS_DIR)/utils.h $(UTILS_DIR)/gridlink_mocks_impl_double.h $(UTILS_DIR)/gridlink_mocks_impl_float.h \ 32 | $(UTILS_DIR)/function_precision.h $(UTILS_DIR)/cellarray_mocks_double.h $(UTILS_DIR)/cellarray_mocks_float.h \ 33 | $(UTILS_DIR)/progressbar.h $(UTILS_DIR)/cosmology_params.h 34 | 35 | LIBRARY_INCL := -I$(DDrppi_mocks_DIR) -I$(DDsmu_mocks_DIR) -I$(DDTHETA_mocks_DIR) -I$(VPF_mocks_DIR) 36 | 37 | all: $(TARGET) $(TARGETSRC) $(C_LIBRARIES) $(INCL) $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk Makefile 38 | 39 | EXTRA_LINK:= $(GSL_LINK) 40 | EXTRA_INCL:= $(GSL_CFLAGS) $(LIBRARY_INCL) 41 | 42 | $(TARGET):$(C_LIBRARIES) 43 | 44 | $(DDrppi_mocks_DIR)/lib$(DDrppi_mocks_LIB).a: $(DDrppi_mocks_DIR)/*.c $(DDrppi_mocks_DIR)/*.c.src $(DDrppi_mocks_DIR)/*.h.src $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk 45 | $(MAKE) -C $(DDrppi_mocks_DIR) libs 46 | 47 | $(DDsmu_mocks_DIR)/lib$(DDsmu_mocks_LIB).a: $(DDsmu_mocks_DIR)/*.c $(DDsmu_mocks_DIR)/*.c.src $(DDsmu_mocks_DIR)/*.h.src $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk 48 | $(MAKE) -C $(DDsmu_mocks_DIR) libs 49 | 50 | $(DDTHETA_mocks_DIR)/lib$(DDTHETA_mocks_LIB).a: $(DDTHETA_mocks_DIR)/*.c $(DDTHETA_mocks_DIR)/*.c.src $(DDTHETA_mocks_DIR)/*.h.src $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk 51 | $(MAKE) -C $(DDTHETA_mocks_DIR) libs 52 | 53 | $(VPF_mocks_DIR)/lib$(VPF_mocks_LIB).a: $(VPF_mocks_DIR)/*.c $(VPF_mocks_DIR)/*.c.src $(VPF_mocks_DIR)/*.h.src $(ROOT_DIR)/mocks.options $(ROOT_DIR)/common.mk 54 | $(MAKE) -C $(VPF_mocks_DIR) libs 55 | 56 | clean: 57 | $(RM) $(TARGET) $(TARGETOBJS) 58 | $(RM) -R *.dSYM 59 | 60 | distclean:clean 61 | 62 | include $(ROOT_DIR)/rules.mk 63 | -------------------------------------------------------------------------------- /mocks/tests/Mr19_mock_vpf: -------------------------------------------------------------------------------- 1 | 1.00 9.5180e-01 3.7700e-02 7.2000e-03 2.0000e-03 5.0000e-04 4.0000e-04 2 | 2.00 7.7890e-01 1.1310e-01 4.7400e-02 2.4900e-02 1.1700e-02 8.2000e-03 3 | 3.00 5.4480e-01 1.5040e-01 9.5300e-02 5.7200e-02 3.5500e-02 2.7200e-02 4 | 4.00 3.3500e-01 1.4480e-01 1.0140e-01 7.9700e-02 5.5800e-02 5.1200e-02 5 | 5.00 1.8600e-01 1.0890e-01 8.4500e-02 7.3200e-02 6.8400e-02 5.5700e-02 6 | 6.00 9.1800e-02 6.9800e-02 6.0000e-02 5.7300e-02 5.4300e-02 4.8100e-02 7 | 7.00 4.1000e-02 4.2300e-02 3.5400e-02 3.7200e-02 3.5100e-02 3.6900e-02 8 | 8.00 1.8000e-02 2.2100e-02 1.8300e-02 2.1200e-02 2.1900e-02 2.4400e-02 9 | 9.00 5.7000e-03 1.0200e-02 1.0800e-02 1.3400e-02 1.2200e-02 1.1000e-02 10 | 10.00 1.7000e-03 4.5000e-03 3.9000e-03 6.9000e-03 6.7000e-03 7.0000e-03 11 | -------------------------------------------------------------------------------- /mocks/tests/Mr19_mock_wtheta.DD: -------------------------------------------------------------------------------- 1 | 2936 0.01207688 0.01000000 0.01412538 0.25077757 2 | 5062 0.01700963 0.01412538 0.01995262 0.25373562 3 | 8506 0.02417096 0.01995262 0.02818383 0.24530685 4 | 13778 0.03419236 0.02818383 0.03981072 0.25017743 5 | 23048 0.04825636 0.03981072 0.05623413 0.25228183 6 | 38528 0.06819978 0.05623413 0.07943282 0.25036740 7 | 65526 0.09631756 0.07943282 0.11220185 0.24989625 8 | 110272 0.13594077 0.11220185 0.15848932 0.24978269 9 | 187034 0.19202972 0.15848932 0.22387211 0.24962210 10 | 313508 0.27140789 0.22387211 0.31622777 0.24754937 11 | 530662 0.38369529 0.31622777 0.44668359 0.24781683 12 | 930214 0.54220094 0.44668359 0.63095734 0.24893846 13 | 1671728 0.76666682 0.63095734 0.89125094 0.24791310 14 | 3099042 1.08355906 0.89125094 1.25892541 0.24858059 15 | 5828652 1.53089476 1.25892541 1.77827941 0.24875674 16 | 10976410 2.16255637 1.77827941 2.51188643 0.24892780 17 | 20847164 3.05523249 2.51188643 3.54813389 0.24961533 18 | 39328118 4.31455474 3.54813389 5.01187234 0.24914003 19 | 74387848 6.09658625 5.01187234 7.07945784 0.24928205 20 | 139896124 8.60669794 7.07945784 10.00000000 0.24919054 21 | -------------------------------------------------------------------------------- /mocks/tests/Mr19_mock_wtheta.DR: -------------------------------------------------------------------------------- 1 | 3307 0.01220753 0.01000000 0.01412538 0.25135664 2 | 6771 0.01716219 0.01412538 0.01995262 0.25320638 3 | 13168 0.02433315 0.01995262 0.02818383 0.24634877 4 | 26347 0.03435183 0.02818383 0.03981072 0.24895144 5 | 52265 0.04849492 0.03981072 0.05623413 0.25155925 6 | 104479 0.06850782 0.05623413 0.07943282 0.25036414 7 | 208346 0.09673721 0.07943282 0.11220185 0.24970455 8 | 414103 0.13664325 0.11220185 0.15848932 0.24937376 9 | 823430 0.19303881 0.15848932 0.22387211 0.24937354 10 | 1640735 0.27266049 0.22387211 0.31622777 0.24964666 11 | 3266620 0.38515437 0.31622777 0.44668359 0.24963237 12 | 6497628 0.54402942 0.44668359 0.63095734 0.24975278 13 | 12919972 0.76841558 0.63095734 0.89125094 0.24984140 14 | 25615923 1.08535342 0.89125094 1.25892541 0.24977742 15 | 50765332 1.53307352 1.25892541 1.77827941 0.24988538 16 | 100260834 2.16530063 1.77827941 2.51188643 0.24982727 17 | 197415967 3.05824647 2.51188643 3.54813389 0.24974025 18 | 386523595 4.31917829 3.54813389 5.01187234 0.24973802 19 | 750988843 6.09907090 5.01187234 7.07945784 0.24970810 20 | 1437638129 8.61111329 7.07945784 10.00000000 0.24960908 21 | -------------------------------------------------------------------------------- /mocks/tests/Mr19_randoms_vpf: -------------------------------------------------------------------------------- 1 | 1.00 0.0000e+00 4.9450e-01 3.4920e-01 1.2240e-01 2.9000e-02 4.0000e-03 2 | 2.00 0.0000e+00 3.0000e-03 2.4300e-02 6.1900e-02 1.1350e-01 1.5540e-01 3 | 3.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 2.0000e-04 4 | 4.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 5 | 5.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 6 | 6.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 7 | 7.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 8 | 8.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 9 | 9.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 10 | 10.00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 11 | -------------------------------------------------------------------------------- /mocks/tests/angular_bins: -------------------------------------------------------------------------------- 1 | 0.010000000000 0.014125375446 2 | 0.014125375446 0.019952623150 3 | 0.019952623150 0.028183829313 4 | 0.028183829313 0.039810717055 5 | 0.039810717055 0.056234132519 6 | 0.056234132519 0.079432823472 7 | 0.079432823472 0.112201845430 8 | 0.112201845430 0.158489319246 9 | 0.158489319246 0.223872113857 10 | 0.223872113857 0.316227766017 11 | 0.316227766017 0.446683592151 12 | 0.446683592151 0.630957344480 13 | 0.630957344480 0.891250938134 14 | 0.891250938134 1.258925411794 15 | 1.258925411794 1.778279410039 16 | 1.778279410039 2.511886431510 17 | 2.511886431510 3.548133892336 18 | 3.548133892336 5.011872336273 19 | 5.011872336273 7.079457843841 20 | 7.079457843841 10.000000000000 21 | -------------------------------------------------------------------------------- /mocks/tests/bins: -------------------------------------------------------------------------------- 1 | 0.100000000000 0.148347908994 2 | 0.148347908994 0.220071021028 3 | 0.220071021028 0.326470757996 4 | 0.326470757996 0.484312542963 5 | 0.484312542963 0.718467530481 6 | 0.718467530481 1.065831558267 7 | 1.065831558267 1.581138830084 8 | 1.581138830084 2.345586392718 9 | 2.345586392718 3.479628367238 10 | 3.479628367238 5.161955923550 11 | 5.161955923550 7.657653675764 12 | 7.657653675764 11.359969105977 13 | 11.359969105977 16.852276631050 14 | 16.852276631050 25.000000000000 15 | -------------------------------------------------------------------------------- /mocks/tests/data/Mr19_mock_northonly.rdcz.ff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/mocks/tests/data/Mr19_mock_northonly.rdcz.ff -------------------------------------------------------------------------------- /mocks/tests/data/Mr19_randoms_northonly.rdcz.ff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/mocks/tests/data/Mr19_randoms_northonly.rdcz.ff -------------------------------------------------------------------------------- /mocks/vpf_mocks/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR:=../.. 2 | INSTALL_HEADERS_DIR := $(ROOT_DIR)/include 3 | INSTALL_LIB_DIR := $(ROOT_DIR)/lib 4 | INSTALL_BIN_DIR := $(ROOT_DIR)/bin 5 | UTILS_DIR:=$(ROOT_DIR)/utils 6 | IO_DIR:=$(ROOT_DIR)/io 7 | 8 | GSL_REQUIRED := true 9 | include $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 10 | 11 | LIBNAME:=countspheres_mocks 12 | LIBRARY:=lib$(LIBNAME).a 13 | LIBSRC:=countspheres_mocks.c countspheres_mocks_impl_float.c countspheres_mocks_impl_double.c \ 14 | $(UTILS_DIR)/gridlink_impl_float.c $(UTILS_DIR)/gridlink_impl_double.c \ 15 | $(UTILS_DIR)/gridlink_utils_float.c $(UTILS_DIR)/gridlink_utils_double.c \ 16 | $(UTILS_DIR)/utils.c $(UTILS_DIR)/progressbar.c $(UTILS_DIR)/cpu_features.c $(UTILS_DIR)/avx512_calls.c \ 17 | $(UTILS_DIR)/set_cosmo_dist.c $(UTILS_DIR)/cosmology_params.c 18 | LIBRARY_HEADERS := $(LIBNAME).h 19 | 20 | TARGET := vpf_mocks 21 | TARGETSRC := $(TARGET).c $(IO_DIR)/io.c $(IO_DIR)/ftread.c $(LIBSRC) 22 | INCL := $(LIBNAME).h vpf_mocks_kernels.c.src countspheres_mocks_impl.c.src countspheres_mocks_impl.h.src \ 23 | countspheres_mocks_impl_float.h countspheres_mocks_impl_double.h \ 24 | $(UTILS_DIR)/gridlink_impl_float.h $(UTILS_DIR)/gridlink_impl_double.h $(UTILS_DIR)/gridlink_impl.h.src \ 25 | $(UTILS_DIR)/gridlink_utils_float.h $(UTILS_DIR)/gridlink_utils_double.h $(UTILS_DIR)/gridlink_utils.h.src \ 26 | $(UTILS_DIR)/cellarray_float.h $(UTILS_DIR)/cellarray_double.h $(UTILS_DIR)/cellarray.h.src \ 27 | $(IO_DIR)/ftread.h $(IO_DIR)/io.h $(UTILS_DIR)/utils.h $(UTILS_DIR)/function_precision.h \ 28 | $(UTILS_DIR)/avx512_calls.h $(UTILS_DIR)/avx_calls.h $(UTILS_DIR)/sse_calls.h \ 29 | $(UTILS_DIR)/defs.h $(UTILS_DIR)/set_cosmo_dist.h $(UTILS_DIR)/cosmology_params.h $(UTILS_DIR)/progressbar.h $(UTILS_DIR)/cpu_features.h 30 | 31 | TARGETOBJS := $(TARGETSRC:.c=.o) 32 | LIBOBJS :=$(LIBSRC:.c=.o) 33 | 34 | EXTRA_INCL:=$(GSL_CFLAGS) 35 | EXTRA_LINK:=$(GSL_LINK) 36 | 37 | all: $(TARGET) $(TARGETSRC) Makefile $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 38 | 39 | countspheres_mocks_impl_float.o:countspheres_mocks_impl_float.c countspheres_mocks_impl_float.h vpf_mocks_kernels_float.c $(UTILS_DIR)/gridlink_impl_float.h $(UTILS_DIR)/cellarray_float.h $(UTILS_DIR)/gridlink_utils_float.h 40 | countspheres_mocks_impl_double.o:countspheres_mocks_impl_double.c countspheres_mocks_impl_double.h vpf_mocks_kernels_double.c $(UTILS_DIR)/gridlink_impl_double.h $(UTILS_DIR)/cellarray_double.h $(UTILS_DIR)/gridlink_utils_double.h 41 | countspheres_mocks.o: countspheres_mocks.c countspheres_mocks_impl_float.h countspheres_mocks_impl_double.h 42 | 43 | libs: lib 44 | lib: $(LIBRARY) 45 | 46 | install: $(INSTALL_BIN_DIR)/$(TARGET) $(INSTALL_LIB_DIR)/$(LIBRARY) $(INSTALL_HEADERS_DIR)/$(LIBRARY_HEADERS) 47 | 48 | distclean: clean | $(INSTALL_LIB_DIR) $(INSTALL_HEADERS_DIR) $(INSTALL_BIN_DIR) 49 | $(RM) $(INSTALL_LIB_DIR)/$(LIBRARY) 50 | cd $(INSTALL_HEADERS_DIR) && $(RM) $(LIBRARY_HEADERS) 51 | cd $(INSTALL_BIN_DIR) && $(RM) $(TARGET) 52 | 53 | clean: 54 | $(RM) $(TARGET) $(TARGETOBJS) $(LIBRARY) countspheres_mocks_impl_float.[ch] countspheres_mocks_impl_double.[ch] vpf_mocks_kernels_float.c vpf_mocks_kernels_double.c 55 | $(RM) -R vpf_mocks.dSYM 56 | 57 | tests: 58 | $(MAKE) -C ../tests vpf_mocks 59 | 60 | 61 | include $(ROOT_DIR)/rules.mk 62 | -------------------------------------------------------------------------------- /mocks/vpf_mocks/countspheres_mocks.h: -------------------------------------------------------------------------------- 1 | /* File: countspheres_mocks.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h"//for definition of struct config_options 16 | #include //for uint64_t 17 | 18 | 19 | //define the results structure 20 | typedef struct{ 21 | double **pN; 22 | double rmax; 23 | int nbin; 24 | int nc; 25 | int num_pN; 26 | } results_countspheres_mocks; 27 | 28 | extern int countspheres_mocks(const int64_t Ngal, void *xgal, void *ygal, void *zgal, 29 | const int64_t Nran, void * restrict xran, void * restrict yran, void * restrict zran, 30 | const int threshold_neighbors, 31 | const double rmax, const int nbin, const int nc, 32 | const int num_pN, 33 | const char *centers_file, 34 | const int cosmology, 35 | results_countspheres_mocks *results, 36 | struct config_options *options, struct extra_options *extra); 37 | 38 | extern void free_results_countspheres_mocks(results_countspheres_mocks *results); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /mocks/vpf_mocks/countspheres_mocks_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countspheres_mocks_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for definition of struct config_options 17 | #include "countspheres_mocks.h"//for definition of struct results_countspheres_mocks 18 | 19 | extern void interrupt_handler_vpf_mocks_DOUBLE(int signo); 20 | 21 | typedef int (*vpf_mocks_func_ptr_DOUBLE)(const int64_t np, DOUBLE * restrict X, DOUBLE * restrict Y, DOUBLE * restrict Z, 22 | const DOUBLE xc, const DOUBLE yc, const DOUBLE zc, 23 | const DOUBLE rmax, const int nbin, 24 | uint64_t *counts_src_pN); 25 | 26 | extern vpf_mocks_func_ptr_DOUBLE vpf_mocks_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 27 | 28 | 29 | extern int countspheres_mocks_DOUBLE(const int64_t Ngal, DOUBLE *RA, DOUBLE *DEC, DOUBLE *CZ, 30 | const int64_t Nran, DOUBLE * restrict RAND_RA, DOUBLE * restrict RAND_DEC, DOUBLE * restrict RAND_CZ, 31 | const int threshold_neighbors, 32 | const DOUBLE rmax, const int nbin, const int nc, 33 | const int num_pN, 34 | const char *centers_file, 35 | const int cosmology, 36 | results_countspheres_mocks *results, 37 | struct config_options *options, struct extra_options *extra); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /paper/scripts/codes_scaling_numpart.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/codes_scaling_numpart.npz -------------------------------------------------------------------------------- /paper/scripts/codes_scaling_numpart_parallel.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/codes_scaling_numpart_parallel.npz -------------------------------------------------------------------------------- /paper/scripts/cute_box_param.txt: -------------------------------------------------------------------------------- 1 | #input information 2 | data_filename= cute_box_data.dat 3 | num_lines= all 4 | input_format= 0 5 | output_filename= cute_box_out.txt 6 | box_size= 1100. 7 | 8 | #tree stuff 9 | use_tree= 0 10 | max_tree_order= 6 11 | max_tree_nparts= 100 12 | 13 | #irrelevant yet 14 | use_pm= 0 15 | n_grid_side= 256 16 | -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_nthreads.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_nthreads.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_nthreads_stampede_icc15.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_nthreads_stampede_icc15.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_nthreads_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_nthreads_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_numpart.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_numpart.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_numpart_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_numpart_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_rmax.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_rmax.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_rmax_stampede_icc15.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_rmax_stampede_icc15.npz -------------------------------------------------------------------------------- /paper/scripts/mocks_scaling_rmax_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/mocks_scaling_rmax_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/runtimes_bender_icc14.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/runtimes_bender_icc14.npz -------------------------------------------------------------------------------- /paper/scripts/runtimes_stampede_icc15.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/runtimes_stampede_icc15.npz -------------------------------------------------------------------------------- /paper/scripts/swot_config.txt: -------------------------------------------------------------------------------- 1 | # Configuration file for swot 2 | # ---------------------------------------------------------- # 3 | # Input catalogues # 4 | # ---------------------------------------------------------- # 5 | data1 swot_test_data.txt # input data catalogue #1 6 | cols1 1,2,3 # Column ids for data1 7 | #data2 swot_test_data.txt # input data catalogue #2 8 | #cols2 1,2 # Column ids for data2 9 | ran1 swot_test_data.txt # input random catalogue #1 10 | rancols1 1,2,3 # Column ids for ran1 11 | #ran2 swot_test_ran2.txt # input random catalogue #2 12 | #rancols2 1,2 # Column ids for ran2 13 | fits no # input files in fits format? [auto,yes,no(ascii)]. 14 | # ---------------------------------------------------------- # 15 | # Correlation options # 16 | # ---------------------------------------------------------- # 17 | corr auto_3D # Type of correlation: 18 | # [auto,cross,gglens,auto_wp,cross_wp,auto_3D,cross_3D,number] 19 | est nat # Estimator [ls,nat,ham,peebles] 20 | range .01,.90 # Correlation range. Dimension same as "proj": 21 | nbins 19 # Number of bins 22 | nbins_pi 100 # Number of bins for pi (for wp) 23 | log no # Logarithmic bins [yes,no] 24 | err jackknife # Resampling method [bootstrap,jackknife,subsample] 25 | # or [bootstrap2D,jackknife2D] 26 | nsub 0 # Number of subvolumes for resampling (power of 2) 27 | nsamples 0 # Number of samples for resampling (= nsub for jackknife) 28 | seed time # random seed for bootstrap 29 | OA no # Open angle for approximation (value or "no") 30 | calib no # Calibration factor [yes,no] (for lensing). Replace e1 by 1+m or c. 31 | RR_in no # file for pre-computed RR pairs (only for clustering) 32 | RR_out no # file for saving RR pairs (only for clustering) 33 | # ---------------------------------------------------------- # 34 | # Cosmology (for gal-gal correlations, w(R) and xi(rp,PI)) # 35 | # ---------------------------------------------------------- # 36 | H0 72 # Hubble parameter 37 | Omega_M 0.258 # Relative matter density 38 | Omega_L 0.742 # Relative energy density (Lambda) 39 | deltaz 0.03 # For gg lensing: Zsource > Zlens + deltaz 40 | pi_max 40 # For wp: limit for pi integration 41 | # ---------------------------------------------------------- # 42 | # Output options # 43 | # ---------------------------------------------------------- # 44 | #proj como # Axis projection [theta, como, phys] 45 | # for auto, cross: default: theta (deg) 46 | # for auto_[3d,wp], cross_[3d,wp], gglens: default: como (Mpc) 47 | out swot_corr.out # Output file in ascii format 48 | cov no # Covariance matrix of errors [yes,no] (in "out".cov) 49 | xi no # xi(rp, pi) for auto_wp [yes,no] (in "out".xi) 50 | printTree no # Output tree in "out".data[1,2]_tree.[ascii,fits] 51 | printTreeAndExit no # Same as above but exits after 52 | printSamples no # Ouput samples in "out".samples 53 | -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_nthreads.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_nthreads.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_nthreads_stampede_icc15.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_nthreads_stampede_icc15.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_nthreads_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_nthreads_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_numpart.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_numpart.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_numpart_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_numpart_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_rmax.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_rmax.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_rmax_stampede_icc15.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_rmax_stampede_icc15.npz -------------------------------------------------------------------------------- /paper/scripts/theory_scaling_rmax_stampede_icc15_after_weights.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/paper/scripts/theory_scaling_rmax_stampede_icc15_after_weights.npz -------------------------------------------------------------------------------- /paper/scripts/utils.py: -------------------------------------------------------------------------------- 1 | def convert_numpy_bytes_to_unicode(runtimes): 2 | ''' 3 | Our old runtime arrays use the S dtype descriptor, which 4 | in Python 3 becomes bytes, making str comparison 5 | more cumbersome. We can just change the dtype of 6 | the string fields to be Unicode. Doing so on 7 | a structured arrays is also cumbersome, hence 8 | this function. 9 | 10 | Our new runtime arrays just use Unicode by default. 11 | ''' 12 | runtimes_descr = runtimes.dtype.descr 13 | runtimes_descr = [list(d) for d in runtimes_descr] 14 | for d in runtimes_descr: 15 | if 'S' in d[1]: 16 | d[1] = d[1].replace('S','U') 17 | runtimes_descr = [tuple(d) for d in runtimes_descr] 18 | runtimes = runtimes.astype(runtimes_descr) 19 | 20 | return runtimes 21 | -------------------------------------------------------------------------------- /paper/tables/timings_Mr19_numpart_theory_simd_speedup.tex: -------------------------------------------------------------------------------- 1 | Nparticles & wp & xi \\ 2 | & avx512f & avx & sse42 & fallback & avx512f & avx & sse42 & fallback \\ 3 | 1235 & 0.8$\times$ & 0.8$\times$ & 0.9$\times$ & 1.0$\times$ & 0.8$\times$ & 0.8$\times$ & 1.0$\times$ & 1.0$\times$ \\ 4 | 6179 & 1.0$\times$ & 0.8$\times$ & 1.0$\times$ & 1.0$\times$ & 0.9$\times$ & 0.9$\times$ & 1.0$\times$ & 1.0$\times$ \\ 5 | 12359 & 0.9$\times$ & 0.9$\times$ & 0.9$\times$ & 1.0$\times$ & 1.0$\times$ & 1.0$\times$ & 1.1$\times$ & 1.0$\times$ \\ 6 | 61795 & 2.7$\times$ & 1.7$\times$ & 1.2$\times$ & 1.0$\times$ & 1.9$\times$ & 1.6$\times$ & 1.1$\times$ & 1.0$\times$ \\ 7 | 123590 & 3.3$\times$ & 2.0$\times$ & 1.3$\times$ & 1.0$\times$ & 2.5$\times$ & 1.9$\times$ & 1.2$\times$ & 1.0$\times$ \\ 8 | 247180 & 3.8$\times$ & 2.2$\times$ & 1.3$\times$ & 1.0$\times$ & 3.1$\times$ & 2.1$\times$ & 1.3$\times$ & 1.0$\times$ \\ 9 | 308976 & 4.0$\times$ & 2.3$\times$ & 1.4$\times$ & 1.0$\times$ & 3.3$\times$ & 2.3$\times$ & 1.4$\times$ & 1.0$\times$ \\ 10 | 494361 & 4.2$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 3.6$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ \\ 11 | 617952 & 4.2$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 3.7$\times$ & 2.4$\times$ & 1.5$\times$ & 1.0$\times$ \\ 12 | 741542 & 4.4$\times$ & 2.5$\times$ & 1.4$\times$ & 1.0$\times$ & 3.9$\times$ & 2.5$\times$ & 1.5$\times$ & 1.0$\times$ \\ 13 | 865132 & 4.3$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 3.9$\times$ & 2.5$\times$ & 1.5$\times$ & 1.0$\times$ \\ 14 | 988723 & 4.4$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 4.0$\times$ & 2.5$\times$ & 1.5$\times$ & 1.0$\times$ \\ 15 | 1112313 & 4.3$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 4.0$\times$ & 2.5$\times$ & 1.5$\times$ & 1.0$\times$ \\ 16 | 1235904 & 4.3$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 4.0$\times$ & 2.5$\times$ & 1.5$\times$ & 1.0$\times$ \\ 17 | -------------------------------------------------------------------------------- /paper/tables/timings_Mr19_openmp_mocks.tex: -------------------------------------------------------------------------------- 1 | Nthreads & DDrppi (DR) & DDtheta (DR) \\ 2 | & avx & sse42 & fallback & avx & sse42 & fallback \\ 3 | 1 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 \\ 4 | 2 & 98.8 & 99.7 & 99.8 & 97.3 & 98.8 & 99.5 \\ 5 | 3 & 98.4 & 99.5 & 99.5 & 95.9 & 97.8 & 99.3 \\ 6 | 4 & 98.7 & 98.9 & 99.2 & 93.9 & 96.6 & 98.5 \\ 7 | 5 & 96.5 & 97.5 & 97.3 & 92.0 & 95.0 & 97.2 \\ 8 | 6 & 94.1 & 96.2 & 96.2 & 90.3 & 94.2 & 96.8 \\ 9 | 7 & 92.9 & 94.7 & 94.6 & 87.9 & 92.6 & 95.6 \\ 10 | 8 & 91.3 & 93.4 & 93.5 & 86.9 & 91.5 & 94.9 \\ 11 | 9 & 90.4 & 92.0 & 91.8 & 84.2 & 89.8 & 93.3 \\ 12 | 10 & 89.5 & 91.2 & 90.8 & 83.2 & 89.3 & 93.4 \\ 13 | 11 & 89.8 & 90.9 & 90.7 & 81.2 & 87.9 & 92.2 \\ 14 | 12 & 88.4 & 90.0 & 90.2 & 79.8 & 86.3 & 90.8 \\ 15 | 13 & 88.0 & 89.4 & 89.2 & 79.0 & 86.1 & 90.7 \\ 16 | 14 & 85.8 & 88.5 & 89.5 & 77.5 & 84.9 & 90.0 \\ 17 | 15 & 83.6 & 85.1 & 86.0 & 75.3 & 83.1 & 88.7 \\ 18 | 16 & 78.4 & 80.9 & 81.8 & 73.8 & 81.9 & 87.2 \\ 19 | 17 & 77.5 & 79.5 & 80.6 & 73.0 & 81.5 & 87.2 \\ 20 | 18 & 76.2 & 77.0 & 77.9 & 71.2 & 80.0 & 86.0 \\ 21 | 19 & 73.4 & 74.6 & 75.5 & 69.3 & 78.5 & 84.4 \\ 22 | 20 & 70.3 & 71.6 & 72.6 & 67.6 & 76.4 & 82.4 \\ 23 | 21 & 67.9 & 69.4 & 70.4 & 66.3 & 75.1 & 81.3 \\ 24 | 22 & 65.7 & 66.8 & 67.7 & 65.1 & 74.1 & 80.3 \\ 25 | 23 & 63.8 & 64.7 & 65.6 & 64.5 & 73.9 & 80.8 \\ 26 | 24 & 61.5 & 62.7 & 63.5 & 63.2 & 72.4 & 79.2 \\ 27 | -------------------------------------------------------------------------------- /paper/tables/timings_Mr19_openmp_theory.tex: -------------------------------------------------------------------------------- 1 | Nthreads & wp & xi \\ 2 | & avx & sse42 & fallback & avx & sse42 & fallback \\ 3 | 1 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 & 100.0 \\ 4 | 2 & 95.2 & 99.5 & 101.7 & 98.4 & 101.7 & 99.4 \\ 5 | 3 & 99.5 & 99.8 & 103.8 & 97.8 & 101.7 & 104.4 \\ 6 | 4 & 97.5 & 99.9 & 104.8 & 97.6 & 103.8 & 100.6 \\ 7 | 5 & 95.1 & 99.2 & 103.7 & 97.1 & 102.8 & 103.4 \\ 8 | 6 & 96.7 & 100.5 & 103.9 & 96.5 & 101.3 & 101.0 \\ 9 | 7 & 95.4 & 99.1 & 103.9 & 97.1 & 102.6 & 100.6 \\ 10 | 8 & 94.3 & 99.8 & 104.8 & 97.0 & 102.3 & 101.0 \\ 11 | 9 & 94.0 & 99.7 & 104.1 & 96.9 & 102.8 & 99.6 \\ 12 | 10 & 95.2 & 99.8 & 104.3 & 96.9 & 102.7 & 101.5 \\ 13 | 11 & 93.9 & 99.7 & 105.2 & 96.8 & 102.3 & 100.5 \\ 14 | 12 & 94.3 & 98.7 & 104.1 & 96.6 & 101.1 & 102.6 \\ 15 | 13 & 94.7 & 98.7 & 104.6 & 96.4 & 100.2 & 101.7 \\ 16 | 14 & 93.4 & 99.9 & 104.6 & 96.1 & 101.7 & 101.9 \\ 17 | 15 & 93.5 & 98.8 & 104.3 & 95.8 & 100.3 & 101.8 \\ 18 | 16 & 93.5 & 98.2 & 103.4 & 95.5 & 99.8 & 100.4 \\ 19 | 17 & 93.5 & 98.1 & 102.7 & 95.3 & 99.6 & 100.5 \\ 20 | 18 & 94.2 & 98.5 & 104.3 & 95.2 & 100.0 & 101.0 \\ 21 | 19 & 93.0 & 98.1 & 104.4 & 95.2 & 99.4 & 100.4 \\ 22 | 20 & 94.2 & 98.0 & 104.5 & 95.2 & 99.4 & 101.9 \\ 23 | 21 & 92.6 & 98.2 & 104.9 & 94.5 & 99.4 & 102.4 \\ 24 | 22 & 92.0 & 98.2 & 104.6 & 94.6 & 99.5 & 101.2 \\ 25 | 23 & 93.5 & 98.1 & 104.0 & 93.9 & 99.3 & 101.1 \\ 26 | 24 & 92.9 & 98.4 & 105.1 & 93.6 & 99.8 & 102.5 \\ 27 | -------------------------------------------------------------------------------- /paper/tables/timings_Mr19_rmax_theory_simd_speedup.tex: -------------------------------------------------------------------------------- 1 | Rmax & wp & xi \\ 2 | & avx512f & avx & sse42 & fallback & avx512f & avx & sse42 & fallback \\ 3 | 10.0 & 1.1$\times$ & 1.0$\times$ & 1.0$\times$ & 1.0$\times$ & 1.0$\times$ & 1.0$\times$ & 0.9$\times$ & 1.0$\times$ \\ 4 | 20.0 & 2.7$\times$ & 1.8$\times$ & 1.3$\times$ & 1.0$\times$ & 2.2$\times$ & 1.8$\times$ & 1.1$\times$ & 1.0$\times$ \\ 5 | 40.0 & 3.0$\times$ & 1.8$\times$ & 1.2$\times$ & 1.0$\times$ & 2.4$\times$ & 1.9$\times$ & 1.2$\times$ & 1.0$\times$ \\ 6 | 80.0 & 3.9$\times$ & 2.3$\times$ & 1.3$\times$ & 1.0$\times$ & 3.6$\times$ & 2.3$\times$ & 1.4$\times$ & 1.0$\times$ \\ 7 | 100.0 & 3.8$\times$ & 2.4$\times$ & 1.4$\times$ & 1.0$\times$ & 3.8$\times$ & 2.4$\times$ & 1.5$\times$ & 1.0$\times$ \\ 8 | -------------------------------------------------------------------------------- /theory.options: -------------------------------------------------------------------------------- 1 | #### Science use-cases for Theory Correlation Functions 2 | OPT = -DPERIODIC 3 | 4 | #OPT += -DOUTPUT_RPAVG ### Enabling this can cause up to a 2x performance hit 5 | #OPT += -DFAST_DIVIDE=2 ##replaces a divide (in DDsmu) with approximate reciprocals, followed by 'FAST_DIVIDE' number of Newton-Raphson steps. Trade-off between speed and accuracy; may be slower on newer computers 6 | 7 | OPT += -DENABLE_MIN_SEP_OPT ## Enable optimizations relating to min. separations between cell-pairs (introduced in v2.3) 8 | 9 | OPT += -DCOPY_PARTICLES ## Make a copy of particles positions and weights (doubles the memory required, introduced in v2.3) 10 | 11 | #### Code specs for both theory and data Correlation Functions 12 | #OPT += -DDOUBLE_PREC 13 | -------------------------------------------------------------------------------- /theory/DD/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := ../.. 2 | 3 | include $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 4 | 5 | INSTALL_HEADERS_DIR := $(ROOT_DIR)/include 6 | INSTALL_LIB_DIR := $(ROOT_DIR)/lib 7 | INSTALL_BIN_DIR := $(ROOT_DIR)/bin 8 | UTILS_DIR := $(ROOT_DIR)/utils 9 | IO_DIR := $(ROOT_DIR)/io 10 | 11 | LIBNAME := countpairs 12 | LIBRARY := lib$(LIBNAME).a 13 | LIBSRC := countpairs.c countpairs_impl_double.c countpairs_impl_float.c \ 14 | $(UTILS_DIR)/gridlink_impl_double.c $(UTILS_DIR)/gridlink_impl_float.c \ 15 | $(UTILS_DIR)/gridlink_utils_double.c $(UTILS_DIR)/gridlink_utils_float.c \ 16 | $(UTILS_DIR)/utils.c $(UTILS_DIR)/progressbar.c $(UTILS_DIR)/cpu_features.c $(UTILS_DIR)/avx512_calls.c 17 | LIBRARY_HEADERS := $(LIBNAME).h 18 | 19 | TARGET := DD 20 | TARGETSRC := DD.c $(IO_DIR)/ftread.c $(IO_DIR)/io.c $(LIBSRC) 21 | INCL := countpairs_kernels_float.c countpairs_kernels_double.c countpairs_kernels.c.src countpairs_impl.c.src countpairs_impl.h.src \ 22 | countpairs.h countpairs_impl_double.h countpairs_impl_float.h \ 23 | $(UTILS_DIR)/gridlink_impl_float.h $(UTILS_DIR)/gridlink_impl_double.h $(UTILS_DIR)/gridlink_impl.h.src \ 24 | $(UTILS_DIR)/gridlink_utils_float.h $(UTILS_DIR)/gridlink_utils_double.h $(UTILS_DIR)/gridlink_utils.h.src \ 25 | $(UTILS_DIR)/cellarray_float.h $(UTILS_DIR)/cellarray_double.h $(UTILS_DIR)/cellarray.h.src \ 26 | $(UTILS_DIR)/cell_pair_float.h $(UTILS_DIR)/cell_pair_double.h $(UTILS_DIR)/cell_pair.h.src \ 27 | $(UTILS_DIR)/function_precision.h $(UTILS_DIR)/avx512_calls.h $(UTILS_DIR)/avx_calls.h $(UTILS_DIR)/sse_calls.h \ 28 | $(UTILS_DIR)/defs.h $(UTILS_DIR)/cpu_features.h \ 29 | $(IO_DIR)/ftread.h $(IO_DIR)/io.h $(UTILS_DIR)/utils.h $(UTILS_DIR)/progressbar.h \ 30 | $(UTILS_DIR)/weight_functions_double.h $(UTILS_DIR)/weight_functions_float.h $(UTILS_DIR)/weight_functions.h.src \ 31 | $(UTILS_DIR)/weight_defs_double.h $(UTILS_DIR)/weight_defs_float.h $(UTILS_DIR)/weight_defs.h.src 32 | 33 | TARGETOBJS := $(TARGETSRC:.c=.o) 34 | LIBOBJS := $(LIBSRC:.c=.o) 35 | 36 | all: $(TARGET) $(LIBOBJS) $(TARGETOBJS) $(TARGETSRC) $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk Makefile 37 | libs: lib 38 | lib: $(LIBRARY) 39 | install: $(INSTALL_BIN_DIR)/$(TARGET) $(INSTALL_LIB_DIR)/$(LIBRARY) $(INSTALL_HEADERS_DIR)/$(LIBRARY_HEADERS) 40 | 41 | countpairs_impl_float.c countpairs_impl_double.c:countpairs_impl.c.src $(INCL) 42 | countpairs_impl_float.o:countpairs_impl_float.c countpairs_impl_float.h countpairs_kernels_float.c \ 43 | $(UTILS_DIR)/gridlink_impl_float.h $(UTILS_DIR)/gridlink_utils_float.h 44 | countpairs_impl_double.o:countpairs_impl_double.c countpairs_impl_double.h countpairs_kernels_double.c \ 45 | $(UTILS_DIR)/gridlink_impl_double.h $(UTILS_DIR)/gridlink_utils_double.h 46 | countpairs.o:countpairs.c countpairs_impl_double.h countpairs_impl_float.h countpairs.h 47 | 48 | clean: 49 | $(RM) $(TARGETOBJS) $(TARGET) $(LIBRARY) countpairs_kernels_float.c countpairs_kernels_double.c countpairs_impl_double.[ch] countpairs_impl_float.[ch] 50 | $(RM) -R *.dSYM 51 | 52 | distclean:clean 53 | cd $(INSTALL_HEADERS_DIR) && $(RM) $(LIBRARY_HEADERS) 54 | cd $(INSTALL_LIB_DIR) && $(RM) $(LIBRARY) 55 | cd $(INSTALL_BIN_DIR) && $(RM) $(TARGET) 56 | 57 | tests: 58 | $(MAKE) -C ../tests DD 59 | 60 | include $(ROOT_DIR)/rules.mk 61 | -------------------------------------------------------------------------------- /theory/DD/countpairs.c: -------------------------------------------------------------------------------- 1 | /* File: countpairs.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "countpairs.h" //function proto-type for API 15 | #include "countpairs_impl_double.h"//actual implementations for double 16 | #include "countpairs_impl_float.h"//actual implementations for float 17 | 18 | 19 | void free_results(results_countpairs *results) 20 | { 21 | if(results == NULL) 22 | return; 23 | 24 | free(results->rupp);results->rupp = NULL; 25 | free(results->npairs);results->npairs = NULL; 26 | free(results->rpavg);results->rpavg = NULL; 27 | free(results->weightavg);results->weightavg = NULL; 28 | 29 | results->nbin = 0; 30 | } 31 | 32 | 33 | 34 | int countpairs(const int64_t ND1, void * restrict X1, void * restrict Y1, void * restrict Z1, 35 | const int64_t ND2, void * restrict X2, void * restrict Y2, void * restrict Z2, 36 | const int numthreads, 37 | const int autocorr, 38 | const char *binfile, 39 | results_countpairs *results, 40 | struct config_options *options, 41 | struct extra_options *extra) 42 | { 43 | 44 | 45 | 46 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 47 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 48 | __FUNCTION__, options->float_type); 49 | return EXIT_FAILURE; 50 | } 51 | 52 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1) != 0) { 53 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 54 | return EXIT_FAILURE; 55 | } 56 | 57 | if(options->float_type == sizeof(float)) { 58 | return countpairs_float(ND1, (float *) X1, (float *) Y1, (float *) Z1, 59 | ND2, (float *) X2, (float *) Y2, (float *) Z2, 60 | numthreads, 61 | autocorr, 62 | binfile, 63 | results, 64 | options, 65 | extra); 66 | } else { 67 | return countpairs_double(ND1, (double *) X1, (double *) Y1, (double *) Z1, 68 | ND2, (double *) X2, (double *) Y2, (double *) Z2, 69 | numthreads, 70 | autocorr, 71 | binfile, 72 | results, 73 | options, 74 | extra); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /theory/DD/countpairs.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | 16 | #include "defs.h"//for struct config_options 17 | #include //for uint64_t 18 | 19 | //define the results structure 20 | typedef struct{ 21 | uint64_t *npairs; 22 | double *rupp; 23 | double *rpavg; 24 | double *weightavg; 25 | int nbin; 26 | } results_countpairs; 27 | 28 | extern int countpairs(const int64_t ND1, void *X1, void *Y1, void *Z1, 29 | const int64_t ND2, void *X2, void *Y2, void *Z2, 30 | const int numthreads, 31 | const int autocorr, 32 | const char *binfile, 33 | results_countpairs *results, 34 | struct config_options *options, 35 | struct extra_options *extra) __attribute__((warn_unused_result)); 36 | 37 | extern void free_results(results_countpairs *results); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /theory/DD/countpairs_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "defs.h" 18 | #include "weight_defs_DOUBLE.h" 19 | #include 20 | 21 | #include "countpairs.h" /* For definition of results_countpairs */ 22 | 23 | extern void interrupt_handler_countpairs_DOUBLE(int signo); 24 | 25 | typedef int (*countpairs_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, 26 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, 27 | const int same_cell, 28 | const DOUBLE sqr_rpmax, const DOUBLE sqr_rpmin, const int nbin, const DOUBLE *rupp_sqr, const DOUBLE rpmax, 29 | const DOUBLE off_xwrap, const DOUBLE off_ywrap, const DOUBLE off_zwrap, 30 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 31 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 32 | DOUBLE *src_rpavg, uint64_t *src_npairs, 33 | DOUBLE *src_weightavg, const weight_method_t weight_method); 34 | 35 | extern countpairs_func_ptr_DOUBLE countpairs_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 36 | 37 | extern int countpairs_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z1, 38 | const int64_t ND2, DOUBLE *X2, DOUBLE *Y2, DOUBLE *Z2, 39 | const int numthreads, 40 | const int autocorr, 41 | const char *binfile, 42 | results_countpairs *results, 43 | struct config_options *options, 44 | struct extra_options *extra); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /theory/DD/xi_of_r_scaling_Mr19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/DD/xi_of_r_scaling_Mr19.png -------------------------------------------------------------------------------- /theory/DDrppi/countpairs_rp_pi.c: -------------------------------------------------------------------------------- 1 | /* File: countpairs_rp_pi.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "countpairs_rp_pi.h" //function proto-type for API 14 | #include "countpairs_rp_pi_impl_double.h"//actual implementations for double 15 | #include "countpairs_rp_pi_impl_float.h"//actual implementations for float 16 | 17 | void free_results_rp_pi(results_countpairs_rp_pi *results) 18 | { 19 | if(results==NULL) 20 | return; 21 | 22 | free(results->rupp);results->rupp = NULL; 23 | free(results->npairs);results->npairs = NULL; 24 | free(results->rpavg);results->rpavg = NULL; 25 | free(results->weightavg);results->weightavg = NULL; 26 | 27 | results->nbin = 0; 28 | results->npibin = 0; 29 | results->pimax = 0.0; 30 | } 31 | 32 | 33 | int countpairs_rp_pi(const int64_t ND1, void *X1, void *Y1, void *Z1, 34 | const int64_t ND2, void *X2, void *Y2, void *Z2, 35 | const int numthreads, 36 | const int autocorr, 37 | const char *binfile, 38 | const double pimax, 39 | results_countpairs_rp_pi *results, 40 | struct config_options *options, 41 | struct extra_options *extra) 42 | { 43 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 44 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 45 | __FUNCTION__, options->float_type); 46 | return EXIT_FAILURE; 47 | } 48 | 49 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1) != 0) { 50 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 51 | return EXIT_FAILURE; 52 | } 53 | 54 | if(options->float_type == sizeof(float)) { 55 | return countpairs_rp_pi_float(ND1, (float *) X1, (float *) Y1, (float *) Z1, 56 | ND2, (float *) X2, (float *) Y2, (float *) Z2, 57 | numthreads, 58 | autocorr, 59 | binfile, 60 | pimax, 61 | results, 62 | options, 63 | extra); 64 | } else { 65 | return countpairs_rp_pi_double(ND1, (double *) X1, (double *) Y1, (double *) Z1, 66 | ND2, (double *) X2, (double *) Y2, (double *) Z2, 67 | numthreads, 68 | autocorr, 69 | binfile, 70 | pimax, 71 | results, 72 | options, 73 | extra); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /theory/DDrppi/countpairs_rp_pi.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_rp_pi.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" //for struct config_options 16 | #include //for uint64_t 17 | 18 | //define the results structure 19 | typedef struct{ 20 | uint64_t *npairs; 21 | double *rupp; 22 | double *rpavg; 23 | double *weightavg; 24 | double pimax; 25 | int nbin; 26 | int npibin; 27 | } results_countpairs_rp_pi; 28 | 29 | extern int countpairs_rp_pi(const int64_t ND1, void *X1, void *Y1, void *Z1, 30 | const int64_t ND2, void *X2, void *Y2, void *Z2, 31 | const int numthreads, 32 | const int autocorr, 33 | const char *binfile, 34 | const double pimax, 35 | results_countpairs_rp_pi *results, 36 | struct config_options *options, 37 | struct extra_options *extra); 38 | 39 | extern void free_results_rp_pi(results_countpairs_rp_pi *results); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /theory/DDrppi/countpairs_rp_pi_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_rp_pi_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for struct config_options 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_rp_pi.h"//for struct results_countpairs_rp_pi 21 | 22 | extern void interrupt_handler_countpairs_rp_pi_DOUBLE(int signo); 23 | 24 | typedef int (*countpairs_rp_pi_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, 25 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, const int same_cell, 26 | const DOUBLE sqr_rpmax, const DOUBLE sqr_rpmin, const int nbin, const int npibin, 27 | const DOUBLE *rupp_sqr, const DOUBLE pimax, 28 | const DOUBLE off_xwrap, const DOUBLE off_ywrap, const DOUBLE off_zwrap, 29 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 30 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 31 | DOUBLE *src_rpavg, uint64_t *src_npairs, 32 | DOUBLE *src_weightavg, const weight_method_t weight_method); 33 | 34 | 35 | extern countpairs_rp_pi_func_ptr_DOUBLE countpairs_rp_pi_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 36 | 37 | extern int countpairs_rp_pi_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z1, 38 | const int64_t ND2, DOUBLE *X2, DOUBLE *Y2, DOUBLE *Z2, 39 | const int numthreads, 40 | const int autocorr, 41 | const char *binfile, 42 | const DOUBLE pimax, 43 | results_countpairs_rp_pi *results, 44 | struct config_options *options, 45 | struct extra_options *extra); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /theory/DDrppi/xi_rp_pi_scaling_Mr19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/DDrppi/xi_rp_pi_scaling_Mr19.png -------------------------------------------------------------------------------- /theory/DDsmu/countpairs_s_mu.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_s_mu.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" //for struct config_options 16 | #include //for uint64_t 17 | 18 | //define the results structure 19 | typedef struct{ 20 | uint64_t *npairs; 21 | double *supp; 22 | double *savg; 23 | double mu_max; 24 | double mu_min;//not used -> assumed to be 0.0 25 | double *weightavg; 26 | int nsbin; 27 | int nmu_bins; 28 | } results_countpairs_s_mu; 29 | 30 | extern int countpairs_s_mu(const int64_t ND1, void *X1, void *Y1, void *Z1, 31 | const int64_t ND2, void *X2, void *Y2, void *Z2, 32 | const int numthreads, 33 | const int autocorr, 34 | const char *sbinfile, 35 | const double mu_max, 36 | const int nmu_bins, 37 | results_countpairs_s_mu *results, 38 | struct config_options *options, 39 | struct extra_options *extra); 40 | 41 | extern void free_results_s_mu(results_countpairs_s_mu *results); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /theory/DDsmu/countpairs_s_mu_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_s_mu_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" //for struct config_options 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_s_mu.h"//for struct results_countpairs_s_mu 21 | 22 | extern void interrupt_handler_countpairs_s_mu_DOUBLE(int signo); 23 | 24 | typedef int (*countpairs_s_mu_func_ptr_DOUBLE)(const int64_t N0, DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, 25 | const int64_t N1, DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, 26 | const int same_cell, 27 | const unsigned int fast_divide_and_NR_steps, 28 | const DOUBLE sqr_smax, const DOUBLE sqr_smin, const int nsbin, const int nmu_bins, 29 | const DOUBLE *supp_sqr, const DOUBLE mu_max, const DOUBLE pimax, 30 | const DOUBLE off_xwrap, const DOUBLE off_ywrap, const DOUBLE off_zwrap, 31 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 32 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 33 | DOUBLE *src_savg, uint64_t *src_npairs, 34 | DOUBLE *src_weightavg, const weight_method_t weight_method); 35 | 36 | 37 | extern countpairs_s_mu_func_ptr_DOUBLE countpairs_s_mu_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 38 | 39 | extern int countpairs_s_mu_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z1, 40 | const int64_t ND2, DOUBLE *X2, DOUBLE *Y2, DOUBLE *Z2, 41 | const int numthreads, 42 | const int autocorr, 43 | const char *sbinfile, 44 | const double mu_max, 45 | const int nmu_bins, 46 | results_countpairs_s_mu *results, 47 | struct config_options *options, 48 | struct extra_options *extra); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /theory/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR:=.. 2 | 3 | include $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 4 | 5 | PYTHON_EXT_DIR:= 6 | ifneq ($(COMPILE_PYTHON_EXT), 0) 7 | PYTHON_EXT_DIR:=python_bindings 8 | else 9 | $(warning $(ccmagenta) Not compiling C extensions for mocks. Either python or numpy not available $(ccreset)) 10 | endif 11 | 12 | TARGETS:=DD DDrppi DDsmu wp xi vpf examples $(PYTHON_EXT_DIR) 13 | 14 | all: $(TARGETS) $(PYTHON_EXT_DIR) logbins 15 | 16 | logbins: logbins.c 17 | $(CC) $(CFLAGS) $< $(CLINK) -o $@ 18 | 19 | .PHONY: $(TARGETS) libs install tests distclean realclean distclena realclena clean celna 20 | 21 | DD DDrppi DDsmu xi wp vpf: 22 | $(MAKE) -C $@ 23 | 24 | python_bindings: libs 25 | $(MAKE) -C $@ 26 | 27 | ### Must create the libraries first before making the examples. 28 | examples: examples/run_correlations 29 | 30 | ## Not a phony target 31 | examples/run_correlations: libs 32 | $(MAKE) -C examples 33 | 34 | distclena distclean realclena:realclean 35 | 36 | realclean: 37 | $(RM) $(ROOT_DIR)/bin/logbins 38 | $(RM) -R *.dSYM 39 | for dir in $(TARGETS); do \ 40 | $(MAKE) -C $$dir distclean; \ 41 | done 42 | $(MAKE) -C python_bindings distclean 43 | $(MAKE) -C tests clean 44 | 45 | celan clena celna: clean 46 | 47 | clean: 48 | $(RM) logbins 49 | $(RM) -R *.dSYM 50 | for dir in $(TARGETS); do \ 51 | $(MAKE) -C $$dir clean; \ 52 | done 53 | $(MAKE) -C python_bindings clean 54 | $(MAKE) -C tests clean 55 | $(MAKE) -C ../io clean 56 | $(MAKE) -C ../utils clean 57 | 58 | install: $(ROOT_DIR)/bin/logbins examples $(TARGETS) $(PYTHON_EXT_DIR) 59 | for dir in $(TARGETS); do \ 60 | $(MAKE) -C $$dir install; \ 61 | done 62 | ifneq ($(COMPILE_PYTHON_EXT), 0) 63 | $(MAKE) -C python_bindings install 64 | endif 65 | 66 | $(ROOT_DIR)/bin/logbins: logbins 67 | cp -p logbins $(ROOT_DIR)/bin 68 | 69 | lib: libs 70 | 71 | libs: 72 | for dir in $(TARGETS); do \ 73 | $(MAKE) -C $$dir lib; \ 74 | done 75 | 76 | test: tests 77 | tests: 78 | $(MAKE) -C tests 79 | 80 | include $(ROOT_DIR)/rules.mk 81 | -------------------------------------------------------------------------------- /theory/README.rst: -------------------------------------------------------------------------------- 1 | Description 2 | ------------ 3 | 4 | This `theory` directory contains a set of codes to measure the following correlation measures in a cosmological box: 5 | 6 | - `DD` Measures auto/cross-correlation pair-counts between two boxes. Can be used to make full 3-d correlation function -- $\xi(r)$ 7 | 8 | - `DDrppi` Measures the auto/cross-correlation pair-counts between two boxes. Can be used to make projected correlation function $\xi(r_p, \pi)$ 9 | 10 | - `wp` Measures the full 2-point projected auto-correlation ($w_p(r_p)$) function in a periodic cosmological box. 11 | 12 | - `xi` Measures the full 2-point 3D auto-correlation function ($\xi(r)$) in a periodic cosmological box. 13 | 14 | - `DDsmu` Measures the auto/cross-correlation pair-counts between two boxes. Can be used to make the $\xi(s, \mu)$ 15 | 16 | - `vpf` Measures the counts-in-cell stats $pN(r)$, where $p0(r)$ is the *Void Probability function* `(vpf)` 17 | -------------------------------------------------------------------------------- /theory/benchmarks/timings_Mr19_numpart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/benchmarks/timings_Mr19_numpart.pdf -------------------------------------------------------------------------------- /theory/benchmarks/timings_Mr19_openmp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/benchmarks/timings_Mr19_openmp.pdf -------------------------------------------------------------------------------- /theory/benchmarks/timings_Mr19_openmp.tex: -------------------------------------------------------------------------------- 1 | 1 & 100 & 100 & 100 & 100 \\ 2 | 2 & 115 & 98 & 98 & 106 \\ 3 | 3 & 113 & 95 & 91 & 102 \\ 4 | 4 & 111 & 96 & 95 & 101 \\ 5 | 5 & 108 & 94 & 93 & 99 \\ 6 | 6 & 106 & 91 & 91 & 96 \\ 7 | 7 & 105 & 90 & 89 & 96 \\ 8 | 8 & 105 & 92 & 88 & 92 \\ 9 | 9 & 101 & 88 & 83 & 91 \\ 10 | 10 & 101 & 84 & 83 & 88 \\ 11 | 11 & 97 & 87 & 67 & 84 \\ 12 | 12 & 96 & 82 & 75 & 87 \\ 13 | 13 & 94 & 84 & 76 & 82 \\ 14 | 14 & 94 & 81 & 77 & 80 \\ 15 | 15 & 91 & 78 & 78 & 78 \\ 16 | 16 & 89 & 83 & 73 & 80 \\ 17 | -------------------------------------------------------------------------------- /theory/benchmarks/timings_Mr19_rmax.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/benchmarks/timings_Mr19_rmax.pdf -------------------------------------------------------------------------------- /theory/bins: -------------------------------------------------------------------------------- 1 | 0.100000000000 0.148347908994 2 | 0.148347908994 0.220071021028 3 | 0.220071021028 0.326470757996 4 | 0.326470757996 0.484312542963 5 | 0.484312542963 0.718467530481 6 | 0.718467530481 1.065831558267 7 | 1.065831558267 1.581138830084 8 | 1.581138830084 2.345586392718 9 | 2.345586392718 3.479628367238 10 | 3.479628367238 5.161955923550 11 | 5.161955923550 7.657653675764 12 | 7.657653675764 11.359969105977 13 | 11.359969105977 16.852276631050 14 | 16.852276631050 25.000000000000 15 | -------------------------------------------------------------------------------- /theory/examples/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := ../.. 2 | UTILS_DIR := $(ROOT_DIR)/utils 3 | IO_DIR := $(ROOT_DIR)/io 4 | INCLUDE_DIR := $(ROOT_DIR)/include 5 | LIB_DIR := $(ROOT_DIR)/lib 6 | DATA_DIR := ../tests/data 7 | 8 | THEORY_DIR := $(ROOT_DIR)/theory 9 | DD_DIR := $(THEORY_DIR)/DD 10 | DDrppi_DIR := $(THEORY_DIR)/DDrppi 11 | DDsmu_DIR := $(THEORY_DIR)/DDsmu 12 | WP_DIR := $(THEORY_DIR)/wp 13 | XI_DIR := $(THEORY_DIR)/xi 14 | VPF_DIR := $(THEORY_DIR)/vpf 15 | 16 | DD_LIB := countpairs 17 | DDrppi_LIB := countpairs_rp_pi 18 | DDsmu_LIB := countpairs_s_mu 19 | WP_LIB := countpairs_wp 20 | XI_LIB := countpairs_xi 21 | VPF_LIB := countspheres 22 | 23 | GSL_REQUIRED := true 24 | include $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 25 | 26 | TARGET := run_correlations 27 | TARGETSRC := run_correlations.c $(IO_DIR)/ftread.c $(IO_DIR)/io.c $(UTILS_DIR)/utils.c $(UTILS_DIR)/progressbar.c 28 | TARGETOBJS := $(TARGETSRC:.c=.o) 29 | C_LIBRARIES := $(DD_DIR)/lib$(DD_LIB).a $(DDrppi_DIR)/lib$(DDrppi_LIB).a $(DDsmu_DIR)/lib$(DDsmu_LIB).a $(WP_DIR)/lib$(WP_LIB).a \ 30 | $(XI_DIR)/lib$(XI_LIB).a $(VPF_DIR)/lib$(VPF_LIB).a 31 | INCL := $(DD_DIR)/$(DD_LIB).h $(DDrppi_DIR)/$(DDrppi_LIB).h $(DDsmu_DIR)/$(DDsmu_LIB).h $(WP_DIR)/$(WP_LIB).h \ 32 | $(XI_DIR)/$(XI_LIB).h $(VPF_DIR)/$(VPF_LIB).h \ 33 | $(UTILS_DIR)/defs.h 34 | 35 | EXTRA_INCL:= -I$(DD_DIR) -I$(DDrppi_DIR) -I$(DDsmu_DIR) -I$(WP_DIR) -I$(XI_DIR) -I$(VPF_DIR) $(GSL_CFLAGS) 36 | EXTRA_LINK:= $(GSL_LINK) 37 | 38 | all: $(TARGET) $(TARGETSRC) $(INCL) $(C_LIBRARY) $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk Makefile uncompress 39 | 40 | $(DD_DIR)/lib$(DD_LIB).a: $(DD_DIR)/*.c $(DD_DIR)/*.c.src $(DD_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 41 | $(MAKE) -C $(DD_DIR) libs 42 | 43 | $(DDrppi_DIR)/lib$(DDrppi_LIB).a: $(DDrppi_DIR)/*.c $(DDrppi_DIR)/*.c.src $(DDrppi_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 44 | $(MAKE) -C $(DDrppi_DIR) libs 45 | 46 | $(DDsmu_DIR)/lib$(DDsmu_LIB).a: $(DDsmu_DIR)/*.c $(DDsmu_DIR)/*.c.src $(DDsmu_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 47 | $(MAKE) -C $(DDsmu_DIR) libs 48 | 49 | $(WP_DIR)/lib$(WP_LIB).a: $(WP_DIR)/*.c $(WP_DIR)/*.c.src $(WP_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 50 | $(MAKE) -C $(WP_DIR) libs 51 | 52 | $(XI_DIR)/lib$(XI_LIB).a: $(XI_DIR)/*.c $(XI_DIR)/*.c.src $(XI_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 53 | $(MAKE) -C $(XI_DIR) libs 54 | 55 | $(VPF_DIR)/lib$(VPF_LIB).a: $(VPF_DIR)/*.c $(VPF_DIR)/*.c.src $(VPF_DIR)/*.h.src $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 56 | $(MAKE) -C $(VPF_DIR) libs 57 | 58 | $(TARGET): $(C_LIBRARIES) $(TARGETOBJS) 59 | 60 | uncompress: | $(DATA_DIR) 61 | @{\ 62 | oldpwd=$$(pwd); \ 63 | cd $(DATA_DIR) ; \ 64 | for f in $$(ls -f *.gz 2>/dev/null) ; do \ 65 | gunzip $$f ; \ 66 | done ;\ 67 | cd $$oldpwd; \ 68 | } 69 | 70 | .PHONY: clean clena celan uncompress 71 | 72 | clena: clean 73 | celan: clean 74 | clean: 75 | $(RM) $(TARGET) $(TARGETOBJS) 76 | $(RM) -R *.dSYM 77 | 78 | include $(ROOT_DIR)/rules.mk 79 | 80 | -------------------------------------------------------------------------------- /theory/logbins.c: -------------------------------------------------------------------------------- 1 | /* File: logbins.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | /* PROGRAM logbins 10 | 11 | --- logbins xmin xmax nbin 12 | --- Outputs the bins for a logarithmic bin spacing 13 | 14 | * xmin = inner radius of smallest bin 15 | * xmax = outer radius of largest bin 16 | * nbin = number of bins (logarithmically spaced in theta) 17 | ---------------------------------------------------------------------- 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | /*---Arguments-------------------------*/ 28 | int nbin ; 29 | double xmin,xmax,logxmin,logxmax,dlogx; 30 | 31 | if(argc<4) { 32 | fprintf(stderr,"Usage `%s' rmin rmax nbins \n",argv[0]); 33 | return EXIT_FAILURE; 34 | } else { 35 | /*---Read-arguments-----------------------------------*/ 36 | sscanf(argv[1],"%lf",&xmin) ; 37 | sscanf(argv[2],"%lf",&xmax) ; 38 | sscanf(argv[3],"%d",&nbin) ; 39 | } 40 | assert(xmin > 0 && "rmin has to be non-zero, otherwise log is undefined"); 41 | 42 | /*---Setup-Pairs-arrays-------------------------------*/ 43 | logxmin = log10(xmin) ; 44 | logxmax = log10(xmax) ; 45 | dlogx = (logxmax-logxmin)/(double)nbin ; 46 | 47 | double left_edge=logxmin; 48 | for(int i=0;i 10 | #include 11 | #include 12 | #include 13 | 14 | #include "utils.h" //for matrix_free 15 | #include "countspheres.h" //API Header 16 | 17 | //Actual implementations 18 | #include "countspheres_impl_float.h" 19 | #include "countspheres_impl_double.h" 20 | 21 | 22 | void free_results_countspheres(results_countspheres *results) 23 | { 24 | if(results == NULL) 25 | return; 26 | 27 | matrix_free((void **) results->pN, results->nbin); 28 | results->pN = NULL; 29 | results->rmax = 0.0; 30 | results->nbin = 0; 31 | results->nc = 0; 32 | results->num_pN = 0; 33 | } 34 | 35 | 36 | 37 | int countspheres(const int64_t np, void * restrict X, void * restrict Y, void * restrict Z, 38 | const double rmax, const int nbin, const int nc, 39 | const int num_pN, 40 | unsigned long seed, 41 | results_countspheres *results, 42 | struct config_options *options, 43 | struct extra_options *extra) 44 | { 45 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 46 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 47 | __FUNCTION__, options->float_type); 48 | return EXIT_FAILURE; 49 | } 50 | 51 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1) != 0) { 52 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 53 | return EXIT_FAILURE; 54 | } 55 | 56 | if(options->float_type == sizeof(float)) { 57 | return countspheres_float(np, (float *) X, (float *) Y, (float *) Z, 58 | rmax, nbin, nc, 59 | num_pN, 60 | seed, 61 | results, 62 | options, 63 | extra); 64 | } else { 65 | return countspheres_double(np, (double *) X, (double *) Y, (double *) Z, 66 | rmax, nbin, nc, 67 | num_pN, 68 | seed, 69 | results, 70 | options, 71 | extra); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /theory/vpf/countspheres.h: -------------------------------------------------------------------------------- 1 | /* File: countspheres.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" //struct config_options 16 | #include //for uint64_t 17 | 18 | 19 | //define the results structure 20 | typedef struct{ 21 | double **pN; 22 | double rmax; 23 | int nbin; 24 | int nc; 25 | int num_pN; 26 | } results_countspheres; 27 | 28 | 29 | extern int countspheres(const int64_t np, void * restrict X, void * restrict Y, void * restrict Z, 30 | const double rmax, const int nbin, const int nc, 31 | const int num_pN, 32 | unsigned long seed, 33 | results_countspheres *results, 34 | struct config_options *options, 35 | struct extra_options *extra); 36 | 37 | extern void free_results_countspheres(results_countspheres *results); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /theory/vpf/countspheres_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countspheres_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" 17 | #include 18 | 19 | #include "countspheres.h" //for definition of DOUBLE 20 | 21 | extern void interrupt_handler_vpf_DOUBLE(int signo); 22 | 23 | typedef int (*vpf_func_ptr_DOUBLE)(const int64_t np, DOUBLE * restrict X, DOUBLE * restrict Y, DOUBLE * restrict Z, 24 | const DOUBLE xc, const DOUBLE yc, const DOUBLE zc, 25 | const DOUBLE rmax, const int nbin, 26 | int *counts_src_pN); 27 | 28 | extern vpf_func_ptr_DOUBLE vpf_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 29 | 30 | extern int countspheres_DOUBLE(const int64_t np, DOUBLE * restrict X, DOUBLE * restrict Y, DOUBLE * restrict Z, 31 | const double rmax, const int nbin, const int nc, 32 | const int num_pN, 33 | unsigned long seed, 34 | results_countspheres *results, 35 | struct config_options *options, 36 | struct extra_options *extra); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /theory/wp/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := ../.. 2 | INSTALL_HEADERS_DIR := $(ROOT_DIR)/include 3 | INSTALL_LIB_DIR := $(ROOT_DIR)/lib 4 | INSTALL_BIN_DIR := $(ROOT_DIR)/bin 5 | UTILS_DIR := $(ROOT_DIR)/utils 6 | IO_DIR := $(ROOT_DIR)/io 7 | 8 | include $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk 9 | LIBNAME:= countpairs_wp 10 | LIBRARY := lib$(LIBNAME).a 11 | LIBSRC := countpairs_wp.c countpairs_wp_impl_double.c countpairs_wp_impl_float.c \ 12 | $(UTILS_DIR)/gridlink_impl_double.c $(UTILS_DIR)/gridlink_impl_float.c \ 13 | $(UTILS_DIR)/gridlink_utils_float.c $(UTILS_DIR)/gridlink_utils_double.c \ 14 | $(UTILS_DIR)/utils.c $(UTILS_DIR)/progressbar.c $(UTILS_DIR)/cpu_features.c $(UTILS_DIR)/avx512_calls.c 15 | LIBRARY_HEADERS := $(LIBNAME).h 16 | 17 | TARGET := wp 18 | TARGETSRC := wp.c $(IO_DIR)/io.c $(IO_DIR)/ftread.c $(LIBSRC) 19 | 20 | INCL := wp_kernels_double.c wp_kernels_float.c wp_kernels.c.src countpairs_wp.h \ 21 | countpairs_wp_impl_float.h countpairs_wp_impl_double.h countpairs_wp_impl.h.src \ 22 | $(UTILS_DIR)/gridlink_impl_float.h $(UTILS_DIR)/gridlink_impl_double.h $(UTILS_DIR)/gridlink_impl.h.src \ 23 | $(UTILS_DIR)/gridlink_utils_float.h $(UTILS_DIR)/gridlink_utils_double.h $(UTILS_DIR)/gridlink_utils.h.src \ 24 | $(UTILS_DIR)/cellarray_double.h $(UTILS_DIR)/cellarray_float.h $(UTILS_DIR)/cellarray.h.src \ 25 | $(UTILS_DIR)/cell_pair_float.h $(UTILS_DIR)/cell_pair_double.h $(UTILS_DIR)/cell_pair.h.src \ 26 | $(UTILS_DIR)/avx512_calls.h $(UTILS_DIR)/avx2_calls.h \ 27 | $(UTILS_DIR)/avx_calls.h $(UTILS_DIR)/sse_calls.h $(UTILS_DIR)/function_precision.h $(UTILS_DIR)/defs.h \ 28 | $(UTILS_DIR)/cpu_features.h \ 29 | $(IO_DIR)/ftread.h $(IO_DIR)/io.h $(UTILS_DIR)/utils.h $(UTILS_DIR)/sglib.h $(UTILS_DIR)/progressbar.h \ 30 | $(UTILS_DIR)/weight_functions_double.h $(UTILS_DIR)/weight_functions_float.h $(UTILS_DIR)/weight_functions.h.src \ 31 | $(UTILS_DIR)/weight_defs_double.h $(UTILS_DIR)/weight_defs_float.h $(UTILS_DIR)/weight_defs.h.src 32 | 33 | 34 | TARGETOBJS := $(TARGETSRC:.c=.o) 35 | LIBOBJS := $(LIBSRC:.c=.o) 36 | 37 | all: $(TARGET) $(TARGETOBJS) $(TARGETSRC) $(ROOT_DIR)/theory.options $(ROOT_DIR)/common.mk Makefile 38 | 39 | countpairs_wp_impl_float.o:countpairs_wp_impl_float.c countpairs_wp_impl_float.h wp_kernels_float.c $(UTILS_DIR)/gridlink_impl_float.h 40 | countpairs_wp_impl_double.o:countpairs_wp_impl_double.c countpairs_wp_impl_double.h wp_kernels_double.c $(UTILS_DIR)/gridlink_impl_double.h 41 | countpairs_wp.o:countpairs_wp.c countpairs_wp_impl_double.h countpairs_wp_impl_float.h countpairs_wp.h 42 | countpairs_wp_impl_float.c countpairs_wp_impl_double.c:countpairs_wp_impl.c.src $(INCL) 43 | 44 | 45 | 46 | libs: lib 47 | lib: $(LIBRARY) 48 | install:$(INSTALL_BIN_DIR)/$(TARGET) $(INSTALL_LIB_DIR)/$(LIBRARY) $(INSTALL_HEADERS_DIR)/$(LIBRARY_HEADERS) 49 | clean: 50 | $(RM) $(TARGETOBJS) $(TARGET) $(LIBRARY) wp_kernels_float.c wp_kernels_double.c countpairs_wp_impl_double.[ch] countpairs_wp_impl_float.[ch] 51 | $(RM) -R *.dSYM 52 | 53 | distclean:clean 54 | cd $(INSTALL_HEADERS_DIR) && $(RM) $(LIBRARY_HEADERS) 55 | cd $(INSTALL_LIB_DIR) && $(RM) $(LIBRARY) 56 | cd $(INSTALL_BIN_DIR) && $(RM) $(TARGET) 57 | 58 | tests: tests_periodic 59 | 60 | tests_periodic: 61 | $(MAKE) -C ../tests wp 62 | 63 | include $(ROOT_DIR)/rules.mk 64 | -------------------------------------------------------------------------------- /theory/wp/countpairs_wp.c: -------------------------------------------------------------------------------- 1 | /* File: countpairs_wp.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "countpairs_wp.h" //function proto-type for API 15 | #include "countpairs_wp_impl_double.h"//actual implementations for double 16 | #include "countpairs_wp_impl_float.h"//actual implementations for float 17 | 18 | void free_results_wp(results_countpairs_wp *results) 19 | { 20 | if(results == NULL) 21 | return; 22 | 23 | free(results->rupp);results->rupp = NULL; 24 | free(results->npairs);results->npairs = NULL; 25 | free(results->rpavg);results->rpavg = NULL; 26 | free(results->weightavg);results->weightavg = NULL; 27 | free(results->wp);results->wp = NULL; 28 | 29 | results->nbin = 0; 30 | results->pimax = 0.0; 31 | } 32 | 33 | int countpairs_wp(const int64_t ND, void * restrict X, void * restrict Y, void * restrict Z, 34 | const double boxsize, 35 | const int numthreads, 36 | const char *binfile, 37 | const double pimax, 38 | results_countpairs_wp *results, 39 | struct config_options *options, 40 | struct extra_options *extra) 41 | { 42 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 43 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 44 | __FUNCTION__, options->float_type); 45 | return EXIT_FAILURE; 46 | } 47 | 48 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1 ) != 0) { 49 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 50 | return EXIT_FAILURE; 51 | } 52 | 53 | if(options->float_type == sizeof(float)) { 54 | return countpairs_wp_float(ND, (float *) X, (float *) Y, (float *) Z, 55 | boxsize, 56 | numthreads, 57 | binfile, 58 | pimax, 59 | results, 60 | options, 61 | extra); 62 | } else { 63 | return countpairs_wp_double(ND, (double *) X, (double *) Y, (double *) Z, 64 | boxsize, 65 | numthreads, 66 | binfile, 67 | pimax, 68 | results, 69 | options, 70 | extra); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /theory/wp/countpairs_wp.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_wp.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" 17 | #include 18 | 19 | //define the results structure 20 | typedef struct{ 21 | uint64_t *npairs; 22 | double *wp; 23 | double *rupp; 24 | double *rpavg; 25 | double *weightavg; 26 | double pimax; 27 | int nbin; 28 | } results_countpairs_wp; 29 | 30 | extern int countpairs_wp(const int64_t ND1, void * restrict X1, void * restrict Y1, void * restrict Z1, 31 | const double boxsize, 32 | const int numthreads, 33 | const char *binfile, 34 | const double pimax, 35 | results_countpairs_wp *result, 36 | struct config_options *options, 37 | struct extra_options *extra) __attribute__((warn_unused_result)); 38 | 39 | extern void free_results_wp(results_countpairs_wp *results); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /theory/wp/countpairs_wp_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_wp_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "defs.h" 18 | #include "weight_defs_DOUBLE.h" 19 | #include 20 | 21 | #include "countpairs_wp.h" 22 | 23 | extern void interrupt_handler_countpairs_wp_DOUBLE(int signo); 24 | 25 | 26 | typedef int (*wp_func_ptr_DOUBLE)(DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, const int64_t N0, 27 | DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, const int64_t N1, const int same_cell, 28 | const DOUBLE sqr_rpmax, const DOUBLE sqr_rpmin, const int nbin, const DOUBLE *rupp_sqr, const DOUBLE pimax, 29 | const DOUBLE off_xwrap, const DOUBLE off_ywrap, const DOUBLE off_zwrap, 30 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 31 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 32 | DOUBLE *src_rpavg, uint64_t *src_npairs, 33 | DOUBLE *src_weightavg, const weight_method_t weight_method); 34 | 35 | extern wp_func_ptr_DOUBLE wp_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 36 | 37 | extern int countpairs_wp_DOUBLE(const int64_t ND1, DOUBLE * restrict X1, DOUBLE * restrict Y1, DOUBLE * restrict Z1, 38 | const double boxsize, 39 | const int numthreads, 40 | const char *binfile, 41 | const double pimax, 42 | results_countpairs_wp *result, 43 | struct config_options *options, 44 | struct extra_options *extra) __attribute__((warn_unused_result)); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /theory/wp/wp_scaling_Mr19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manodeep/Corrfunc/43e651e53a3be77776b27beadb1e3185cc2c5cd7/theory/wp/wp_scaling_Mr19.png -------------------------------------------------------------------------------- /theory/xi/countpairs_xi.c: -------------------------------------------------------------------------------- 1 | /* File: countpairs_xi.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "countpairs_xi.h" //function proto-type for API 15 | #include "countpairs_xi_impl_double.h"//actual implementations for double 16 | #include "countpairs_xi_impl_float.h"//actual implementations for float 17 | 18 | void free_results_xi(results_countpairs_xi *results) 19 | { 20 | if(results == NULL) 21 | return; 22 | 23 | free(results->rupp);results->rupp = NULL; 24 | free(results->xi);results->xi = NULL; 25 | free(results->npairs);results->npairs = NULL; 26 | free(results->ravg);results->ravg = NULL; 27 | free(results->weightavg);results->weightavg = NULL; 28 | 29 | results->nbin = 0; 30 | } 31 | 32 | 33 | int countpairs_xi(const int64_t ND, void * restrict X, void * restrict Y, void * restrict Z, 34 | const double boxsize, 35 | const int numthreads, 36 | const char *binfile, 37 | results_countpairs_xi *results, 38 | struct config_options *options, 39 | struct extra_options *extra) 40 | { 41 | if( ! (options->float_type == sizeof(float) || options->float_type == sizeof(double))){ 42 | fprintf(stderr,"ERROR: In %s> Can only handle doubles or floats. Got an array of size = %zu\n", 43 | __FUNCTION__, options->float_type); 44 | return EXIT_FAILURE; 45 | } 46 | if( strncmp(options->version, STR(VERSION), sizeof(options->version)/sizeof(char)-1) != 0) { 47 | fprintf(stderr,"Error: Do not know this API version = `%s'. Expected version = `%s'\n", options->version, STR(VERSION)); 48 | return EXIT_FAILURE; 49 | } 50 | 51 | if(options->float_type == sizeof(float)) { 52 | return countpairs_xi_float(ND, (float *) X, (float *) Y, (float *) Z, 53 | boxsize, 54 | numthreads, 55 | binfile, 56 | results, 57 | options, 58 | extra); 59 | } else { 60 | return countpairs_xi_double(ND, (double *) X, (double *) Y, (double *) Z, 61 | boxsize, 62 | numthreads, 63 | binfile, 64 | results, 65 | options, 66 | extra); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /theory/xi/countpairs_xi.h: -------------------------------------------------------------------------------- 1 | /* File: countpairs_xi.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "defs.h" //for struct config_options 16 | #include //for uint64_t 17 | 18 | 19 | //define the results structure 20 | typedef struct{ 21 | uint64_t *npairs; 22 | double *xi; 23 | double *rupp; 24 | double *ravg; 25 | double *weightavg; 26 | int nbin; 27 | } results_countpairs_xi; 28 | 29 | extern void free_results_xi(results_countpairs_xi *results); 30 | extern int countpairs_xi(const int64_t ND1, void * restrict X1, void * restrict Y1, void * restrict Z1, 31 | const double boxsize, 32 | const int numthreads, 33 | const char *binfile, 34 | results_countpairs_xi *results, 35 | struct config_options *options, 36 | struct extra_options *extra); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /theory/xi/countpairs_xi_impl.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: countpairs_xi_impl.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "defs.h" 17 | #include "weight_defs_DOUBLE.h" 18 | #include //for uint64_t 19 | 20 | #include "countpairs_xi.h" //definition of struct results_countpairs_xi (and config_options from defs.h included) 21 | 22 | extern void interrupt_handler_countpairs_xi_DOUBLE(int signo); 23 | 24 | typedef int (*xi_func_ptr_DOUBLE)(DOUBLE *x0, DOUBLE *y0, DOUBLE *z0, const weight_struct_DOUBLE *weights0, const int64_t N0, 25 | DOUBLE *x1, DOUBLE *y1, DOUBLE *z1, const weight_struct_DOUBLE *weights1, const int64_t N1, const int same_cell, 26 | const DOUBLE sqr_rpmax, const DOUBLE sqr_rpmin, const int nbin, const DOUBLE *rupp_sqr, 27 | const DOUBLE off_xwrap, const DOUBLE off_ywrap, const DOUBLE off_zwrap, 28 | const DOUBLE min_xdiff, const DOUBLE min_ydiff, const DOUBLE min_zdiff, 29 | const DOUBLE closest_icell_xpos, const DOUBLE closest_icell_ypos, const DOUBLE closest_icell_zpos, 30 | DOUBLE *src_rpavg, uint64_t *src_npairs, 31 | DOUBLE *src_weightavg, const weight_method_t weight_method); 32 | 33 | extern xi_func_ptr_DOUBLE xi_driver_DOUBLE(const struct config_options *options) __attribute__((warn_unused_result)); 34 | 35 | extern int countpairs_xi_DOUBLE(const int64_t ND1, DOUBLE * restrict X1, DOUBLE * restrict Y1, DOUBLE * restrict Z1, 36 | const double boxsize, 37 | const int numthreads, 38 | const char *binfile, 39 | results_countpairs_xi *results, 40 | struct config_options *options, 41 | struct extra_options *extra); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /utils/Makefile: -------------------------------------------------------------------------------- 1 | ROOT_DIR := .. 2 | 3 | ## While GSL is required in one object file, GSL_REQUIRED is intentionally 4 | ## *NOT* set because that flag will be set/unset by the actual pair-counting. 5 | ## If we set the GSL_REQUIRED flag in this Makefile, then *ALL* directories 6 | ## effectively inherit GSL_REQUIRED. 7 | 8 | include $(ROOT_DIR)/common.mk 9 | TARGETSRC := cosmology_params.c gridlink_impl_double.c gridlink_impl_float.c gridlink_mocks_impl_float.c \ 10 | gridlink_mocks_impl_double.c gridink_utils_double.c gridlink_utils_float.c \ 11 | progressbar.c set_cosmo_dist.c utils.c cpu_features.c avx512_calls.c 12 | TARGETOBJS := $(TARGETSRC:.c=.o) 13 | INCL := avx512_calls.h avx2_calls.h avx_calls.h sse_calls.h defs.h defs.h function_precision.h cosmology_params.h \ 14 | cellarray_float.h cellarray_double.h cellarray.h.src \ 15 | cellarray_mocks_float.h cellarray_mocks_double.h cellarray_mocks.h.src \ 16 | gridlink_utils_float.h gridlink_utils_double.h gridlink_utils_impl.h.src \ 17 | gridlink_utils_float.c gridlink_utils_double.c gridlink_utils_impl.c.src \ 18 | gridlink_impl_float.c gridlink_impl_double.c \ 19 | gridlink_mocks_impl_float.c gridlink_mocks_impl_double.c \ 20 | gridlink_impl_double.h gridlink_impl_float.h gridlink_impl.c.src gridlink_impl.h.src \ 21 | gridlink_mocks_impl_float.h gridlink_mocks_impl_double.h gridlink_mocks_impl.h.src gridlink_mocks_impl.c.src \ 22 | progressbar.h set_cosmo_dist.h set_cosmology.h sglib.h utils.h \ 23 | weight_functions_double.h weight_functions_float.h weight_functions.h.src \ 24 | weight_defs_double.h weight_defs_float.h weight_defs.h.src \ 25 | cell_pair_float.h cell_pair_double.h cell_pair.h.src 26 | 27 | all: $(TARGETOBJS) Makefile $(ROOT_DIR)/common.mk $(ROOT_DIR)/theory.options $(ROOT_DIR)/mocks.options 28 | 29 | set_cosmo_dist.o: set_cosmo_dist.c $(ROOT_DIR)/mocks.options 30 | $(CC) $(CFLAGS) $(GSL_CFLAGS) -c $< -o $@ 31 | 32 | clean: 33 | $(RM) $(TARGETOBJS) cellarray_float.h cellarray_double.h gridlink_impl_float.[ch] gridlink_impl_double.[ch] cellarray_mocks_float.h cellarray_mocks_double.h gridlink_mocks_impl_float.[ch] gridlink_utils_double.[ch] gridlink_utils_float.[ch] gridlink_mocks_impl_double.[ch] weight_functions_double.h weight_functions_float.h weight_defs_double.h weight_defs_float.h cell_pair_double.h cell_pair_float.h 34 | 35 | include $(ROOT_DIR)/rules.mk 36 | -------------------------------------------------------------------------------- /utils/avx512_calls.c: -------------------------------------------------------------------------------- 1 | /* File: avx512_calls.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | #if defined(__AVX512F__) 9 | #include "avx512_calls.h" 10 | 11 | 12 | const int64_t bits_set_in_avx512_mask_float[] = { B16(0) }; 13 | const uint16_t masks_per_misalignment_value_float[] = {0b1111111111111111, 14 | 0b0000000000000001, 15 | 0b0000000000000011, 16 | 0b0000000000000111, 17 | 0b0000000000001111, 18 | 0b0000000000011111, 19 | 0b0000000000111111, 20 | 0b0000000001111111, 21 | 0b0000000011111111, 22 | 0b0000000111111111, 23 | 0b0000001111111111, 24 | 0b0000011111111111, 25 | 0b0000111111111111, 26 | 0b0001111111111111, 27 | 0b0011111111111111, 28 | 0b0111111111111111}; 29 | 30 | const int64_t bits_set_in_avx512_mask_double[] = { B8(0) }; 31 | const uint8_t masks_per_misalignment_value_double[] = {0b11111111, 32 | 0b00000001, 33 | 0b00000011, 34 | 0b00000111, 35 | 0b00001111, 36 | 0b00011111, 37 | 0b00111111, 38 | 0b01111111}; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /utils/cache.c: -------------------------------------------------------------------------------- 1 | /* File: cache.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | /*Taken from http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size*/ 10 | 11 | // Author: Nick Strupat 12 | // Date: October 29, 2010 13 | // Returns the cache line size (in bytes) of the processor, or 0 on failure 14 | 15 | 16 | /* BUG NOTE: Might be worthwhile to take the minimum cache linesize across all cpus 17 | just in case the cpus have different caches. This has already happened on ARM 18 | https://github.com/mono/mono/pull/3549 19 | http://lists.infradead.org/pipermail/linux-arm-kernel/2016-September/453859.html 20 | */ 21 | 22 | 23 | #if defined(__APPLE__) 24 | 25 | #include 26 | size_t cache_line_size(void) 27 | { 28 | size_t line_size = 0; 29 | size_t sizeof_line_size = sizeof(line_size); 30 | sysctlbyname("hw.cachelinesize", &line_size, &sizeof_line_size, 0, 0); 31 | return line_size; 32 | } 33 | 34 | #elif defined(__linux__) 35 | 36 | #include 37 | size_t cache_line_size(void) 38 | { 39 | FILE *fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); 40 | size_t lineSize = DEFAULT_CACHE_LINE_SIZE; 41 | if (fp != NULL) { 42 | int nitems = fscanf(fp, "%zu", &lineSize); 43 | if(nitems !=1) { 44 | linesize=0; 45 | } 46 | fclose(fp); 47 | } 48 | return lineSize; 49 | } 50 | 51 | #else 52 | 53 | #warning Unrecognized platform for figuring out cache line size - returning a default value of DEFAULT_CACHE_LINE_SIZE 54 | size_t cache_line_size(void) 55 | { 56 | return DEFAULT_CACHE_LINE_SIZE;//set a default of 64 bytes for cache line size 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /utils/cache.h: -------------------------------------------------------------------------------- 1 | /* File: cache.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #define DEFAULT_CACHE_LINE_SIZE 64 17 | 18 | /*Taken from http://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size*/ 19 | #include 20 | size_t cache_line_size(void); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /utils/cell_pair.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: cell_pair.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "weight_defs_DOUBLE.h" 19 | 20 | struct cell_pair_DOUBLE{ 21 | int64_t cellindex1; 22 | int64_t cellindex2; 23 | 24 | DOUBLE xwrap; 25 | DOUBLE ywrap; 26 | DOUBLE zwrap; 27 | 28 | DOUBLE min_dx; 29 | DOUBLE min_dy; 30 | DOUBLE min_dz; 31 | 32 | DOUBLE closest_x1; 33 | DOUBLE closest_y1; 34 | DOUBLE closest_z1; 35 | 36 | int8_t same_cell; 37 | }; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /utils/cellarray.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: cellarray.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "weight_defs_DOUBLE.h" 19 | 20 | typedef struct cellarray_DOUBLE cellarray_DOUBLE; 21 | struct cellarray_DOUBLE{ 22 | int64_t nelements;//Here the xyz positions will be stored in their individual pointers. More amenable to sorting -> used by wp and xi 23 | DOUBLE *x; 24 | DOUBLE *y; 25 | DOUBLE *z; 26 | weight_struct_DOUBLE weights; 27 | DOUBLE xbounds[2];//xmin and xmax for entire cell 28 | DOUBLE ybounds[2]; 29 | DOUBLE zbounds[2]; 30 | 31 | int64_t *original_index;//the input order for particles 32 | uint8_t owns_memory;// boolean flag if the x/y/z pointers were separately malloc'ed -> need to be freed once calculations are done 33 | 34 | /* 35 | boolean flag (only relevant when external particle positions 36 | are used) to re-order particles back into original order 37 | after calculations are done. Only relevant if external 38 | pointers are being used for x/y/z 39 | */ 40 | 41 | uint8_t unused[7];//to maintain alignment explicitly (the compiler would insert this anyway) 42 | }; 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /utils/cellarray_mocks.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | /* File: cellarray_mocks.h.src */ 3 | /* 4 | This file is a part of the Corrfunc package 5 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 6 | License: MIT LICENSE. See LICENSE file under the top-level 7 | directory at https://github.com/manodeep/Corrfunc/ 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include "weight_defs_DOUBLE.h" 19 | 20 | typedef struct cellarray_mocks_DOUBLE cellarray_mocks_DOUBLE; 21 | struct cellarray_mocks_DOUBLE{ 22 | int64_t nelements; 23 | DOUBLE *x; 24 | DOUBLE *y; 25 | DOUBLE *z; 26 | weight_struct_DOUBLE weights; 27 | DOUBLE xbounds[2]; 28 | DOUBLE ybounds[2]; 29 | DOUBLE zbounds[2]; 30 | 31 | //these two fields are only relevant for angular calculations 32 | DOUBLE dec_bounds[2]; 33 | DOUBLE ra_bounds[2]; 34 | 35 | int64_t *original_index;//the input order for particles 36 | uint8_t owns_memory;// boolean flag if the x/y/z pointers were separately malloc'ed -> need to be freed once calculations are done 37 | 38 | /* 39 | boolean flag (only relevant when external particle positions 40 | are used) to re-order particles back into original order 41 | after calculations are done. Only relevant if external 42 | pointers are being used for x/y/z 43 | */ 44 | 45 | uint8_t unused[7];//to maintain alignment explicitly (the compiler would insert this anyway) 46 | }; 47 | 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /utils/cosmology_params.c: -------------------------------------------------------------------------------- 1 | /* File: cosmology_params.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | #include 9 | #include "cosmology_params.h" 10 | 11 | //Declare the variables 12 | double OMEGA_M; 13 | double OMEGA_B; 14 | double OMEGA_L; 15 | double HUBBLE; 16 | double LITTLE_H; 17 | double SIGMA_8; 18 | double NS; 19 | int active_cosmology=-1; 20 | int cosmology_initialized=0; 21 | 22 | int init_cosmology(const int which_cosmology) 23 | { 24 | 25 | switch(which_cosmology) 26 | { 27 | case 1: 28 | //LasDamas Cosmology 29 | OMEGA_M=0.25; 30 | OMEGA_B=0.04; 31 | OMEGA_L=1.0-OMEGA_M; 32 | LITTLE_H=0.7; 33 | SIGMA_8=0.8; 34 | NS=1.0; 35 | break; 36 | case 2: 37 | //Planck cosmology 38 | OMEGA_M=0.302; 39 | OMEGA_B=0.048; 40 | OMEGA_L=1.0-OMEGA_M; 41 | LITTLE_H=0.681; 42 | SIGMA_8=0.828; 43 | NS=0.96; 44 | break; 45 | 46 | default: 47 | fprintf(stderr,"ERROR: In %s> Cosmology=%d not implemented\n",__FUNCTION__, which_cosmology); 48 | return EXIT_FAILURE; 49 | } 50 | 51 | cosmology_initialized=1; 52 | HUBBLE=100.0*LITTLE_H; 53 | active_cosmology=which_cosmology; 54 | return EXIT_SUCCESS; 55 | } 56 | -------------------------------------------------------------------------------- /utils/cosmology_params.h: -------------------------------------------------------------------------------- 1 | /* File: cosmology_params.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern int cosmology_initialized; 17 | extern double OMEGA_M; 18 | extern double OMEGA_B; 19 | extern double OMEGA_L; 20 | extern double HUBBLE; 21 | extern double LITTLE_H; 22 | extern double SIGMA_8; 23 | extern double NS; 24 | extern int active_cosmology; 25 | 26 | int init_cosmology(const int lasdamas_cosmology)__attribute__((warn_unused_result)); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /utils/cpu_features.h: -------------------------------------------------------------------------------- 1 | /* File: cpu_features.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | 8 | 9 | Adapted from Agner Fog's vectorclass: http://agner.org/ 10 | */ 11 | 12 | #pragma once 13 | #include 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef enum { 21 | DEFAULT=-42,/* present simply to make the enum a signed int*/ 22 | FALLBACK=0, /* No special options */ 23 | SSE=1, /* 64 bit vectors */ 24 | SSE2=2, /* 128 bit vectors */ 25 | SSE3=3, /* 128 bit vectors */ 26 | SSSE3=4, /* 128 bit vectors */ 27 | SSE4=5,/* 128bit vectors */ 28 | SSE42=6, /* 128bit vectors with blend operations */ 29 | AVX=7, /* 256bit vector width */ 30 | AVX2=8, /* AVX2 (integer operations)*/ 31 | AVX512F=9,/* AVX 512 Foundation */ 32 | ARM64=10, /* ARM64 on Apple M1/M2 */ 33 | NUM_ISA /*NUM_ISA will be the next integer after 34 | the last declared enum. AVX512F:=9 (so, NUM_ISA==10)*/ 35 | } isa; //name for instruction sets -> corresponds to the return values for functions in cpu_features.c 36 | 37 | 38 | static inline void cpuid (int output[4], int functionnumber) { 39 | #if defined (__ARM_NEON) 40 | (void) output; 41 | (void) functionnumber; 42 | #else 43 | #if defined(__GNUC__) || defined(__clang__) // use inline assembly, Gnu/AT&T syntax 44 | 45 | int a, b, c, d; 46 | __asm("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(functionnumber),"c"(0) ); 47 | output[0] = a; 48 | output[1] = b; 49 | output[2] = c; 50 | output[3] = d; 51 | 52 | #else // unknown platform. try inline assembly with masm/intel syntax 53 | 54 | __asm { 55 | mov eax, functionnumber 56 | xor ecx, ecx 57 | cpuid; 58 | mov esi, output 59 | mov [esi], eax 60 | mov [esi+4], ebx 61 | mov [esi+8], ecx 62 | mov [esi+12], edx 63 | } 64 | 65 | #endif 66 | #endif 67 | } 68 | 69 | // Define interface to xgetbv instruction 70 | static inline int64_t xgetbv (int ctr) { 71 | #if defined(__ARM_NEON) 72 | (void) ctr; 73 | return (int64_t) FALLBACK; /* use FALLBACK kernels until the ARM64 kernels are added to the pair-counters */ 74 | #else 75 | #if (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 1200) //Intel compiler supporting _xgetbv intrinsic 76 | return _xgetbv(ctr); // intrinsic function for XGETBV 77 | #elif defined(__GNUC__) // use inline assembly, Gnu/AT&T syntax 78 | uint32_t a, d; 79 | __asm("xgetbv" : "=a"(a),"=d"(d) : "c"(ctr) : ); 80 | return a | (((uint64_t) d) << 32); 81 | #else 82 | uint32_t a, d; 83 | __asm { 84 | mov ecx, ctr 85 | _emit 0x0f 86 | _emit 0x01 87 | _emit 0xd0 ; // xgetbv 88 | mov a, eax 89 | mov d, edx 90 | } 91 | return a | (((uint64_t) d) << 32); 92 | 93 | #endif 94 | #endif 95 | } 96 | 97 | extern int runtime_instrset_detect(void); 98 | extern int get_max_usable_isa(void); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | -------------------------------------------------------------------------------- /utils/function_precision.h: -------------------------------------------------------------------------------- 1 | /* File: function_precision.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | 16 | #ifndef M_PI 17 | #define M_PI 3.14159265358979323846264338327950288 18 | #endif 19 | 20 | #define PI_OVER_180 0.017453292519943295769236907684886127134428718885417254560971 21 | #define INV_PI_OVER_180 57.29577951308232087679815481410517033240547246656432154916024 22 | 23 | //Define the Macros 24 | #ifdef DOUBLE_PREC 25 | #define COSD(X) cos(X*PI_OVER_180) 26 | #define SIND(X) sin(X*PI_OVER_180) 27 | #else 28 | #define COSD(X) cosf(X*PI_OVER_180) 29 | #define SIND(X) sinf(X*PI_OVER_180) 30 | #endif 31 | 32 | #ifdef __AVX__ 33 | 34 | #define REGISTER_WIDTH 256 //cpu supports avx instructions 35 | #define NVECF 8 //8 floats per ymm register 36 | #define NVECD 4 //4 doubles per ymm register 37 | 38 | #else 39 | 40 | #ifdef __SSE4_2__ 41 | 42 | #define REGISTER_WIDTH 128 //cpu supports sse instructions 43 | #define NVECF 4 //8 floats per xmm register 44 | #define NVECD 2 //4 doubles per xmm register 45 | 46 | #else 47 | 48 | #define REGISTER_WIDTH 64 49 | #define NVECF 2 50 | #define NVECD 1 51 | 52 | #endif//SSE 53 | #endif//AVX 54 | 55 | 56 | #include 57 | 58 | #ifdef DOUBLE_PREC 59 | #define DOUBLE double 60 | #define REAL_FORMAT "lf" 61 | #define NVEC NVECD 62 | #define ZERO 0.0 63 | #define SQRT sqrt 64 | #define LOG log 65 | #define LOG10 log10 66 | #define LOG2 log2 67 | #define FABS fabs 68 | #define COS cos 69 | #define SIN sin 70 | #define ACOS acos 71 | #define ASIN asin 72 | #define POW pow 73 | #define ABS fabs 74 | #define MAX_POSITIVE_FLOAT DBL_MAX 75 | #else 76 | #define DOUBLE float 77 | #define REAL_FORMAT "f" 78 | #define NVEC NVECF 79 | #define ZERO 0.0f 80 | #define SQRT sqrtf 81 | #define LOG logf 82 | #define LOG10 log10f 83 | #define LOG2 log2f 84 | #define FABS fabsf 85 | #define COS cosf 86 | #define SIN sinf 87 | #define ACOS acosf 88 | #define ASIN asinf 89 | #define POW powf 90 | #define ABS fabsf 91 | #define MAX_POSITIVE_FLOAT FLT_MAX 92 | #endif 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /utils/progressbar.h: -------------------------------------------------------------------------------- 1 | /* File: progressbar.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | void init_my_progressbar(const int64_t N,int *interrupted); 22 | void my_progressbar(const int64_t curr_index,int *interrupted); 23 | void finish_myprogressbar(int *interrupted); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /utils/set_cosmo_dist.c: -------------------------------------------------------------------------------- 1 | /* File: set_cosmo_dist.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | /* function set_cosmo_dist (modelled after cosmodist.c) 10 | 11 | --- Computes the comoving distance as a function of redshift for 12 | a given cosmological model. 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "set_cosmo_dist.h" 21 | #include "cosmology_params.h" 22 | 23 | #define SQR(x) ((x)*(x)) 24 | #define CUBE(x) ((x)*(x)*(x)) 25 | #define epsilon 1e-10 26 | 27 | int set_cosmo_dist(const double zmax,const int max_size,double *zc,double *dc,const int lasdamas_cosmology) 28 | { 29 | /* First, initialize cosmology*/ 30 | int status = init_cosmology(lasdamas_cosmology); 31 | if(status != EXIT_SUCCESS) { 32 | return -1; 33 | } 34 | 35 | int i = 0; 36 | double Omegak; 37 | double smallh = 1.0;//Andreas pointed out that I don't need the real value of LITTLE_H 38 | Omegak = 1.0 - OMEGA_M - OMEGA_L; 39 | const double Dh = SPEED_OF_LIGHT*0.01/smallh ;// c/(100) -> in units of little h^-1 Mpc 40 | 41 | const double Deltaz = 1.0/max_size; 42 | const double dz = 1e-2*Deltaz; 43 | 44 | double Eint = 0.0; 45 | double E2 = 1.0 ; 46 | double z2 = Deltaz ; 47 | for(double z=2.0*dz;z(z2-epsilon) && z<(z2+epsilon)) { 55 | if( i >= max_size ) 56 | break ; 57 | 58 | const double Dc = Eint*Dh ; 59 | zc[i] = z ; 60 | dc[i] = Dc ; 61 | z2 += Deltaz ; 62 | i++ ; 63 | } 64 | } 65 | 66 | #ifdef DEBUG 67 | fprintf(stderr,"%s> (Omega_m, Omega_L, Omega_k, h, zmax) = (%4.2f, %4.2f, %4.2f, %4.2f,%4.2lf)\n", __FUNCTION__, OMEGA_M,OMEGA_L,Omegak,LITTLE_H,zmax) ; 68 | fprintf(stderr,"%s> tabulated redshift: %g to %g (distance: %g to %g Mpc)\n", __FUNCTION__, zc[0], zc[i-1], dc[0], dc[i-1]) ; 69 | #endif 70 | return i ; 71 | } 72 | -------------------------------------------------------------------------------- /utils/set_cosmo_dist.h: -------------------------------------------------------------------------------- 1 | /* File: set_cosmo_dist.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #ifndef _SET_COSMO_DIST_H_ 10 | #define _SET_COSMO_DIST_H_ 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | #define SPEED_OF_LIGHT 299800.0 20 | 21 | extern int set_cosmo_dist(const double zmax,const int max_size,double *zc,double *dc,const int lasdamas_cosmology); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /utils/set_cosmology.c: -------------------------------------------------------------------------------- 1 | /* File: set_cosmology.c */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #include "set_cosmology.h" 10 | #include "cosmology_params.h" 11 | #include "set_cosmo_dist.h" 12 | #include "macros.h" 13 | 14 | #include 15 | #include 16 | 17 | 18 | double get_age(const double z) 19 | { 20 | const int NWORKSPACE=1000; 21 | const double RECOMBINATION_REDSHIFT=1e3; 22 | const double AGE_AT_RECOMBINATION=0.37*1e-3;/*in Gyr ( recombination = 0.37 Myr)*/ 23 | gsl_integration_workspace *w = gsl_integration_workspace_alloc(NWORKSPACE); 24 | gsl_function F; 25 | double dummy=0.0; 26 | double result=0.0,error=0.0; 27 | 28 | F.function = &agefunc; 29 | F.params = &dummy; 30 | gsl_integration_qags (&F, z, RECOMBINATION_REDSHIFT, 0, 1e-7,NWORKSPACE,w,&result, &error); 31 | result *= 9.77813/LITTLE_H; 32 | 33 | result += AGE_AT_RECOMBINATION; 34 | 35 | gsl_integration_workspace_free (w); 36 | return result; 37 | } 38 | 39 | double agefunc(double z,void *params) 40 | { 41 | (void) params; 42 | return 1.0/(epeebles(z)*(1.0+z)); 43 | } 44 | 45 | 46 | double get_comoving_distance(const double zlow, const double z) 47 | { 48 | const int NWORKSPACE=1000; 49 | gsl_integration_workspace *w = gsl_integration_workspace_alloc(NWORKSPACE); 50 | gsl_function F; 51 | double dummy=0.0; 52 | double result=0.0,error=0.0; 53 | 54 | if(comoving_distance_func(0.0, NULL) < 0) { 55 | return -1.0; 56 | } 57 | 58 | F.function = &comoving_distance_func; 59 | F.params = &dummy; 60 | gsl_integration_qag (&F, zlow, z, 0, 1e-7, GSL_INTEG_GAUSS51, NWORKSPACE,w,&result, &error); 61 | 62 | gsl_integration_workspace_free (w); 63 | const double smallh=1.0; 64 | const double Dh = SPEED_OF_LIGHT*0.01/smallh ;// c/(100) -> in units of little h^-1 Mpc 65 | return Dh*result; 66 | } 67 | 68 | 69 | double comoving_distance_func(const double z, void *params) 70 | { 71 | (void) params; 72 | return 1.0/epeebles(z); 73 | } 74 | 75 | 76 | 77 | double epeebles(const double z) 78 | { 79 | if(cosmology_initialized != 1) { 80 | XRETURN(cosmology_initialized == 1, -1.0, "Cosmology needs to be initialized before calling the co-moving distance routines.\n" 81 | "initialize cosmology by calling the function `init_cosmology' in cosmology_params.c\n"); 82 | return -1.0; 83 | } 84 | const double Omegak = 1.0 - OMEGA_M - OMEGA_L; 85 | const double ez = sqrt(OMEGA_M*(1.0+z)*(1.0+z)*(1.0+z) + Omegak *(1+z) + OMEGA_L); 86 | return ez; 87 | } 88 | -------------------------------------------------------------------------------- /utils/set_cosmology.h: -------------------------------------------------------------------------------- 1 | /* File: set_cosmology.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | 17 | #include "cosmology_params.h" 18 | 19 | double get_age(const double z); 20 | double agefunc(double z,void *params); 21 | double get_comoving_distance(const double zlow, const double z); 22 | double comoving_distance_func(const double z, void *params); 23 | double epeebles(const double z); 24 | 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /utils/utils.h: -------------------------------------------------------------------------------- 1 | /* File: utils.h */ 2 | /* 3 | This file is a part of the Corrfunc package 4 | Copyright (C) 2015-- Manodeep Sinha (manodeep@gmail.com) 5 | License: MIT LICENSE. See LICENSE file under the top-level 6 | directory at https://github.com/manodeep/Corrfunc/ 7 | */ 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | #include//defines int64_t datatype -> *exactly* 8 bytes int 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | //routines for file i/o 24 | extern FILE * my_fopen(const char *fname,const char *mode); 25 | extern FILE * my_fopen_carefully(const char *fname,void (*header)(FILE *)); 26 | extern size_t my_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream); 27 | extern size_t my_fread(void *ptr, size_t size, size_t nmemb, FILE *stream); 28 | extern int my_fseek(FILE *stream, long offset, int whence); 29 | 30 | //general utilities 31 | extern void get_max_float(const int64_t ND1, const float *cz1, float *czmax); 32 | extern void get_max_double(const int64_t ND1, const double *cz1, double *czmax); 33 | extern char *int2bin(int a, char *buffer, int buf_size) ; 34 | extern int my_snprintf(char *buffer,int len,const char *format, ...) __attribute__((format(printf,3,4))); 35 | extern char * get_time_string(struct timeval t0,struct timeval t1); 36 | extern void print_time(struct timeval t0,struct timeval t1,const char *s); 37 | extern void current_utc_time(struct timespec *ts); 38 | extern int64_t getnumlines(const char *fname,const char comment); 39 | extern int is_big_endian(void); 40 | extern void byte_swap(char * const in, const size_t size, char *out); 41 | 42 | //memory routines 43 | extern void* my_realloc(void *x,size_t size,int64_t N,const char *varname); 44 | extern void* my_realloc_in_function(void **x,size_t size,int64_t N,const char *varname); 45 | extern void* my_malloc(size_t size,int64_t N); 46 | extern void* my_calloc(size_t size,int64_t N); 47 | extern void my_free(void ** x); 48 | extern void **matrix_malloc(size_t size,int64_t nx,int64_t ny); 49 | extern void **matrix_calloc(size_t size,int64_t nx,int64_t ny); 50 | extern int matrix_realloc(void **matrix, size_t size, int64_t nrow, int64_t ncol); 51 | extern void matrix_free(void **m,int64_t ny); 52 | 53 | void *** volume_malloc(size_t size,int64_t nrow,int64_t ncol,int64_t nframe); 54 | void *** volume_calloc(size_t size,int64_t nrow,int64_t ncol,int64_t nframe); 55 | void volume_free(void ***v,int64_t nrow,int64_t ncol); 56 | 57 | extern int run_system_call(const char *execstring); 58 | 59 | extern int setup_bins(const char *fname,double *rmin,double *rmax,int *nbin,double **rupp); 60 | extern int setup_bins_double(const char *fname,double *rmin,double *rmax,int *nbin,double **rupp); 61 | extern int setup_bins_float(const char *fname,float *rmin,float *rmax,int *nbin,float **rupp); 62 | 63 | extern int test_all_files_present(const int nfiles, ...); 64 | 65 | /* Floating point comparison utilities */ 66 | extern int AlmostEqualRelativeAndAbs_float(float A, float B, const float maxDiff, const float maxRelDiff); 67 | extern int AlmostEqualRelativeAndAbs_double(double A, double B, const double maxDiff, const double maxRelDiff); 68 | 69 | extern void parallel_cumsum(const int64_t *a, const int64_t N, int64_t *cumsum); 70 | 71 | //end function declarations 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /utils/weight_defs.h.src: -------------------------------------------------------------------------------- 1 | // # -*- mode: c -*- 2 | #pragma once 3 | 4 | #include 5 | 6 | typedef struct 7 | { 8 | DOUBLE *weights[MAX_NUM_WEIGHTS]; // This will be of shape weights[num_weights][num_particles] 9 | int64_t num_weights; 10 | } weight_struct_DOUBLE; 11 | --------------------------------------------------------------------------------