tests/testthat/optimCheck-testfunctions.R

#--- package test functions ----------------------------------------------------

# generate an n x p matrix of iid N(0,1)
rMnorm <- function(n, p) {
  if(missing(p)) p <- n
  matrix(rnorm(n*p), n, p)
}

# max of min of abs and rel error
max.xdiff <- function(x) {
  xdiff <- abs(diff(x))
  max(pmin(xdiff[,1], xdiff[,2]))
}
mlysy/optimCheck documentation built on May 25, 2019, 10:31 p.m.