ForDiff: A Fortran library for numerical differentiation
To use ForDiff
as a dependency in your fpm project, include the following line in your fpm.toml
file:
[dependencies]
fordiff = {git="https://github.com/gha3mi/fordiff.git"}
use fordiff
dfdx = derivative(f, x, h, method)
example/demo1.f90
demonstrates how to compute the derivative of a scalar-valued function w.r.t to a scalar variable using complex-step and finite-difference methods.
fpm run --example demo1
example/demo2.f90
demonstrates how to compute the derivative of a scalar-valued function w.r.t to a vector variable using complex-step and finite-difference methods.
fpm run --example demo2
example/demo3.f90
demonstrates how to compute the derivative of a vector-valued function w.r.t to a vector variable using complex-step and finite-difference methods.
fpm run --example demo3
The tests
directory contains test programs to verify the functionality of the fordiff
module. To run the tests using fpm
, you can use response files for specific compilers:
fpm @test-<compiler>
<compiler>: gfortran, ifx, ifort, nvfortran
- Complex-step: f(x) f is a scalar-valued function and x is a scalar variable
- Complex-step: f(x) f is a scalar-valued function and x is a vector variable
- Complex-step: f(x) f is a vector-valued function and x is a vector variable
- Finite Difference: f(x) f is a scalar-valued function and x is a scalar variable
- Finite Difference: f(x) f is a scalar-valued function and x is a vector variable
- Finite Difference: f(x) f is a vector-valued function and x is a vector variable
- Automatic Differentiation
The most up-to-date API documentation for the main branch is available
here.
To generate the API documentation for ForDiff
using
ford run the following
command:
ford ford.yml
Contributions to fordiff are welcome! If you find any issues or would like to suggest improvements, please open an issue or submit a pull request.