grad-methods: Compute gradients of a function

Description Usage Arguments Value Examples

Description

Compute gradients of a function with respect to one of its arguments

Usage

1
2
3
4
grad(f, argnum = 1L)

## S4 method for signature ''function''
grad(f, argnum = 1L)

Arguments

f

a function for which gradients should be computed

argnum

the number of the argument of the function for which gradients are computed

Value

the gradient of f w.r.t argnum

Examples

1
2
3
4
f <- function(x, y) {
  x + y
}
grad(f)(1.0, 1.0)

dirmeier/jar documentation built on Dec. 20, 2021, 12:03 a.m.