Description Usage Arguments Details Value See Also Examples
Inferface to the integration over function dimensions.
1 2 3 | nint_integrateNFunc(f, funcs, x0, i0, ...)
nint_integrateNFunc_recursive(integrate1)
|
integrate1 |
|
f |
the scalar-valued wrapper function to be integrated. |
funcs |
the list of function dimensions. |
x0 |
the partially realized point in the space. |
i0 |
the vector of indices of function dimensions in the space. |
... |
other arguments passed to |
nint_integrate
uses nint_integrateNFunc
to handle function dimensions.
See examples below on how to deploy different solutions.
The function built by nint_integrateNFunc_recursive
directly sums over discrete dimensions and uses integrate1
otherwise.
In conjunction with integrateA
this is the default.
nint_integrateNFunc
returns a single numeric.
nint_integrateNFunc_recursive
returns a recursive implementation for nint_integrateNFunc
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | dfltNFunc = nint_integrateNFunc
## area of circle
s = nint_space(
nint_intvDim(-1, 1),
nint_funcDim(function(x) nint_intvDim(c(-1, 1) * sin(acos(x[1])) ))
)
nint_integrate(function(x) 1, s) # pi
## see nint_integrate's examples for more sophisticated integrals
## prepare for custom recursive implementation
using = TRUE
nfunc = nint_integrateNFunc_recursive(
function(f, lowerLimit, upperLimit, ...) {
if (using) { # this function is called many times
using <<- FALSE
cat('using integrateA\n')
}
integrateA(f, lowerLimit, upperLimit, ..., subdivisions=1)$value
}
)
unlockBinding('nint_integrateNFunc', environment(nint_integrate))
assign('nint_integrateNFunc', nfunc, envir=environment(nint_integrate))
## integrate with custom recursive implementation
nint_integrate(function(x) 1, s) # pi
## prepare for custom solution
f = function(f, funcs, x0, i0, ...) {
# add sophisticated code here
print(list(f=f, funcs=funcs, x0=x0, i0=i0, ...))
stop('do something')
}
unlockBinding('nint_integrateNFunc', environment(nint_integrate))
assign('nint_integrateNFunc', f, envir=environment(nint_integrate))
## integrate with custom solution
try(nint_integrate(function(x) 1, s))
assign('nint_integrateNFunc', dfltNFunc, envir=environment(nint_integrate))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.