ADiMat comes with a set of Matlab functions. The most prominent are the derivative classes, which are described in a seperate chapter. In this chapter we describe the funtions that make up the ADiMat runtime environment.

**admDiffFor(function, S, arg1, ..., argN, opts?)**-
Differentiate function and compute the product J*S of the Jacobian matrix J at arguments arg1, ..., argN and the seed matrix S. The computational expense depends linearly on the number of columns of S.

**admDiffFor(@f, 1, a, b, c)**returns the full Jacobian matrix of function f evaluated at the point (a, b, c). The value of 1 for the seed matrix is a shortcut for the identity matrix of the right size.**admDiffFor(@f, [1 1 1]', 1, 2, 3)**returns the column sum of the Jacobian matrix of function f evaluated at the point (1, 2, 3). **admDiffVFor(function, S, arg1, ..., argN, opts?)**-
Differentiate function and compute the product J*S of the Jacobian matrix J at arguments arg1, ..., argN and the seed matrix S. The computational expense depends linearly on the number of columns of S.

This function uses the new forward mode. Otherwise the functionality is the same.

**admDiffRev(function, S, arg1, ..., argN, opts?)**-
Differentiate function in reverse mode and compute the product S*J of the the seed matrix S and the Jacobian matrix J at arguments arg1, ..., argN. The computational expense depends linearly on the number of rows of S.

**admDiffRev(@f, 1, a, b, c)**returns the full Jacobian matrix of function f evaluated at the point (a, b, c).**admDiffRev(@f, [1 1 1], 1, 2, 3)**returns the row sum of the Jacobian matrix of function f evaluated at the point (1, 2, 3). **admTaylorFor(function, S, arg1, ..., argN, opts?)**-
Compute unvariate Taylor coefficients of function, with OO, see Higher order derivatives

**admTaylorFor(function, S, arg1, ..., argN, opts?)**-
Compute unvariate Taylor coefficients of function, with FM ST, see Higher order derivatives

**admTaylorRev(function, S, arg1, ..., argN, opts?)**-
Compute derivatives of unvariate Taylor coefficients of function, with OO applyied to function differentiated in RM, see Higher order derivatives

**admHessian(function, S, arg1, ..., argN, opts?)**-
Compute Hessian of function, using one of several strategies, by default FM-over-RM, see Higher order derivatives

**admHessFor(function, S, arg1, ..., argN, opts?)****admHessVFor(function, S, arg1, ..., argN, opts?)****admHessFD(function, S, arg1, ..., argN, opts?)**-
Compute Hessian of function via second order Taylor coefficients, see Higher order derivatives

**admDiffFor2(function, S, arg1, ..., argN, opts?)**-
Compute Hessian of function via second order FM differntiation, see Higher order derivatives

**admDiffComplex(function, S, arg1, ..., argN, opts?)**-
Differentiate function and compute the product J*S of the Jacobian matrix J at arguments arg1, ..., argN and the seed matrix S. The computational expense depends linearly on the number of columns of S.

This function does not do AD at all, but instead uses the so called complex variable method to compute derivatives. The results are equally precise as those returned by AD, provided the function is real and analytic. This functions is provided in order to facilitate the comparison of AD results with the complex variable method.

**admDiffFD(function, S, arg1, ..., argN, opts?)**-
This function does not do AD at all, but instead uses divided differences to evaluate the derivatives approximately. The results are at best precise up to half of the machines matissa bits, but may be less precise when the differential step h is chosen carefully. Use the field ddStep of the admOptions structure to adjust the differential step h to your function. This functions is provided in order to facilitate the comparison of AD results with divided differences.

**admOptions(name1?, value1?, name2?, value2?, ...)**-
Create a structure that can be used to pass options to the admDiff* functions, as the last parameter, called

`opts`

in the synopses above.

**admTransform(function, indeps, deps, flags)**-
Matlab frontend to

**adimat-client**(or**admproc**, if present). Differentiate`function`

using ADiMat.`function`

can be a filename as a string or a function handle.`flags`

is a string which is added to the adimat-client command line.`indeps`

and`deps`

are strings containing comma separated lists of variable names or positions.admTransform works by executing the program adimat-client (or admproc, if present) via the

**system**builtin. The builtin**which**is used to determine the path and filename of function. admTransform will automatically add the options -I and -p with appropriate arguments to the command line, for adding the directory where the file resides to ADiMat's search path and writing the transformed file to the same directory. You can override the output directory by providing your own -p option in flags.**admTransform(function)**transforms the function in classic forward mode.**admTransform(function, indeps, deps, '-F')**is the same.**admTransform(function, indeps, deps, '-f')**transforms the function in the new forward mode.**admTransform(function, indeps, deps, '-r')**transforms the function in the reverse mode.**admTransform(function, [1], [2], mode)**transforms the function such that you can compute the derivative of the second output parameter w.r.t. the first input parameter of the function. **addiff(function, indeps, deps, flags)**-
Deprecated: This function is now just a synonym for admTransform.

**admrev(function, indeps, deps, flags)**-
Deprecated: This function is now just a synonym for admTransform.

**admClean(baseDir?, modes?)**-
This function deletes the ADiMat-generated functions from the directory

`baseDir`

. With the string`modes`

you can choose which kind of files will be deleted. The letters in the string correspond to the mode flags (see Modes and toolchains), plus`'s'`

which refers to the status directory`.adimat`

.Warning: Use this function with some care as the file name patterns might also match some other files!

**adimat_derivclass(name)**-
Select the derivative class. This merely modifies the Matlab path. For a description of the classes, see The derivative classes. If

`name`

is the string 'list', a list of available classes is returned. With no argument, the name of the currently loaded derivative class is returned. **adimat_adjoint(name)**-
Select the adjoint class. This merely modifies the Matlab path. There are two options, 'default' and 'scalar'. With no argument, the name of the currently loaded adjoint class is returned.

**g_zeros(sz)**-
This is the most prominent runtime function found in the transformed source code. Returns zero derivative objects of dimension sz of the derivative class that is currently in use (see adimat_derivclass). In the case of scalar_directderivs, simply returns zeros(sz), i.e. a plain double array.

**a_zeros(v)**-
When adimat_adjoint is 'default', then returns g_zeros(size(v)) to return zero adjoint objects. When adimat_adjoint is 'scalar' then returns zeros(size(v)), i.e. a plain double array.

**adimat_stack(name)**-
Select the stack implementation. All stacks are implemented via a single function adimat_store. This function switches the path to various directories where different implementations of adimat_store reside. If

`name`

is the string 'list', a list of available impletations is returned. With no argument, the name of the currently loaded stack is returned. **adimat_push(v1, ...)**-
Push values on the stack. Takes any number of arguments.

**[v1, ...] = adimat_pop**-
Pop values from the stack. Returns any number of output arguments, but one value is always removed from the stack.

**adimat_store(mode, v?)**-
Operate on the stack according to mode:

- 0 pop one value and return it
- 1 push value v on the stack, return number of values on stack
- 2 clear the stack, delete all values, return number of values on stack
- 3 return size of stack
- 4 return size of stack in bytes. Not always available, maybe 0.
- 5 flush the stack to disk. Not always available.
- 6 return size of stack stored on disk, in bytes. Not always available, maybe 0.

**adimat_clear_stack**-
Calls adimat_store(2)

**adimat_stack_size**-
Calls adimat_store(3)

**adimat_stack_byte_size**-
Calls adimat_store(4)

**adimat_stack_file_size**-
Calls adimat_store(6)

**adimat_flush_stack**-
Calls adimat_store(5)

**adimat_stack_buffer_size(bytes)**-
Sets the size of the buffer used by the stack implementations with "buffered" in their name.

**adimat_aio_init(numThreads, numBuffers)**-
Sets the parameters of the aio.h API calling aio_init. Used by the stack implementations with "abuffered" in their name.

**adimat_stack_prefetch(n)**-
Sets a parameter of the aio.h based streambuffer, controlling how many preceding blocks of memory to prefetch when a read is being waited for.

**adimat_adjred****adimat_multl, adimat_multm and adimat_multlr**

Next Previous Contents