Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static PyObject* geo_capi(PyObject centroids, PyObject datapoints, PyObject k, PyObject maxiters, PyObject epsilon)
- {
- Py_ssize_t cent_length = PyList_Size(centroids);
- double** centroids_arr = (double**)calloc(cent_length, sizeof(double*));
- int i = 0;
- for (i < cent_length; i++){
- centroids_arr[i] = (double*)calloc(cent_length, sizeof(double));
- }
- int c, d;
- PyObject* centroid;
- for (c = 0; c < cent_length; c++){
- point = PyList_GetItem(centroids_arr, c);
- Py_ssize_t n = PyList_Size(point);
- for (d = 0; d < n; d++){
- centroids_arr[c][d] = PyList_GetItem(point, d);
- }
- }
- int k_val = (int)PyInt_AsLong(k);
- int epsilon = (int)PyInt_AsLong(epsilon);
- int maxiters = (int)PyInt_AsLong(maxiters);
- /* This parses the Python arguments into a double (d) variable named z and int (i) variable named n*/
- //if(!PyArg_ParseTuple(args, "di", &z, &n)) {
- // return NULL; /* In the CPython API, a NULL value is never valid for a
- // PyObject* so it is used to signal that an error has occurred. */
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement