Skip to contentSkip to Content

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

ParameterTypeDescription
rspires_reservoir *Handle to the reservoir. Must not be NULL.
input_seriesconst 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_lengthsize_tNumber 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 malloc and owned by the caller. You must call free() on the returned pointer when it is no longer needed. Failing to do so will leak series_length * num_neurons * sizeof(double) bytes.
  • Reservoir state. After spires_run returns, the reservoir’s internal state reflects the final timestep of the series (i.e., it is as if spires_step was called series_length times). 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_series parameters of spires_train_ridge.
  • No partial results. If allocation fails partway through, NULL is returned and no partial data is available. The reservoir state is undefined in this case; call spires_reservoir_reset before reuse.
  • Thread safety. A given reservoir must not be used from multiple threads simultaneously. Different reservoirs may be run concurrently.

See Also

Last updated on