
These base constructors have been extended to keep the AD class attribute of the data argument.
# S4 method for advector,ANY,ANY
diag(x, nrow, ncol)# S4 method for advector
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
# S4 method for num.
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
Object of class "advector"
with a dimension attribute.
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'
Run the code above in your browser using DataLab