You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generates a function that computes the observed value(s) `ts` in the system `sys`, while making the assumption that there are no cycles in the equations.
415
+
416
+
## Arguments
417
+
- `sys`: The system for which to generate the function
418
+
- `ts`: The symbolic observed values whose value should be computed
419
+
420
+
## Keywords
421
+
- `return_inplace = false`: If true and the observed value is a vector, then return both the in place and out of place methods.
422
+
- `expression = false`: Generates a Julia `Expr`` computing the observed value if `expression` is true
423
+
- `eval_expression = false`: If true and `expression = false`, evaluates the returned function in the module `eval_module`
424
+
- `output_type = Array` the type of the array generated by a out-of-place vector-valued function
425
+
- `param_only = false` if true, only allow the generated function to access system parameters
426
+
- `inputs = nothing` additinoal symbolic variables that should be provided to the generated function
427
+
- `checkbounds = true` checks bounds if true when destructuring parameters
428
+
- `op = Operator` sets the recursion terminator for the walk done by `vars` to identify the variables that appear in `ts`. See the documentation for `vars` for more detail.
429
+
- `throw = true` if true, throw an error when generating a function for `ts` that reference variables that do not exist.
430
+
- `mkarray`; only used if the output is an array (that is, `!isscalar(ts)` and `ts` is not a tuple, in which case the result will always be a tuple). Called as `mkarray(ts, output_type)` where `ts` are the expressions to put in
431
+
the array and `output_type` is the argument of the same name passed to build_explicit_observed_function.
432
+
433
+
## Returns
434
+
435
+
The return value will be either:
436
+
* a single function `f_oop` if the input is a scalar or if the input is a Vector but `return_inplace` is false
437
+
* the out of place and in-place functions `(f_ip, f_oop)` if `return_inplace` is true and the input is a `Vector`
438
+
439
+
The function(s) `f_oop` (and potentially `f_ip`) will be:
440
+
* `RuntimeGeneratedFunction`s by default,
441
+
* A Julia `Expr` if `expression` is true,
442
+
* A directly evaluated Julia function in the module `eval_module` if `eval_expression` is true and `expression` is false.
443
+
444
+
The signatures will be of the form `g(...)` with arguments:
445
+
446
+
- `output` for in-place functions
447
+
- `unknowns` if `param_only` is `false`
448
+
- `inputs` if `inputs` is an array of symbolic inputs that should be available in `ts`
449
+
- `p...` unconditionally; note that in the case of `MTKParameters` more than one parameters argument may be present, so it must be splatted
450
+
- `t` if the system is time-dependent; for example `NonlinearSystem` will not have `t`
451
+
452
+
For example, a function `g(op, unknowns, p..., inputs, t)` will be the in-place function generated if `return_inplace` is true, `ts` is a vector,
453
+
an array of inputs `inputs` is given, and `param_only` is false for a time-dependent system.
416
454
"""
417
455
functionbuild_explicit_observed_function(sys, ts;
418
456
inputs =nothing,
@@ -421,12 +459,12 @@ function build_explicit_observed_function(sys, ts;
421
459
eval_module =@__MODULE__,
422
460
output_type = Array,
423
461
checkbounds =true,
424
-
drop_expr = drop_expr,
425
462
ps =parameters(sys),
426
463
return_inplace =false,
427
464
param_only =false,
428
465
op = Operator,
429
-
throw =true)
466
+
throw =true,
467
+
mkarray = MakeArray)
430
468
is_tuple = ts isa Tuple
431
469
if is_tuple
432
470
ts =collect(ts)
@@ -582,7 +620,7 @@ function build_explicit_observed_function(sys, ts;
0 commit comments