Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Jan 25, 2024
1 parent 8e2361b commit 24528f4
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
**ForDiff**: A Fortran library for numerical differentiation


## Table of Contents

- [Table of Contents](#table-of-contents)
- [fpm dependency](#fpm-dependency)
- [Usage](#usage)
- [Run Demos](#run-demos)
- [Run Tests](#run-tests)
- [TO DO](#to-do)
- [TODO](#todo)
- [API documentation](#api-documentation)
- [Contributing](#contributing)

Expand All @@ -28,40 +26,29 @@ fordiff = {git="https://github.com/gha3mi/fordiff.git"}

## Usage

Here is an example of how to use the `fordiff` module in your Fortran code:
```fortran
module mod_func1
use kinds
implicit none
contains
function func1(x) result(f)
complex(rk), intent(in) :: x
complex(rk) :: f
f = x**2 + 2.0_rk*x
end function func1
end module mod_func1
use fordiff
dfdx = derivative(f, x, h, method)
```

program test1
## Run Demos

use kinds
use mod_func1
use fordiff
`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.

implicit none
```bash
fpm run --example demo1
```

real(rk) :: dfdx
`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.

dfdx = derivative(f=func1, x=1.0_rk, h=1e-100_rk)
```bash
fpm run --example demo2
```

print*,dfdx
`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.

end program test1
```bash
fpm run --example demo3
```

## Run Tests
Expand Down

0 comments on commit 24528f4

Please sign in to comment.