Skip to contentSkip to Content
DocsAPI ReferenceState Accessspires_compute_output

spires_compute_output

Compute the readout output vector from the reservoir’s current state: y = W_out * x.


Signature

spires_status spires_compute_output(spires_reservoir *r, double *out);

Parameters

ParameterTypeDescription
rspires_reservoir *Handle to the reservoir. Must not be NULL.
outdouble *Caller-allocated array of at least num_outputs elements. The computed output vector is written here. Must not be NULL.

Returns

spires_statusSPIRES_OK on success, or SPIRES_ERR_INVALID_ARG if r or out is NULL.


Example

size_t no = spires_num_outputs(r); double *y = malloc(no * sizeof(double)); /* Step and read output */ spires_step(r, input_vec); spires_compute_output(r, y); for (size_t k = 0; k < no; k++) { printf("output[%zu] = %.6f\n", k, y[k]); } free(y);

Notes

  • Readout weights. The output is the matrix-vector product W_out * x, where W_out is the [num_outputs x num_neurons] readout weight matrix and x is the current neuron state vector. If no training has been performed, W_out is all zeros and the output will be zero.
  • No allocation. This function performs no heap allocation. The caller provides the output buffer.
  • Buffer sizing. The out array must hold at least num_outputs doubles. Use spires_num_outputs to query the required size.
  • Idempotent. Calling this function does not modify the reservoir state. It can be called multiple times between steps with identical results.
  • Thread safety. Safe to call concurrently with other read-only functions (e.g., spires_num_neurons) on the same reservoir, but do not call concurrently with mutating functions (e.g., spires_step, spires_train_online).

See Also

Last updated on