spires_step
Advance the reservoir by a single timestep, feeding in one input vector.
Signature
spires_status spires_step(spires_reservoir *r, const double *u_t);Parameters
| Parameter | Type | Description |
|---|---|---|
r | spires_reservoir * | Handle to the reservoir. Must not be NULL. |
u_t | const double * | Input vector for this timestep, of length num_inputs. May be NULL, in which case all inputs are treated as zero for this step. |
Returns
spires_status — SPIRES_OK on success, or SPIRES_ERR_INVALID_ARG if r is NULL.
Example
/* Step through a time series one sample at a time */
for (size_t t = 0; t < series_length; t++) {
const double *u = &input_series[t * num_inputs];
spires_status s = spires_step(r, u);
if (s != SPIRES_OK) {
fprintf(stderr, "step failed at t=%zu\n", t);
break;
}
/* Read out the current state or output after each step */
double y;
spires_compute_output(r, &y);
printf("t=%zu y=%.6f\n", t, y);
}Notes
- State update. Each call updates the internal neuron state vector according to the reservoir’s neuron model:
x(t+1) = f(W * x(t) + W_in * u(t)). The exact dynamics depend on theneuron_typeselected at creation time. - NULL input. Passing
u_t = NULLis equivalent to passing a zero vector. This is useful for “free-running” the reservoir without external drive, for example to observe the decay of transient dynamics. - No allocation. This function performs no heap allocation. It operates entirely on pre-allocated internal buffers.
- Thread safety. A given reservoir must not be stepped from multiple threads simultaneously. Different reservoirs may be stepped concurrently without issue.
- Fractional models. For
FLIF_*neuron types, each call tospires_stepappends to the internal history buffer used for the fractional derivative computation. The memory cost per step is O(1) forFLIF_GLandFLIF_DIFFUSIVE, but may vary forFLIF_CAPUTO.
See Also
- spires_run — drive the reservoir with an entire series in one call.
- spires_compute_output — read the output after stepping.
- spires_copy_reservoir_state — snapshot the state after stepping.
Last updated on