mesh_exsets: Search excursion set of nD function, sampled by a mesh

mesh_exsetsR Documentation

Search excursion set of nD function, sampled by a mesh

Description

Search excursion set of nD function, sampled by a mesh

Usage

mesh_exsets(
  f,
  vectorized = FALSE,
  threshold,
  sign,
  intervals,
  mesh.type = "seq",
  mesh.sizes = 11,
  maxerror_f = 1e-09,
  tol = .Machine$double.eps^0.25,
  ex_filter.tri = all,
  ...
)

Arguments

f

Function to inverse at 'threshold'

vectorized

boolean: is f already vectorized ? (default: FALSE) or if function: vectorized version of f.

threshold

target value to inverse

sign

focus at conservative for above (sign=1) or below (sign=-1) the threshold

intervals

bounds to inverse in, each column contains min and max of each dimension

mesh.type

"unif" or "seq" (default) or "LHS" to preform interval partition

mesh.sizes

number of parts for mesh (duplicate for each dimension if using "seq")

maxerror_f

maximal tolerance on f precision

tol

the desired accuracy (convergence tolerance on f arg).

ex_filter.tri

boolean function to validate a geometry::tri as considered in excursion : 'any' or 'all'

...

parameters to forward to roots_mesh(...) call

Examples

# mesh_exsets(function(x) x, threshold=.51, sign=1, intervals=rbind(0,1),
#   maxerror_f=1E-2,tol=1E-2) # for faster testing
# mesh_exsets(function(x) x, threshold=.50000001, sign=1, intervals=rbind(0,1),
#   maxerror_f=1E-2,tol=1E-2) # for faster testing
# mesh_exsets(function(x) sum(x), threshold=.51,sign=1, intervals=cbind(rbind(0,1),rbind(0,1)),
#   maxerror_f=1E-2,tol=1E-2) # for faster testing
# mesh_exsets(sin,threshold=0,sign="sup",interval=c(pi/2,5*pi/2),
#   maxerror_f=1E-2,tol=1E-2) # for faster testing

if (identical(Sys.getenv("NOT_CRAN"), "true")) { # too long for CRAN on Windows

  e = mesh_exsets(function(x) (0.25+x[1])^2+(0.5+x[2])^2 ,
                threshold =0.25,sign=-1, intervals=matrix(c(-1,1,-1,1),nrow=2),
                maxerror_f=1E-2,tol=1E-2) # for faster testing

  plot(e$p,xlim=c(-1,1),ylim=c(-1,1));
  apply(e$tri,1,function(tri) polygon(e$p[tri,],col=rgb(.4,.4,.4,.4)))

  if (requireNamespace("rgl")) {
    e = mesh_exsets(function(x) (0.5+x[1])^2+(-0.5+x[2])^2+(0.+x[3])^2,
                  threshold = .25,sign=-1, mesh.type="unif",
                  intervals=matrix(c(-1,1,-1,1,-1,1),nrow=2),
                  maxerror_f=1E-2,tol=1E-2) # for faster testing

    rgl::plot3d(e$p,xlim=c(-1,1),ylim=c(-1,1),zlim=c(-1,1));
    apply(e$tri,1,function(tri)rgl::lines3d(e$p[tri,]))
  }
}

IRSN/DiceView documentation built on Jan. 31, 2024, 10:09 a.m.