difeq | R Documentation |
Solve a difference (or recurrence) equation by iterating it a number of times.
difeq(y, steps, target, parms, ..., n_out = 0L, n_history = 0L,
grow_history = FALSE, return_history = n_history > 0, dllname = "",
parms_are_real = TRUE, ynames = names(y), outnames = NULL,
return_by_column = TRUE, return_initial = TRUE, return_step = TRUE,
return_output_with_y = TRUE, restartable = FALSE,
return_minimal = FALSE)
difeq_continue(obj, steps, y = NULL, ..., copy = FALSE, parms = NULL,
return_history = NULL, return_by_column = NULL, return_initial = NULL,
return_step = NULL, return_output_with_y = NULL, restartable = NULL)
yprev(step, i = NULL)
y |
The initial state of the system. Must be a numeric
vector (and will be passed through |
steps |
A vector of steps to return the system at. The
first step is taken as step zero, and the solution will
be recorded at every other step in the vector. So to step a
system from time zero to times 1, 2, 3, ..., n use 0:n. Must be
integer values and will be passed through |
target |
The target function to advance. This can either be
an R function taking arguments |
parms |
Parameters to pass through to the difference function |
... |
Dummy arguments - nothing is allowed here, but this means that all further arguments must be specified by name (not order) so I can easily reorder them later on. |
n_out |
The number of output variables (in addition to the
difference equation variables). If given, then an R function
must return an attribute |
n_history |
The number of iterations of history to save during the simulation. By default, no history is saved. |
grow_history |
Logical indicating if history should be grown
during the simulation. If |
return_history |
Logical indicating if history is to be
returned. By default, history is returned if |
dllname |
Name of the shared library (without extension) to
find the function |
parms_are_real |
Logical, indicating if |
ynames |
Logical, indicating if the output should be named
following the names of the input vector |
outnames |
An optional character vector, used when
|
return_by_column |
Logical, indicating if the output should be
returned organised by column (rather than row). This incurs a
slight cost for transposing the matrices. If you can work with
matrices that are transposed relative to |
return_initial |
Logical, indicating if the output should
include the initial conditions. Specifying |
return_step |
Logical, indicating if a row (or column if
|
return_output_with_y |
Logical, indicating if the output
should be bound together with the returned matrix |
restartable |
Logical, indicating if the problem should be
restartable. If |
return_minimal |
Shorthand option - if set to |
obj |
An object to continue from; this must be the results of
running a simulation with the option |
copy |
Logical, indicating if the pointer should be copied
before continuing. If |
step |
The step to access (not that this is not an offset,
but the actual step; within your target function you'd write
things like |
i |
index within the state vector |
# Here is a really simple equation that just increases by 'p' each
# time (p is the parameter vector and could be any R structure).
rhs <- function(i, y, p) y + p
y0 <- 1
t <- 0:10
p <- 5
dde::difeq(y0, t, rhs, p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.