ADconstruct: AD aware numeric constructors

ADconstructR Documentation

AD aware numeric constructors

Description

These base constructors have been extended to keep the AD class attribute of the data argument.

Usage

## S4 method for signature 'advector,ANY,ANY'
diag(x, nrow, ncol)

## S4 method for signature 'advector'
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)

## S4 method for signature 'num.'
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)

Arguments

x

As diag

nrow

As matrix

ncol

As matrix

data

As matrix

byrow

As matrix

dimnames

As matrix

Value

Object of class "advector" with a dimension attribute.

Functions

  • diag(x = advector, nrow = ANY, ncol = ANY): Equivalent of diag

  • matrix(advector): Equivalent of matrix

  • matrix(num.): Equivalent of matrix

Examples

func <- function(x) {
  M <- matrix(x, 2, 2)
  print(class(M))
  D <- diag(x)
  print(class(D))
  0
}
invisible(func(1:4))            ## 'matrix' 'array'
invisible(MakeTape(func, 1:4))  ## 'advector'

RTMB documentation built on Sept. 12, 2024, 6:45 a.m.