https://github.com/gha3mi/fordiff
ForDiff - A Fortran library for numerical differentiation
https://github.com/gha3mi/fordiff
complex-step-differentiation derivative differentiation finite-difference fortran fortran-package-manager
Last synced: about 1 month ago
JSON representation
ForDiff - A Fortran library for numerical differentiation
- Host: GitHub
- URL: https://github.com/gha3mi/fordiff
- Owner: gha3mi
- License: bsd-3-clause
- Created: 2023-07-02T19:32:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T08:21:21.000Z (over 1 year ago)
- Last Synced: 2025-02-06T04:51:27.574Z (3 months ago)
- Topics: complex-step-differentiation, derivative, differentiation, finite-difference, fortran, fortran-package-manager
- Language: Fortran
- Homepage: https://gha3mi.github.io/fordiff/
- Size: 700 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/gha3mi/fordiff)
[](https://github.com/gha3mi/fordiff/releases/latest)
[](https://gha3mi.github.io/fordiff/)
[](https://github.com/gha3mi/fordiff/blob/main/LICENSE)
[](https://github.com/gha3mi/fordiff/actions/workflows/CI_test.yml)**ForDiff**: A Fortran library for numerical differentiation
- [fpm dependency](#fpm-dependency)
- [Usage](#usage)
- [Run Demos](#run-demos)
- [Run Tests](#run-tests)
- [TODO](#todo)
- [API documentation](#api-documentation)
- [Contributing](#contributing)## fpm dependency
To use `ForDiff` as a dependency in your fpm project, include the following line in your `fpm.toml` file:
```toml
[dependencies]
fordiff = {git="https://github.com/gha3mi/fordiff.git"}
```## Usage
```fortran
use fordiff
dfdx = derivative(f, x, h, method)
```## Run Demos
`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.
```bash
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.
```bash
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.
```bash
fpm run --example demo3
```## Run Tests
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:
```bash
fpm @test-
````: gfortran, ifx, ifort, nvfortran`
## TODO
- [x] Complex-step: f(x) f is a scalar-valued function and x is a scalar variable
- [x] Complex-step: f(x) f is a scalar-valued function and x is a vector variable
- [x] Complex-step: f(x) f is a vector-valued function and x is a vector variable
- [x] Finite Difference: f(x) f is a scalar-valued function and x is a scalar variable
- [x] Finite Difference: f(x) f is a scalar-valued function and x is a vector variable
- [x] Finite Difference: f(x) f is a vector-valued function and x is a vector variable
- [ ] Automatic Differentiation## API documentation
The most up-to-date API documentation for the main branch is available
[here](https://gha3mi.github.io/fordiff/).
To generate the API documentation for `ForDiff` using
[ford](https://github.com/Fortran-FOSS-Programmers/ford) run the following
command:```shell
ford ford.yml
```## Contributing
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.