Changeset 4176435 in sasview for sansmodels/src/sans
- Timestamp:
- Jul 27, 2009 6:10:49 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f20767b
- Parents:
- 812b901
- Location:
- sansmodels/src/sans/models/c_models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_models/CCylinderModel.cpp
r812b901 r4176435 23 23 */ 24 24 25 #define NO_IMPORT_ARRAY26 #define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans27 28 25 extern "C" { 29 26 #include <Python.h> 30 #include <arrayobject.h>31 27 #include "structmember.h" 32 28 #include <stdio.h> … … 146 142 } 147 143 } 148 /** 149 * Function to call to evaluate model 150 * @param args: input numpy array q[] 151 * @return: numpy array object 152 */ 153 154 static PyObject *evaluateOneDim(CylinderModel* model, PyArrayObject *q){ 155 PyArrayObject *result; 156 157 // Check validity of array q , q must be of dimension 1, an array of double 158 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE) 159 { 160 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 161 //PyErr_SetString(PyExc_ValueError , message); 162 return NULL; 163 } 164 result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 165 PyArray_DOUBLE); 166 if (result == NULL) { 167 const char * message= "Could not create result "; 168 PyErr_SetString(PyExc_RuntimeError , message); 169 return NULL; 170 } 171 for (int i = 0; i < q->dimensions[0]; i++){ 172 double q_value = *(double *)(q->data + i*q->strides[0]); 173 double *result_value = (double *)(result->data + i*result->strides[0]); 174 *result_value =(*model)(q_value); 175 } 176 return PyArray_Return(result); 177 } 178 /** 179 * Function to call to evaluate model 180 * @param args: input numpy array [q[],phi[]] 181 * @return: numpy array object 182 */ 183 static PyObject * evaluateTwoDim( CylinderModel* model, 184 PyArrayObject *q, PyArrayObject *phi) 185 { 186 PyArrayObject *result; 187 //check validity of input vectors 188 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 189 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 190 || phi->dimensions[0] != q->dimensions[0]){ 191 192 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 193 //PyErr_SetString(PyExc_ValueError , message); 194 return NULL; 195 } 196 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 197 198 if (result == NULL){ 199 const char * message= "Could not create result "; 200 PyErr_SetString(PyExc_RuntimeError , message); 201 return NULL; 202 } 203 204 for (int i = 0; i < q->dimensions[0]; i++) { 205 double q_value = *(double *)(q->data + i*q->strides[0]); 206 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 207 double *result_value = (double *)(result->data + i*result->strides[0]); 208 if (q_value == 0) 209 *result_value = 0.0; 210 else 211 *result_value = model->evaluate_rphi(q_value, phi_value); 212 } 213 return PyArray_Return(result); 214 } 215 216 /** 217 * Function to call to evaluate model 218 * @param args: input numpy array [x[],y[]] 219 * @return: numpy array object 220 */ 221 static PyObject * evaluateTwoDimXY( CylinderModel* model, 222 PyArrayObject *x, PyArrayObject *y) 223 { 224 PyArrayObject *result; 225 //check validity of input vectors 226 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 227 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 228 || y->dimensions[0] != x->dimensions[0]){ 229 230 //const char * message= "Invalid array: x->nd=%d,type_num=%d\n",x->nd,x->descr->type_num; 231 //PyErr_SetString(PyExc_ValueError , message); 232 return NULL; 233 } 234 result= (PyArrayObject *)PyArray_FromDims(x->nd,(int*)(x->dimensions), PyArray_DOUBLE); 235 236 if (result == NULL){ 237 const char * message= "Could not create result "; 238 PyErr_SetString(PyExc_RuntimeError , message); 239 return NULL; 240 } 241 242 for (int i = 0; i < x->dimensions[0]; i++) { 243 double x_value = *(double *)(x->data + i*x->strides[0]); 244 double y_value = *(double *)(y->data + i*y->strides[0]); 245 double *result_value = (double *)(result->data + i*result->strides[0]); 246 *result_value = (*model)(x_value, y_value); 247 } 248 return PyArray_Return(result); 249 } 250 144 145 251 146 /** 252 147 * Function to call to evaluate model … … 299 194 return NULL; 300 195 } 301 302 196 // We have a vector q, get the q and phi values at which 303 197 // to evaluate I(q,phi) 304 PyObject *q, *phi; 305 q = PyList_GET_ITEM(pars,0); 306 phi = PyList_GET_ITEM(pars,1); 307 308 if (PyArray_Check(q) && PyArray_Check(phi)) { 309 return evaluateTwoDim(self->model, (PyArrayObject*)q, (PyArrayObject*)phi); 310 } else if (PyArray_Check(q) || PyArray_Check(phi)) { 311 return NULL; 312 } else { 313 q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 314 phi_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 315 // Skip zero 316 if (q_value==0) { 317 return Py_BuildValue("d",0.0); 318 } 319 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 320 } 198 q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 199 phi_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 200 // Skip zero 201 if (q_value==0) { 202 return Py_BuildValue("d",0.0); 203 } 204 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 205 321 206 } else { 322 if (PyArray_Check(pars)) { 323 return evaluateOneDim(self->model, (PyArrayObject*)pars); 324 } else { 325 // We have a scalar q, we will evaluate I(q) 207 208 // We have a scalar q, we will evaluate I(q) 326 209 q_value = CCylinderModel_readDouble(pars); 327 return Py_BuildValue("d",(*(self->model))(q_value));328 }329 } 210 211 return Py_BuildValue("d",(*(self->model))(q_value)); 212 } 330 213 } 331 214 … … 382 265 // We have a vector q, get the qx and qy values at which 383 266 // to evaluate I(qx,qy) 384 PyObject *x, *y; 385 x = PyList_GET_ITEM(pars,0); 386 y = PyList_GET_ITEM(pars,1); 387 388 if (PyArray_Check(x) && PyArray_Check(y)) { 389 390 return evaluateTwoDimXY(self->model, (PyArrayObject*)x, (PyArrayObject*)y); 391 } else if (PyArray_Check(x) || PyArray_Check(y)) { 392 return NULL; 393 } else { 394 qx_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 395 qy_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 396 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 397 } 267 qx_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 268 qy_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 269 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 398 270 399 271 } else { 400 if (PyArray_Check(pars)) { 401 return evaluateOneDim(self->model, (PyArrayObject*)pars); 402 } else { 403 // We have a scalar q, we will evaluate I(q) 404 qx_value = CCylinderModel_readDouble(pars); 272 273 // We have a scalar q, we will evaluate I(q) 274 qx_value = CCylinderModel_readDouble(pars); 405 275 406 return Py_BuildValue("d",(*(self->model))(qx_value)); 407 } 276 return Py_BuildValue("d",(*(self->model))(qx_value)); 408 277 } 409 278 } … … 507 376 508 377 378 static PyMethodDef module_methods[] = { 379 {NULL} 380 }; 381 509 382 /** 510 383 * Function used to add the model class to a module -
sansmodels/src/sans/models/c_models/CSphereModel.cpp
r812b901 r4176435 23 23 */ 24 24 25 #define NO_IMPORT_ARRAY26 #define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans27 28 25 extern "C" { 29 26 #include <Python.h> 30 #include <arrayobject.h>31 27 #include "structmember.h" 32 28 #include <stdio.h> … … 134 130 } 135 131 } 136 /** 137 * Function to call to evaluate model 138 * @param args: input numpy array q[] 139 * @return: numpy array object 140 */ 141 142 static PyObject *evaluateOneDim(SphereModel* model, PyArrayObject *q){ 143 PyArrayObject *result; 144 145 // Check validity of array q , q must be of dimension 1, an array of double 146 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE) 147 { 148 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 149 //PyErr_SetString(PyExc_ValueError , message); 150 return NULL; 151 } 152 result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 153 PyArray_DOUBLE); 154 if (result == NULL) { 155 const char * message= "Could not create result "; 156 PyErr_SetString(PyExc_RuntimeError , message); 157 return NULL; 158 } 159 for (int i = 0; i < q->dimensions[0]; i++){ 160 double q_value = *(double *)(q->data + i*q->strides[0]); 161 double *result_value = (double *)(result->data + i*result->strides[0]); 162 *result_value =(*model)(q_value); 163 } 164 return PyArray_Return(result); 165 } 166 /** 167 * Function to call to evaluate model 168 * @param args: input numpy array [q[],phi[]] 169 * @return: numpy array object 170 */ 171 static PyObject * evaluateTwoDim( SphereModel* model, 172 PyArrayObject *q, PyArrayObject *phi) 173 { 174 PyArrayObject *result; 175 //check validity of input vectors 176 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 177 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 178 || phi->dimensions[0] != q->dimensions[0]){ 179 180 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 181 //PyErr_SetString(PyExc_ValueError , message); 182 return NULL; 183 } 184 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 185 186 if (result == NULL){ 187 const char * message= "Could not create result "; 188 PyErr_SetString(PyExc_RuntimeError , message); 189 return NULL; 190 } 191 192 for (int i = 0; i < q->dimensions[0]; i++) { 193 double q_value = *(double *)(q->data + i*q->strides[0]); 194 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 195 double *result_value = (double *)(result->data + i*result->strides[0]); 196 if (q_value == 0) 197 *result_value = 0.0; 198 else 199 *result_value = model->evaluate_rphi(q_value, phi_value); 200 } 201 return PyArray_Return(result); 202 } 203 204 /** 205 * Function to call to evaluate model 206 * @param args: input numpy array [x[],y[]] 207 * @return: numpy array object 208 */ 209 static PyObject * evaluateTwoDimXY( SphereModel* model, 210 PyArrayObject *x, PyArrayObject *y) 211 { 212 PyArrayObject *result; 213 //check validity of input vectors 214 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 215 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 216 || y->dimensions[0] != x->dimensions[0]){ 217 218 //const char * message= "Invalid array: x->nd=%d,type_num=%d\n",x->nd,x->descr->type_num; 219 //PyErr_SetString(PyExc_ValueError , message); 220 return NULL; 221 } 222 result= (PyArrayObject *)PyArray_FromDims(x->nd,(int*)(x->dimensions), PyArray_DOUBLE); 223 224 if (result == NULL){ 225 const char * message= "Could not create result "; 226 PyErr_SetString(PyExc_RuntimeError , message); 227 return NULL; 228 } 229 230 for (int i = 0; i < x->dimensions[0]; i++) { 231 double x_value = *(double *)(x->data + i*x->strides[0]); 232 double y_value = *(double *)(y->data + i*y->strides[0]); 233 double *result_value = (double *)(result->data + i*result->strides[0]); 234 if (x_value == 0) 235 *result_value = 0.0; 236 else 237 *result_value = (*model)(x_value, y_value); 238 } 239 return PyArray_Return(result); 240 } 241 132 133 242 134 /** 243 135 * Function to call to evaluate model … … 281 173 return NULL; 282 174 } 283 284 175 // We have a vector q, get the q and phi values at which 285 176 // to evaluate I(q,phi) 286 PyObject *q, *phi; 287 q = PyList_GET_ITEM(pars,0); 288 phi = PyList_GET_ITEM(pars,1); 289 290 if (PyArray_Check(q) && PyArray_Check(phi)) { 291 return evaluateTwoDim(self->model, (PyArrayObject*)q, (PyArrayObject*)phi); 292 } else if (PyArray_Check(q) || PyArray_Check(phi)) { 293 return NULL; 294 } else { 295 q_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 296 phi_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 297 // Skip zero 298 if (q_value==0) { 299 return Py_BuildValue("d",0.0); 300 } 301 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 302 } 177 q_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 178 phi_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 179 // Skip zero 180 if (q_value==0) { 181 return Py_BuildValue("d",0.0); 182 } 183 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 184 303 185 } else { 304 if (PyArray_Check(pars)) { 305 return evaluateOneDim(self->model, (PyArrayObject*)pars); 306 } else { 307 // We have a scalar q, we will evaluate I(q) 186 187 // We have a scalar q, we will evaluate I(q) 308 188 q_value = CSphereModel_readDouble(pars); 309 return Py_BuildValue("d",(*(self->model))(q_value));310 }311 } 189 190 return Py_BuildValue("d",(*(self->model))(q_value)); 191 } 312 192 } 313 193 … … 355 235 // We have a vector q, get the qx and qy values at which 356 236 // to evaluate I(qx,qy) 357 PyObject *x, *y; 358 x = PyList_GET_ITEM(pars,0); 359 y = PyList_GET_ITEM(pars,1); 360 361 if (PyArray_Check(x) && PyArray_Check(y)) { 362 return evaluateTwoDimXY(self->model, (PyArrayObject*)x, (PyArrayObject*)y); 363 } else if (PyArray_Check(x) || PyArray_Check(y)) { 364 return NULL; 365 } else { 366 qx_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 367 qy_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 368 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 369 } 237 qx_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 238 qy_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 239 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 370 240 371 241 } else { 372 if (PyArray_Check(pars)) { 373 return evaluateOneDim(self->model, (PyArrayObject*)pars); 374 } else { 375 // We have a scalar q, we will evaluate I(q) 376 qx_value = CSphereModel_readDouble(pars); 242 243 // We have a scalar q, we will evaluate I(q) 244 qx_value = CSphereModel_readDouble(pars); 377 245 378 return Py_BuildValue("d",(*(self->model))(qx_value)); 379 } 246 return Py_BuildValue("d",(*(self->model))(qx_value)); 380 247 } 381 248 } … … 473 340 474 341 342 static PyMethodDef module_methods[] = { 343 {NULL} 344 }; 345 475 346 /** 476 347 * Function used to add the model class to a module -
sansmodels/src/sans/models/c_models/classTemplate.txt
r812b901 r4176435 23 23 */ 24 24 25 #define NO_IMPORT_ARRAY26 #define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans27 28 25 extern "C" { 29 26 #include <Python.h> 30 #include <arrayobject.h>31 27 #include "structmember.h" 32 28 #include <stdio.h> … … 120 116 } 121 117 } 122 /** 123 * Function to call to evaluate model 124 * @param args: input numpy array q[] 125 * @return: numpy array object 126 */ 127 128 static PyObject *evaluateOneDim([CMODEL]* model, PyArrayObject *q){ 129 PyArrayObject *result; 130 131 // Check validity of array q , q must be of dimension 1, an array of double 132 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE) 133 { 134 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 135 //PyErr_SetString(PyExc_ValueError , message); 136 return NULL; 137 } 138 result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 139 PyArray_DOUBLE); 140 if (result == NULL) { 141 const char * message= "Could not create result "; 142 PyErr_SetString(PyExc_RuntimeError , message); 143 return NULL; 144 } 145 for (int i = 0; i < q->dimensions[0]; i++){ 146 double q_value = *(double *)(q->data + i*q->strides[0]); 147 double *result_value = (double *)(result->data + i*result->strides[0]); 148 *result_value =(*model)(q_value); 149 } 150 return PyArray_Return(result); 151 } 152 /** 153 * Function to call to evaluate model 154 * @param args: input numpy array [q[],phi[]] 155 * @return: numpy array object 156 */ 157 static PyObject * evaluateTwoDim( [CMODEL]* model, 158 PyArrayObject *q, PyArrayObject *phi) 159 { 160 PyArrayObject *result; 161 //check validity of input vectors 162 if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE 163 || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE 164 || phi->dimensions[0] != q->dimensions[0]){ 165 166 //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num; 167 //PyErr_SetString(PyExc_ValueError , message); 168 return NULL; 169 } 170 result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE); 171 172 if (result == NULL){ 173 const char * message= "Could not create result "; 174 PyErr_SetString(PyExc_RuntimeError , message); 175 return NULL; 176 } 177 178 for (int i = 0; i < q->dimensions[0]; i++) { 179 double q_value = *(double *)(q->data + i*q->strides[0]); 180 double phi_value = *(double *)(phi->data + i*phi->strides[0]); 181 double *result_value = (double *)(result->data + i*result->strides[0]); 182 if (q_value == 0) 183 *result_value = 0.0; 184 else 185 *result_value = model->evaluate_rphi(q_value, phi_value); 186 } 187 return PyArray_Return(result); 188 } 189 190 /** 191 * Function to call to evaluate model 192 * @param args: input numpy array [x[],y[]] 193 * @return: numpy array object 194 */ 195 static PyObject * evaluateTwoDimXY( [CMODEL]* model, 196 PyArrayObject *x, PyArrayObject *y) 197 { 198 PyArrayObject *result; 199 //check validity of input vectors 200 if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE 201 || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE 202 || y->dimensions[0] != x->dimensions[0]){ 203 204 //const char * message= "Invalid array: x->nd=%d,type_num=%d\n",x->nd,x->descr->type_num; 205 //PyErr_SetString(PyExc_ValueError , message); 206 return NULL; 207 } 208 result= (PyArrayObject *)PyArray_FromDims(x->nd,(int*)(x->dimensions), PyArray_DOUBLE); 209 210 if (result == NULL){ 211 const char * message= "Could not create result "; 212 PyErr_SetString(PyExc_RuntimeError , message); 213 return NULL; 214 } 215 216 for (int i = 0; i < x->dimensions[0]; i++) { 217 double x_value = *(double *)(x->data + i*x->strides[0]); 218 double y_value = *(double *)(y->data + i*y->strides[0]); 219 double *result_value = (double *)(result->data + i*result->strides[0]); 220 *result_value = (*model)(x_value, y_value); 221 } 222 return PyArray_Return(result); 223 } 224 118 119 225 120 /** 226 121 * Function to call to evaluate model … … 254 149 return NULL; 255 150 } 256 257 151 // We have a vector q, get the q and phi values at which 258 152 // to evaluate I(q,phi) 259 PyObject *q, *phi; 260 q = PyList_GET_ITEM(pars,0); 261 phi = PyList_GET_ITEM(pars,1); 262 263 if (PyArray_Check(q) && PyArray_Check(phi)) { 264 return evaluateTwoDim(self->model, (PyArrayObject*)q, (PyArrayObject*)phi); 265 } else if (PyArray_Check(q) || PyArray_Check(phi)) { 266 return NULL; 267 } else { 268 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 269 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 270 // Skip zero 271 if (q_value==0) { 272 return Py_BuildValue("d",0.0); 273 } 274 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 275 } 153 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 154 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 155 // Skip zero 156 if (q_value==0) { 157 return Py_BuildValue("d",0.0); 158 } 159 return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value)); 160 276 161 } else { 277 if (PyArray_Check(pars)) { 278 return evaluateOneDim(self->model, (PyArrayObject*)pars); 279 } else { 280 // We have a scalar q, we will evaluate I(q) 162 163 // We have a scalar q, we will evaluate I(q) 281 164 q_value = [PYTHONCLASS]_readDouble(pars); 282 return Py_BuildValue("d",(*(self->model))(q_value));283 }284 } 165 166 return Py_BuildValue("d",(*(self->model))(q_value)); 167 } 285 168 } 286 169 … … 318 201 // We have a vector q, get the qx and qy values at which 319 202 // to evaluate I(qx,qy) 320 PyObject *x, *y; 321 x = PyList_GET_ITEM(pars,0); 322 y = PyList_GET_ITEM(pars,1); 323 324 if (PyArray_Check(x) && PyArray_Check(y)) { 325 326 return evaluateTwoDimXY(self->model, (PyArrayObject*)x, (PyArrayObject*)y); 327 } else if (PyArray_Check(x) || PyArray_Check(y)) { 328 return NULL; 329 } else { 330 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 331 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 332 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 333 } 203 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 204 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 205 return Py_BuildValue("d",(*(self->model))(qx_value,qy_value)); 334 206 335 207 } else { 336 if (PyArray_Check(pars)) { 337 return evaluateOneDim(self->model, (PyArrayObject*)pars); 338 } else { 339 // We have a scalar q, we will evaluate I(q) 340 qx_value = [PYTHONCLASS]_readDouble(pars); 208 209 // We have a scalar q, we will evaluate I(q) 210 qx_value = [PYTHONCLASS]_readDouble(pars); 341 211 342 return Py_BuildValue("d",(*(self->model))(qx_value)); 343 } 212 return Py_BuildValue("d",(*(self->model))(qx_value)); 344 213 } 345 214 } … … 433 302 434 303 304 static PyMethodDef module_methods[] = { 305 {NULL} 306 }; 307 435 308 /** 436 309 * Function used to add the model class to a module
Note: See TracChangeset
for help on using the changeset viewer.