This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

finitediff

finitediff containts two implementations (Fortran 90 and C++) version of Begnt Fornberg’s formulae for generation of finite difference weights on aribtrarily spaced one dimensional grids. The finite difference weights can be used for optimized inter-/extrapolation data series for up to arbitrary derivative order. Python bindings are provided.

Capabilities

finitediff currently provides callbacks for estimation of derivatives or interpolation either at a single point or over an array (available from the Python bindings).

The user may also manually generate the corresponding weights. (see calculate_weights)

Documentation

Autogenerated API documentation for latest stable release is found here: https://pythonhosted.org/finitediff (and development docs for the current master branch are found here: http://hera.physchem.kth.se/~finitediff/branches/master/html).

Examples

Generating finite difference weights is simple using C++11:

#include "finitediff_templated.hpp"
#include <vector>
#include <string>
#include <iostream>

int main(){
    const unsigned max_deriv = 2;
    std::vector<std::string> labels {"0th derivative", "1st derivative", "2nd derivative"};
    std::vector<double> x {0, 1, -1, 2, -2};  // Fourth order of accuracy
    auto coeffs = finitediff::generate_weights(x, max_deriv);
    for (unsigned deriv_i = 0; deriv_i <= max_deriv; deriv_i++){
        std::cout << labels[deriv_i] << ": ";
        for (unsigned idx = 0; idx < x.size(); idx++){
            std::cout << coeffs[deriv_i*x.size() + idx] << " ";
        }
        std::cout << std::endl;
    }
}
$ cd examples/
$ g++ -std=c++11 demo.cpp -I../include
$ ./a.out
Zeroth derivative (interpolation): 1 -0 0 0 -0
First derivative: -0 0.666667 -0.666667 -0.0833333 0.0833333
Second derivative: -2.5 1.33333 1.33333 -0.0833333 -0.0833333

and of course using the python bindings:

>>> from finitediff import get_weights
>>> import numpy as np
>>> c = get_weights(np.array([-1., 0, 1]), 0, maxorder=1)
>>> np.allclose(c[:, 1], [-.5, 0, .5])
True

see the examples/ directory for more examples.

Installation

Simplest way to install finitediff is to use the Conda package manager:

$ conda install -c bjodah finitediff pytest

alternatively you may also use pip:

$ python -m pip install --user finitediff

(you can skip the --user flag if you have got root permissions), to run the tests you need pytest too:

$ python -m pip install --user --upgrade pytest
$ python -m pytest --pyargs finitediff

Dependencies

You need either a C++ or a Fortran 90 compiler. On a debian based linux system you can install it easily by typing:

$ sudo apt-get install gfortran g++

Optional dependencies (for Python bindings):

  • Python header files (sudo apt-get install python-dev)
  • Python
  • NumPy
  • Cython
  • pycompilation
  • pytest

see CI scripts for examples.

For building documentation, running tests for releasing etc you need:

  • pytest-pep8
  • pytest-flakes
  • sphinx
  • sphinx_rtd_theme
  • numpydoc
  • twine
  • sphinx-pypi-upload

Notes

There is a git subtree under finitediff, update through:

git subtree pull --prefix finitediff/newton_interval newton_interval master --squash

where the repo “newton_interval” is https://github.com/bjodah/newton_interval.git

First time you need to add it:

git subtree add --prefix finitediff/newton_interval git://github.com/bjodah/newton_interval master

(Users of Ubuntu 12.04 who want to use git subtree, see http://stackoverflow.com/questions/17797328)

References

The algortihm is a Fortran 90 rewrite of:

http://dx.doi.org/10.1137/S0036144596322507

@article{fornberg_classroom_1998,
  title={Classroom note: Calculation of weights in finite difference formulas},
  author={Fornberg, Bengt},
  journal={SIAM review},
  volume={40},
  number={3},
  pages={685--691},
  year={1998},
  publisher={SIAM}
  doi={10.1137/S0036144596322507}
}

Which is based on an article of the same author:

http://dx.doi.org/10.1090/S0025-5718-1988-0935077-0

@article{fornberg_generation_1988,
  title={Generation of finite difference formulas on arbitrarily spaced grids},
  author={Fornberg, Bengt},
  journal={Mathematics of computation},
  volume={51},
  number={184},
  pages={699--706},
  year={1988}
  doi={10.1090/S0025-5718-1988-0935077-0}
}

License

Open Source. Released under the very permissive “simplified (2-clause) BSD license”. See LICENSE.txt for further details.

Authors

See file AUTHORS in root.

Release History

Release History

0.3.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
finitediff-0.3.2.tar.gz (117.6 kB) Copy SHA256 Checksum SHA256 Source Sep 7, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting