spires_run
Drive the reservoir with an entire input time series, collecting the state at every timestep.
Signature
double *spires_run(spires_reservoir *r, const double *input_series, size_t series_length);Parameters
| Parameter | Type | Description |
|---|---|---|
r | spires_reservoir * | Handle to the reservoir. Must not be NULL. |
input_series | const double * | Flattened input matrix of shape [series_length x num_inputs], stored in row-major order. Element input_series[t * num_inputs + i] is input channel i at timestep t. Must not be NULL. |
series_length | size_t | Number of timesteps in the input series. Must be greater than zero. |
Returns
double * — Pointer to a newly malloc-allocated array of shape [series_length x num_neurons], stored in row-major order. Element result[t * num_neurons + j] is the state of neuron j after processing timestep t.
Returns NULL if any argument is invalid or if memory allocation fails.
Example
size_t N = spires_num_neurons(r);
size_t T = 1000;
size_t ni = spires_num_inputs(r);
/* input_series has shape [T x ni], row-major */
double *states = spires_run(r, input_series, T);
if (!states) {
fprintf(stderr, "spires_run failed\n");
return 1;
}
/* states[t * N + j] is neuron j at timestep t */
for (size_t t = 0; t < T; t++) {
printf("t=%zu neuron_0=%.6f\n", t, states[t * N]);
}
free(states); /* caller must free */Notes
- Ownership. The returned array is allocated with
mallocand owned by the caller. You must callfree()on the returned pointer when it is no longer needed. Failing to do so will leakseries_length * num_neurons * sizeof(double)bytes. - Reservoir state. After
spires_runreturns, the reservoir’s internal state reflects the final timestep of the series (i.e., it is as ifspires_stepwas calledseries_lengthtimes). You can continue stepping, compute an output, or reset. - Memory layout. The returned matrix is row-major with one row per timestep and one column per neuron. This layout is directly compatible with the
input_series/target_seriesparameters ofspires_train_ridge. - No partial results. If allocation fails partway through,
NULLis returned and no partial data is available. The reservoir state is undefined in this case; callspires_reservoir_resetbefore reuse. - Thread safety. A given reservoir must not be used from multiple threads simultaneously. Different reservoirs may be run concurrently.
See Also
- spires_step — advance one timestep at a time.
- spires_train_ridge — train on the collected states.
- spires_reservoir_reset — reset state between runs.
Last updated on