Skip to contentSkip to Content

spires_read_weights

Read the reservoir’s recurrent weight matrix into a caller-provided buffer.


Signature

spires_status spires_read_weights(const spires_reservoir *r, double *buffer);

Parameters

ParameterTypeDescription
rconst spires_reservoir *Handle to the reservoir. Must not be NULL.
bufferdouble *Output buffer of length num_neurons * num_neurons. Must not be NULL. Filled in row-major order: buffer[i * num_neurons + j] is the synaptic weight from neuron j to neuron i.

Returns

spires_statusSPIRES_OK on success. On failure:

  • SPIRES_ERR_INVALID_ARGr or buffer is NULL.

Example

size_t N = spires_num_neurons(r); double *W = malloc(N * N * sizeof(double)); if (!W) return 1; if (spires_read_weights(r, W) != SPIRES_OK) { free(W); return 1; } /* Inspect a specific connection */ printf("W[0->1] = %.6f\n", W[1 * N + 0]); free(W);

Notes

  • No allocation. Unlike spires_copy_weights, this function writes into a buffer you provide. It is suitable for use in tight loops where you want to avoid repeated malloc/free calls.
  • Buffer size. The caller must ensure buffer is at least num_neurons * num_neurons * sizeof(double) bytes. Use spires_num_neurons to query num_neurons before allocating.
  • Row-major layout. buffer[i * N + j] is the connection weight from neuron j to neuron i. Zero entries indicate no connection (sparse matrix stored dense).

See Also

Last updated on