Basically I have a ufunc that requires some randomness. In order to keep the ufuncs as reproducible as possible I would like to use numpy's random number generator for that; basically because setting the seed will be more intuitive this way.
However I cannot find the documentation of the numpy.random C-API (does it have one?).
My current approach looks like that:
#include <numpy/random.h> // does not exist
...
static void
ufunc_M( char ** args
, npy_intp * dimensions
, npy_intp * steps
, void * data)
{
basic_gate_argument_t argument = *((basic_gate_argument_t *) data);
PYQCS_GATE_GENERIC_SETUP;
npy_intp i;
npy_double amplitude_1 = 0;
for(i = 0; i < ndim; i++)
{
if(i & (1 << argument.act))
{
amplitude_1 += qm_in[i].real * qm_in[i].real;
amplitude_1 += qm_in[i].imag * qm_in[i].imag;
}
}
npy_double rand = random_uniform(0, 1); // does not exist
...
*measured_out = 1 << argument.act;
}
...