{"id":30040600,"url":"https://github.com/eelregit/mcfit","last_synced_at":"2025-10-03T21:27:18.882Z","repository":{"id":57440285,"uuid":"84594411","full_name":"eelregit/mcfit","owner":"eelregit","description":"multiplicatively convolutional fast integral transforms, implementing FFTLog","archived":false,"fork":false,"pushed_at":"2025-02-16T02:44:25.000Z","size":366,"stargazers_count":34,"open_issues_count":1,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-25T04:59:07.421Z","etag":null,"topics":["cosmology","differentiable-programming","fftlog","integral-transform","jax","numerical-integration"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eelregit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-10T19:36:40.000Z","updated_at":"2025-05-16T07:37:50.000Z","dependencies_parsed_at":"2023-01-28T13:03:10.892Z","dependency_job_id":"0d0df719-c56c-4c3a-8783-dbe23364590c","html_url":"https://github.com/eelregit/mcfit","commit_stats":{"total_commits":120,"total_committers":3,"mean_commits":40.0,"dds":0.01666666666666672,"last_synced_commit":"3baf5ff7e3b6a1724e536c02bf2b4d757049445f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eelregit/mcfit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelregit%2Fmcfit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelregit%2Fmcfit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelregit%2Fmcfit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelregit%2Fmcfit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eelregit","download_url":"https://codeload.github.com/eelregit/mcfit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelregit%2Fmcfit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269185733,"owners_count":24374634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cosmology","differentiable-programming","fftlog","integral-transform","jax","numerical-integration"],"created_at":"2025-08-07T02:00:27.329Z","updated_at":"2025-10-03T21:27:18.800Z","avatar_url":"https://github.com/eelregit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiplicatively Convolutional Fast Integral Transforms\n\n\n## Features\n\n* Compute integral transforms:\n\n  $$G(y) = \\int_0^\\infty F(x) K(xy) \\frac{dx}x;$$\n\n* Inverse transform without analytic inversion;\n* Integral kernels as derivatives:\n\n  $$G(y) = \\int_0^\\infty F(x) K'(xy) \\frac{dx}x;$$\n\n* Transform input array along any axis of `ndarray`;\n* Output the matrix form;\n* 1-to-n transform for multiple kernels (TODO):\n\n  $$G(y_1, \\cdots, y_n) = \\int_0^\\infty \\frac{dx}x F(x) \\prod_{a=1}^n K_a(xy_a);$$\n\n* Easily extensible for other kernels;\n* Support NumPy and JAX.\n\n\n## Algorithm\n\n`mcfit` computes integral transforms of the form\n\n  $$G(y) = \\int_0^\\infty F(x) K(xy) \\frac{dx}x$$\n\nwhere $F(x)$ is the input function, $G(y)$ is the output function, and\n$K(xy)$ is the integral kernel.\nOne is free to scale all three functions by a power law\n\n  $$g(y) = \\int_0^\\infty f(x) k(xy) \\frac{dx}x$$\n\nwhere $f(x)=x^{-q} F(x)$, $g(y)=y^q G(y)$, and $k(t)=t^q K(t)$.\nAnd $q$ is a tilt parameter serving to shift power of $x$ between the\ninput function and the kernel.\n\n`mcfit` implements the FFTLog algorithm.\nThe idea is to take advantage of the convolution theorem in $\\ln x$ and\n$\\ln y$.\nIt approximates the input function with a partial sum of the Fourier\nseries over one period of a periodic approximant, and use the exact\nFourier transform of the kernel.\nOne can calculate the latter analytically as a Mellin transform.\nThis algorithm is optimal when the input function is smooth in $\\ln x$,\nand is ideal for oscillatory kernels with input spanning a wide range in\n$\\ln x$.\n\n\n## Installation\n\n```sh\npip install mcfit\n```\n\n\n## Documentation\n\nSee docstring of `mcfit.mcfit`, which also applies to other\nsubclasses of transformations.\nAlso see `doc/mcfit.tex` for more explanations.\n\n\n## Examples\n\nOne can perform the following pair of Hankel transforms\n\n  $$e^{-y} = \\int_0^\\infty (1+x^2)^{-\\frac32} J_0(xy) x dx, \\quad (1+x^2)^{-\\frac32} = \\int_0^\\infty e^{-y} J_0(xy) y dy$$\n\neasily as follows\n```python\ndef F_fun(x):\n    return 1 / (1 + x*x)**1.5\ndef G_fun(y):\n    return numpy.exp(-y)\n\nx = numpy.logspace(-3, 3, num=60, endpoint=False)\nF = F_fun(x)\nH = mcfit.Hankel(x, lowring=True)\ny, G = H(F, extrap=True)\nnumpy.allclose(G, G_fun(y), rtol=1e-8, atol=1e-8)\n\ny = numpy.logspace(-4, 2, num=60, endpoint=False)\nG = G_fun(y)\nH_inv = mcfit.Hankel(y, lowring=True)\nx, F = H_inv(G, extrap=True)\nnumpy.allclose(F, F_fun(x), rtol=1e-10, atol=1e-10)\n```\n\nTo use JAX instead of the default numpy backend:\n```python\nH = mcfit.Hankel(x, lowring=True, backend='jax')  # do not jit\nH_jit = jax.jit(functools.partial(H, extrap=True))\ny, G = H_jit(F)\n```\nMost of the time one does not need to apply `jit` or other JAX\ntransforms to the constructor.\nBy forbidding this, `mcfit` allows the constructor to use any special\nfunction implementations available in Python with the `'jax'` backend.\n\nCosmologists often need to transform a power spectrum to its correlation\nfunction\n```python\nk, P = numpy.loadtxt('P.txt', unpack=True)\nr, xi = mcfit.P2xi(k)(P)\n```\nand the other way around\n```python\nr, xi = numpy.loadtxt('xi.txt', unpack=True)\nk, P = mcfit.xi2P(r)(xi)\n```\n\nSimilarly for the quadrupoles\n```python\nk, P2 = numpy.loadtxt('P2.txt', unpack=True)\nr, xi2 = mcfit.P2xi(k, l=2)(P2)\n```\n\nAlso useful to cosmologists is the tool below that computes the variance\nof the overdensity field as a function of radius, from which $\\sigma_8$\ncan be interpolated.\n```python\nR, var = mcfit.TophatVar(k, lowring=True)(P, extrap=True)\nvarR = scipy.interpolate.CubicSpline(R, var)\nsigma8 = numpy.sqrt(varR(8))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelregit%2Fmcfit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feelregit%2Fmcfit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelregit%2Fmcfit/lists"}