value: Get value from AD type

Description Usage Arguments Value Examples

Description

Get value from AD type

Usage

1
value(y)

Arguments

x

An ADtype or AD_matrix type (overloaded also for numeric and matrix types)

Value

The value of the AD type

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# define some function
f <- function(x){ 
M <- matrix(x,2,2)
return(sum(solve(M,c(-1,2))))
}

# run function with regular variables
print(f(c(1,-1,2,4)))

# run function with second order AD-variables
x <- independent2(c(1,-1,2,4))
y <- f(x)
print(value(y))
print(gradient(y))
print(hessian(y))

torekleppe/RAutoDiff documentation built on Dec. 23, 2021, noon