{"id":16927946,"url":"https://github.com/bjodah/finitediff","last_synced_at":"2025-04-28T11:16:54.633Z","repository":{"id":12345240,"uuid":"14988640","full_name":"bjodah/finitediff","owner":"bjodah","description":"Finite difference weights for any derivative order on arbitrarily spaced grids. C89, C++ and Fortran 90 implementations with Python bindings.","archived":false,"fork":false,"pushed_at":"2024-05-23T14:35:03.000Z","size":2978,"stargazers_count":40,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-28T11:16:46.878Z","etag":null,"topics":["finite-differences","grid","method-of-lines","stencil"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjodah.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-06T17:10:24.000Z","updated_at":"2024-11-18T00:37:27.000Z","dependencies_parsed_at":"2024-10-13T20:35:34.361Z","dependency_job_id":"d9f7f666-72f1-4521-b6ee-9fbb47c62b41","html_url":"https://github.com/bjodah/finitediff","commit_stats":{"total_commits":197,"total_committers":2,"mean_commits":98.5,"dds":"0.015228426395939132","last_synced_commit":"bfb1940cf5c7ce5c9a3b440d1efd8f8c4128fed8"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjodah%2Ffinitediff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjodah%2Ffinitediff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjodah%2Ffinitediff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjodah%2Ffinitediff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjodah","download_url":"https://codeload.github.com/bjodah/finitediff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302782,"owners_count":21567601,"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","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":["finite-differences","grid","method-of-lines","stencil"],"created_at":"2024-10-13T20:35:31.897Z","updated_at":"2025-04-28T11:16:54.609Z","avatar_url":"https://github.com/bjodah.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"finitediff\n==========\n.. image:: http://hackspett.bjodah.se/api/badges/12/status.svg\n   :target: http://hackspett.bjodah.se/repos/12\n   :alt: Build status\n.. image:: https://img.shields.io/pypi/v/finitediff.svg\n   :target: https://pypi.python.org/pypi/finitediff\n   :alt: PyPI version\n.. image:: https://zenodo.org/badge/14988640.svg\n   :target: https://zenodo.org/badge/latestdoi/14988640\n   :alt: Zenodo DOI\n.. image:: https://img.shields.io/pypi/l/finitediff.svg\n   :target: https://github.com/bjodah/finitediff/blob/master/LICENSE\n   :alt: License\n.. image:: http://hera.physchem.kth.se/~finitediff/branches/master/htmlcov/coverage.svg\n   :target: http://hera.physchem.kth.se/~finitediff/branches/master/htmlcov\n   :alt: coverage\n\n``finitediff`` containts three implementations of Begnt Fornberg's\nformulae for generation of finite difference weights on aribtrarily\nspaced one dimensional grids:\n\n- `C89 \u003csrc/finitediff_c.c\u003e`_\n- `Fortran 90 \u003csrc/finitediff_fort.f90\u003e`_\n- `C++ \u003cfinitediff/include/finitediff_templated.hpp\u003e`_\n\nThe finite difference weights can be\nused for optimized inter-/extrapolation data series for up to\narbitrary derivative order. Python_ bindings (to the C versions) are also provided.\n\n.. _Python: https://www.python.org\n.. _finitediff: https://github.com/bjodah/finitediff\n\n\nCapabilities\n------------\n``finitediff`` currently provides callbacks for estimation of derivatives\nor interpolation either at a single point or over an array (available\nfrom the Python bindings).\n\nThe user may also manually generate the corresponding weights. (see\n``calculate_weights``)\n\nFinitediff can be conditionally compiled to make ``finitediff_interpolate_by_finite_diff``\nmultithreaded (when ``FINITEDIFF_OPENMP`` is defined). Then the number of threads used is\nset through the environment variable ``FINITEDIFF_NUM_THREADS`` (or ``OMP_NUM_THREADS``).\n\n\nDocumentation\n-------------\nAutogenerated API documentation for latest stable release is found here:\n`\u003chttps://bjodah.github.io/finitediff/latest\u003e`_\n(and the development version for the current master branch is found here:\n`\u003chttp://hera.physchem.kth.se/~finitediff/branches/master/html\u003e`_).\n\nExamples\n--------\nGenerating finite difference weights is simple using C++11:\n\n.. code:: C++\n\n   #include \"finitediff_templated.hpp\"\n   #include \u003cvector\u003e\n   #include \u003cstring\u003e\n   #include \u003ciostream\u003e\n\n   int main(){\n       const unsigned max_deriv = 2;\n       std::vector\u003cstd::string\u003e labels {\"0th derivative\", \"1st derivative\", \"2nd derivative\"};\n       std::vector\u003cdouble\u003e x {0, 1, -1, 2, -2};  // Fourth order of accuracy\n       auto coeffs = finitediff::generate_weights(x, max_deriv);\n       for (unsigned deriv_i = 0; deriv_i \u003c= max_deriv; deriv_i++){\n           std::cout \u003c\u003c labels[deriv_i] \u003c\u003c \": \";\n           for (unsigned idx = 0; idx \u003c x.size(); idx++){\n               std::cout \u003c\u003c coeffs[deriv_i*x.size() + idx] \u003c\u003c \" \";\n           }\n           std::cout \u003c\u003c std::endl;\n       }\n   }\n\n\n::\n\n   $ cd examples/\n   $ g++ -std=c++11 demo.cpp -I../include\n   $ ./a.out\n   Zeroth derivative (interpolation): 1 -0 0 0 -0\n   First derivative: -0 0.666667 -0.666667 -0.0833333 0.0833333\n   Second derivative: -2.5 1.33333 1.33333 -0.0833333 -0.0833333\n\n\nand of course using the python bindings:\n\n.. code:: python\n\n   \u003e\u003e\u003e from finitediff import get_weights\n   \u003e\u003e\u003e import numpy as np\n   \u003e\u003e\u003e c = get_weights(np.array([0, -1., 1]), 0, maxorder=1)\n   \u003e\u003e\u003e np.allclose(c[:, 1], [0, -.5, .5])\n   True\n\n\nfrom Python you can also use the finite differences to interpolate\nvalues (or derivatives thereof):\n\n.. code:: python\n\n    \u003e\u003e\u003e from finitediff import interpolate_by_finite_diff as ifd\n    \u003e\u003e\u003e x = np.array([0, 1, 2])\n    \u003e\u003e\u003e y = np.array([[2, 3, 5], [3, 4, 7], [7, 8, 9], [3, 4, 6]])\n    \u003e\u003e\u003e xout = np.linspace(0.5, 1.5, 5)\n    \u003e\u003e\u003e r = ifd(x, y, xout, maxorder=2)\n    \u003e\u003e\u003e r.shape\n    (5, 4, 3)\n\n\nsee the ``examples/`` directory for more examples.\n\nInstallation\n------------\nSimplest way to install is to use the `conda package manager \u003chttp://conda.pydata.org/docs/\u003e`_:\n\n::\n\n   $ conda install -c conda-forge finitediff pytest\n   $ python -m pytest --pyargs finitediff\n\ntests should pass.\n\nManual installation\n~~~~~~~~~~~~~~~~~~~\nYou can install ``finitediff`` by using ``pip``::\n\n   $ python -m pip install --user finitediff\n\n(you can skip the ``--user`` flag if you have got root permissions),\nto run the tests you need ``pytest`` too::\n\n   $ python -m pip install --user --upgrade pytest\n   $ python -m pytest --pyargs finitediff\n\n\nDependencies\n------------\nYou need either a C, C++ or a Fortran 90 compiler. On debian based linux systems you may install (all) by issuing::\n\n    $ sudo apt-get install gfortran g++ gcc\n\nSee `setup.py \u003csetup.py\u003e`_ for optional (Python) dependencies.\n\n\nCiting\n------\nThe algortihm is from the following paper:\n\nhttp://dx.doi.org/10.1090/S0025-5718-1988-0935077-0\n\n::\n\n    @article{fornberg_generation_1988,\n      title={Generation of finite difference formulas on arbitrarily spaced grids},\n      author={Fornberg, Bengt},\n      journal={Mathematics of computation},\n      volume={51},\n      number={184},\n      pages={699--706},\n      year={1988}\n      doi={10.1090/S0025-5718-1988-0935077-0}\n    }\n\nYou may want to, in addition to the paper, cite finitediff (for e.g. reproducibility),\nand you can get per-version DOIs from the zenodo archive:\n\n.. image:: https://zenodo.org/badge/14988640.svg\n   :target: https://zenodo.org/badge/latestdoi/14988640\n   :alt: Zenodo DOI\n\n\nLicensing\n---------\nThe source code is Open Source and is released under the very permissive\n`\"simplified (2-clause) BSD license\" \u003chttps://opensource.org/licenses/BSD-2-Clause\u003e`_.\nSee `LICENSE \u003cLICENSE\u003e`_ for further details.\n\n\nAuthor\n------\nBjörn Ingvar Dahlgren (gmail address: bjodah). See file `AUTHORS \u003cAUTHORS\u003e`_ in root for a list of all authors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjodah%2Ffinitediff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjodah%2Ffinitediff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjodah%2Ffinitediff/lists"}