ADOLC.jl
A Julia wrapper of the automatic differentiation package ADOL-C
This package wraps the C/C++ automatic differentiation library ADOL-C for use in Julia.
Currently, the ADOL-C binaries are built for Julia 1.9, 1.10, and 1.11, and they are not compiled for musl libc. To add this package, use
To add this package, use
using Pkg; Pkg.add("ADOLC")
using ADOLCFirst- and second-order derivatives can be calculated as follows
f(x) = [x[1]*x[2]^2, x[1]^2*x[3]^3]
x = [1.0, 2.0, -1.0]
dir = [1.0, 0.0, 0.0]
weights = [1.0, 1.0]
res = derivative(f, x, :vec_hess_vec, dir=dir, weights=weights)
# output
3-element CxxVector:
 -2.0
  4.0
  6.0There are various available modes for first- and second-order calculations. The computation of higher-order derivatives is explained here and works as sketched below
f(x) = [x[1]^2*x[2]^2, x[3]^2*x[4]^2]
x = [1.0, 2.0, 3.0, 4.0]
partials = [[1, 1, 0, 0], [0, 0, 1, 1], [2, 2, 0, 0]]
res = derivative(f, x, partials)
# output
2×3 CxxMatrix:
 8.0   0.0  4.0
 0.0  48.0  0.0You can also define parameters (param) not used for differentiation, which can be changed  in subsequent calls without retaping. The given function f is expected to have the shape f(x, param):
function f(x, param)
    x1 = x[1] * param[1]
    return [x1*x[2], x[2]] 
end
x = [-1.0, 1/2]
param = 3.0
dir = [2.0, -2.0]
res = derivative(f, x, param, :jac_vec, dir=dir, tape_id=1)
##res[1] == 9.0
##res[2] == -2.0
param = -3.0
x = [1.0, 1.0]
res = derivative(f, x, param, :jac_vec, dir=dir, tape_id=1, reuse_tape=true)
res 
# output
2-element CxxVector:
  0.0
 -2.0In addition, there is the possibility to compute univariate Taylor polynomials with the univariate_tpp driver:
f(x) = sin(x[1]) + x[2]
x = [pi / 2, 0.5]
d = 2
utp = univariate_tpp(f, x, 2)
# output
1×3 CxxMatrix:
 1.5  1.0  -0.5More information can be found in the Guides.
For advanced users, there is a list of all functions, wrapped from ADOL-C.
API Reference
ADOLC.array_types.CxxMatrixADOLC.array_types.CxxTensorADOLC.array_types.CxxVectorADOLC.adolc_format_to_seed_spaceADOLC.allocatorADOLC.array_types.cxx_res_to_jl_resADOLC.array_types.cxx_res_to_jl_res!ADOLC.array_types.jl_res_to_cxx_resADOLC.array_types.jl_res_to_cxx_res!ADOLC.create_cxx_identityADOLC.create_independentADOLC.create_partial_cxx_identityADOLC.dependentADOLC.derivativeADOLC.derivative!ADOLC.function_and_derivative_value!ADOLC.init_abs_normal_formADOLC.jl_allocatorADOLC.partial_format_to_seed_spaceADOLC.partial_to_adolc_formatADOLC.partial_to_adolc_format!ADOLC.seed_idxs_adolc_formatADOLC.seed_idxs_partial_formatADOLC.tensor_addressADOLC.univariate_tppADOLC.univariate_tpp!
- [1]
 - A. Griewank, J. Utke and A. Walther. Evaluating higher derivative tensors by forward propagation of univariate Taylor series. Mathematics of Computation 69 (1999).
 - [2]
 - A. Griewank and A. Walther. 13. Taylor and Tensor Coefficients. In: Evaluating Derivatives (Society for Industrial and Applied Mathematics, 2008).
 - [3]
 - A. Griewank. On stable piecewise linearization and generalized algorithmic differentiation. Optimization Methods and Software 28 (2013).