+.objlist | R Documentation |
Add two lists element by element
## S3 method for class 'objlist'
out1 + out2
out1 |
List of numerics or matrices |
out2 |
List with the same structure as out1 (there will be no warning when mismatching) |
If out1 has names, out2 is assumed to share these names. Each element of the list out1
is inspected. If it has a names
attributed, it is used to do a matching between out1 and out2.
The same holds for the attributed dimnames
. In all other cases, the "+" operator is applied
the corresponding elements of out1 and out2 as they are.
List of length of out1.
objlist1 <- dMod:::init_empty_objlist(c(a = 1, b = 2))
objlist1$value = 1; objlist1$gradient[1:2] <- 1; objlist1$hessian[1:4] <- 1
objlist2 <- dMod:::init_empty_objlist(c(a = 1, d = 2))
objlist2$value = 1; objlist2$gradient[1:2] <- 1; objlist2$hessian[1:4] <- 1
objlist1 + objlist2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.