you will likely need to include dictobject.h, floatobject.h, , if not already pulled in via other headers. Here is a way to grab all the values from a dict of floating point numbera to a vector. Depending on what's actually in the dict and how that's structured you may want to look at keys and other pieces.
Note that this is C++ and thus should be compiled as such.
//returns true on success
bool dictToVector(PyObject * srcDict, std::vector<double> & destVector) {
destVector.clear();
if(PyDict_Check(srcDict)) {
Py_ssize_t numItems = PyDict_Size(srcDict);
destVector.reserve(numItems);
Py_ssize_t iteratorPPOS = 0;
PyObject * currentVal;
while(PyDict_Next(srcDict, &iteratorPPOS, NULL, ¤tVal) {
// might be worth checking PyFloat_Check...
destVector.push_back(PyFloat_AsDouble(currentVal));
}
return (numItems == destVector.size());
}
else { // not a dict return with failure
return false;
}
}
Your wrapper will be similar at the end in that it will need to copy the result of mmult into the of result type numpy.ndarray.
Usage of the above something like:
PyObject* mmult_wrapper(PyObject * e, PyObject * new_data, PyObject * neighbour_num, PyObject * result) {
int32_t Cresult[16];
std::vector<double> Ce;
bool noErrorSoFar = dictToVector(e,Ce);
if(Ce.size() == 100) {
mmult(PyFloat_AsDouble(new_data) , PyFloat_AsDouble( neighbour_num), Ce.data(), Cresult);
}
else { // not 100 doubles in the data read!
noErrorSoFar = false;
}
... //some stuff to copy Cresult to the python, and return something meaningful?
}