Skip to contents

A step of the cgnonl_native implementation. Called by cgnonl_nonlinear_cg. See the file header for the source the module follows.

Usage

cgnonl_line_search_fr(
  f,
  grad,
  x,
  p,
  f0,
  g0,
  est = NULL,
  max_double = 60L,
  max_cubic = 40L,
  tol = 1e-12
)

Arguments

f

Accepted by the signature and not used anywhere in the body.

grad

Accepted by the signature and not used anywhere in the body.

x

A vector; its length is taken.

p

Numeric; combined arithmetically in the body.

f0

Numeric; combined arithmetically in the body.

g0

Passed to .cgnonl_dot.

est

Optional; may be NULL. Coerced to numeric by the body, with as.numeric.

max_double

A count; the body uses it as seq_len(...). Defaults to 60L.

max_cubic

A count; the body uses it as seq_len(...). Defaults to 40L.

tol

Numeric; combined arithmetically in the body. Defaults to 1e-12.

Value

A list with t, x, f, g, n_eval.

Examples

f <- function(x) sum((x - 1)^2); g <- function(x) 2 * (x - 1)
x <- c(0, 0); p <- -g(x)
cgnonl_line_search_fr(f, g, x, p, f0 = f(x), g0 = g(x))$t   # exact step 0.5
#> [1] 0.5