dual: Dual number constructor

Description Usage Arguments Value Examples

View source: R/class_dual_construction.R

Description

Dual number constructor

Usage

1
dual(x, param_dim, ind)

Arguments

x

The object to be converted to a dual number.

param_dim

A named list. The dimension of the dual component to be attached.

ind

Integer; the index in 'param_dim' corresponding to 'x'. Use '-1' if it is not applicable.

Value

A dual number with components "x" and "dx". The first gives the value of 'f', and the second gives the derivative of 'f'.

Examples

1
2
3
# Suppose X is a 2 x 2 matrix, Y is a 3 x 1 vector, Z is a 2 x 3 matrix, and
# we wish to attach dual components {dX, dY, dZ} to X.
dual(randn(2, 2), list(X = 4, Y = 3, Z = 6), ind = 1)

ADtools documentation built on Nov. 9, 2020, 5:09 p.m.