Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSiebert1 authored Jan 6, 2024
1 parent 5f07e90 commit 950a3ba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This package wraps the C/C++ automatic differentation library [ADOL-C](https://g
1. git clone the repo
2. use the commands `cd ADOLC_wrap/src && julia --project build.jl`
3. check if its works by using `cd .. && julia --project examples/gradient.jl`
4. Use the ADOLC functions by import the package with `include("/path/to/ADOLC_wrap/src/ADOLC_wrap.jl"); using .ADOLC_wrap.Adouble` or `using .ADOLC_wrap.TlAdouble` for tape-based and tape-less ADOLC
4. Use the ADOLC functions by import the package with `include("/path/to/ADOLC_wrap/src/ADOLC_wrap.jl"); using .ADOLC_wrap.AdoubleModule` or `using .ADOLC_wrap.TladoubleModule` for tape-based and tape-less ADOLC.

## Example
After including the package,
```julia
include("/path/to/ADOLC_wrap/src/ADOLC_wrap.jl")
using .ADOLC_wrap.Adouble
using .ADOLC_wrap.AdoubleModule
```
define the function you are planning to differentiate.
```julia
Expand All @@ -22,7 +22,7 @@ end
Then define the point for the derivative, initialize a vector of adoubles and initiaize the output value of the function. The output value is in the end needed to speciy the dependent variable.
```julia
x = [-1.5, 2.0]
a = [adouble() for _ in 1:2]
a = [AdoubleCxx() for _ in 1:2]
y = 0.0
```
Like in ADOLC, you have to use the `trace_on` and `trace_off` functions to start and end the recording of the operations on the tape. The `trace_on` function requires a specifier for the tape, i.e. a corresponding integer. The `trace_off` has to called with 0 or 1 to specify, whether the tape has to be stored or not. For more information you might look into the [ADOLC-manual](https://usermanual.wiki/Pdf/adolcmanual.230286982/view). The tape is then used to calculate the derivative. Between the `trace_on` and `trace_off` function you have to specify the independent variables with `<<` and dependent variables by `>>`. These operators also set the values of `a` and `y`.
Expand Down Expand Up @@ -54,7 +54,7 @@ Note, in contrast to someones expectation some functions like `max` does not con
For this example we utilize the abs-normal interface of ADOLC. To use the interface load the libraries
```julia
include("/PATH/TO/ADOLC_wrap/src/ADOLC_wrap.jl")
using .ADOLC_wrap.Adouble
using .ADOLC_wrap.AdoubleModule
using .ADOLC_wrap
```
Enable the abs-normal functionalities by calling
Expand All @@ -73,8 +73,8 @@ x = [-0.500000, -0.500000, -0.500000]
n = length(x)
y = Vector{Float64}(undef, 1)
m = length(y)
a = [adouble() for _ in 1:length(x)]
b = [adouble() for _ in 1:length(y)]
a = [AdoubleCxx() for _ in 1:length(x)]
b = [AdoubleCxx() for _ in 1:length(y)]
```
Like in the previous example, the function is evaluated by calling it with the vector of adoubles `a` and everything is recored on the tape.
```julia
Expand Down Expand Up @@ -135,4 +135,4 @@ using Test
@test abs_normal_problem.L[2, 2] == 0.0
```

Further examples can be found in the `examples` file.
This and further examples can be found in the `examples` file.

0 comments on commit 950a3ba

Please sign in to comment.