Advertisement
UriSteiff

thrtht

Jun 4th, 2022
1,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. static PyObject* geo_capi(PyObject centroids, PyObject datapoints, PyObject k, PyObject maxiters, PyObject epsilon)
  2. {
  3.     Py_ssize_t cent_length = PyList_Size(centroids);
  4.     double** centroids_arr = (double**)calloc(cent_length, sizeof(double*));
  5.     int i = 0;
  6.     for (i < cent_length; i++){
  7.         centroids_arr[i] = (double*)calloc(cent_length, sizeof(double));
  8.     }
  9.     int c, d;
  10.     PyObject* centroid;
  11.     for (c = 0; c < cent_length; c++){
  12.         point = PyList_GetItem(centroids_arr, c);
  13.         Py_ssize_t n = PyList_Size(point);
  14.         for (d = 0; d < n; d++){
  15.             centroids_arr[c][d] = PyList_GetItem(point, d);
  16.         }
  17.     }
  18.     int k_val = (int)PyInt_AsLong(k);
  19.     int epsilon = (int)PyInt_AsLong(epsilon);
  20.     int maxiters = (int)PyInt_AsLong(maxiters);
  21.     /* This parses the Python arguments into a double (d)  variable named z and int (i) variable named n*/
  22.     //if(!PyArg_ParseTuple(args, "di", &z, &n)) {
  23.       //  return NULL; /* In the CPython API, a NULL value is never valid for a
  24.         //                PyObject* so it is used to signal that an error has occurred. */
  25.     //}
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement