everything is technically working

This commit is contained in:
2019-07-12 20:24:02 +02:00
parent d3a227ac19
commit c52fbe796d
3 changed files with 52 additions and 58 deletions

View File

@@ -13,7 +13,6 @@ interaction_force_function
int i;
for(i = 0; i < 7; i++)
{
printf("%x\n", coefficients);
result += coefficients[i] * powf(r, i);
}
result *= coefficients[7] * expf(coefficients[8] * (r - coefficients[9]));
@@ -28,7 +27,7 @@ interaction_ufunc_force
( char ** args
, npy_intp * dimensions
, npy_intp * steps
, void ** data)
, void * data)
{
char * in = args[0]
, * out = args[1];
@@ -38,9 +37,7 @@ interaction_ufunc_force
npy_intp i;
printf("DATA IS: %x\n", data);
printf("DATA[0] IS: %x\n", data[0]);
float * coefficients = (float *) data[0];
float * coefficients = (float *) data;
for(i = 0; i < n; i++)
{
@@ -139,6 +136,7 @@ typedef struct
PyObject_HEAD
float coefficients[19];
PyObject * ufunc;
void *data[1];
} interaction_UFuncWrapper;
static int
@@ -189,29 +187,30 @@ interaction_UFuncWrapper_init
return -1;
}
}
self->data[0] = (void *)self->coefficients;
switch(type)
{
case 0:
{
self->ufunc = PyUFunc_FromFuncAndData(
force_funcs
, (void **) &(self->coefficients)
, force_types
, 1
, 1
, 1
, PyUFunc_None
, "force_function"
, "computes the scalar force between two particles with given coefficients"
, 0);
force_funcs // func
, self->data // data
, force_types //types
, 1 // ntypes
, 1 // nin
, 1 // nout
, PyUFunc_None // identity
, "force_function" // name
, "computes the scalar force between two particles with given coefficients" // doc
, 0); // unused
break;
}
case 1:
{
self->ufunc = PyUFunc_FromFuncAndData(
interaction_funcs
, (void **) &(self->coefficients)
, self->data
, interaction_types
, 1
, 4
@@ -229,8 +228,6 @@ interaction_UFuncWrapper_init
}
}
Py_INCREF(self->ufunc);
printf("PASSED = %x\n", &(self->coefficients));
printf("PASSED[0] = %x\n", self->coefficients);
return 0;
}

View File

@@ -37,6 +37,6 @@ interaction_ufunc_force
( char ** args
, npy_intp * dimensions
, npy_intp * steps
, void ** data);
, void * data);
#endif