Changeset 9316609 in sasview for sansmodels/src/sans/models/c_extensions/CCylinderModel.c
- Timestamp:
- Oct 28, 2008 3:22:22 PM (16 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:
- 92320e5
- Parents:
- 89fef2c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/CCylinderModel.c
rae3ce4e r9316609 1 /** CCylinderModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension 4 4 * 5 5 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 6 * DO NOT MODIFY THIS FILE, MODIFY cylinder.h6 * DO NOT MODIFY THIS FILE, MODIFY Cylinder.h 7 7 * AND RE-RUN THE GENERATOR SCRIPT 8 8 * … … 17 17 #include <time.h> 18 18 19 #include " cylinder.h"19 #include "Cylinder.h" 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CCylinderModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CylinderParameters model_pars; 34 } CCylinderModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CCylinderModel_dealloc(CCylinderModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CCylinderModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CCylinderModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CCylinderModel_init(CCylinderModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef CCylinderModel_members[] = {83 {"params", T_OBJECT, offsetof( CCylinderModel, params), 0,82 static PyMemberDef [PYTHONCLASS]_members[] = { 83 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( CCylinderModel, log), 0,85 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double CCylinderModel_readDouble(PyObject *p) {94 double [PYTHONCLASS]_readDouble(PyObject *p) { 95 95 if (PyFloat_Check(p)==1) { 96 96 return (double)(((PyFloatObject *)(p))->ob_fval); … … 110 110 * @return: function value 111 111 */ 112 static PyObject * run( CCylinderModel*self, PyObject *args) {112 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 113 113 double q_value, phi_value; 114 114 PyObject* pars; … … 129 129 // Get input and determine whether we have to supply a 1D or 2D return value. 130 130 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 131 PyErr_SetString( CCylinderModelError,132 " CCylinderModel.run expects a q value.");131 PyErr_SetString([PYTHONCLASS]Error, 132 "[PYTHONCLASS].run expects a q value."); 133 133 return NULL; 134 134 } … … 140 140 npars = PyList_GET_SIZE(pars); 141 141 if(npars!=2) { 142 PyErr_SetString( CCylinderModelError,143 " CCylinderModel.run expects a double or a list of dimension 2.");142 PyErr_SetString([PYTHONCLASS]Error, 143 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 144 144 return NULL; 145 145 } 146 146 // We have a vector q, get the q and phi values at which 147 147 // to evaluate I(q,phi) 148 q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));148 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { 152 152 return Py_BuildValue("d",0.0); 153 153 } 154 return Py_BuildValue("d", cylinder_analytical_2D(&(self->model_pars),q_value,phi_value));154 return Py_BuildValue("d",Cylinder_analytical_2D(&(self->model_pars),q_value,phi_value)); 155 155 156 156 } else { 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = CCylinderModel_readDouble(pars);159 q_value = [PYTHONCLASS]_readDouble(pars); 160 160 161 return Py_BuildValue("d", cylinder_analytical_1D(&(self->model_pars),q_value));161 return Py_BuildValue("d",Cylinder_analytical_1D(&(self->model_pars),q_value)); 162 162 } 163 163 } … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( CCylinderModel*self, PyObject *args) {170 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 171 171 double qx_value, qy_value; 172 172 PyObject* pars; … … 187 187 // Get input and determine whether we have to supply a 1D or 2D return value. 188 188 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 189 PyErr_SetString( CCylinderModelError,190 " CCylinderModel.run expects a q value.");189 PyErr_SetString([PYTHONCLASS]Error, 190 "[PYTHONCLASS].run expects a q value."); 191 191 return NULL; 192 192 } … … 198 198 npars = PyList_GET_SIZE(pars); 199 199 if(npars!=2) { 200 PyErr_SetString( CCylinderModelError,201 " CCylinderModel.run expects a double or a list of dimension 2.");200 PyErr_SetString([PYTHONCLASS]Error, 201 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 202 202 return NULL; 203 203 } 204 204 // We have a vector q, get the qx and qy values at which 205 205 // to evaluate I(qx,qy) 206 qx_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));208 return Py_BuildValue("d", cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value));206 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 208 return Py_BuildValue("d",Cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 210 210 } else { 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = CCylinderModel_readDouble(pars);213 qx_value = [PYTHONCLASS]_readDouble(pars); 214 214 215 return Py_BuildValue("d", cylinder_analytical_1D(&(self->model_pars),qx_value));215 return Py_BuildValue("d",Cylinder_analytical_1D(&(self->model_pars),qx_value)); 216 216 } 217 217 } 218 218 219 static PyObject * reset( CCylinderModel*self, PyObject *args) {219 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef CCylinderModel_methods[] = {226 static PyMethodDef [PYTHONCLASS]_methods[] = { 227 227 {"run", (PyCFunction)run , METH_VARARGS, 228 228 "Evaluate the model at a given Q or Q, phi"}, … … 236 236 }; 237 237 238 static PyTypeObject CCylinderModelType = {238 static PyTypeObject [PYTHONCLASS]Type = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " CCylinderModel", /*tp_name*/242 sizeof( CCylinderModel), /*tp_basicsize*/241 "[PYTHONCLASS]", /*tp_name*/ 242 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) CCylinderModel_dealloc, /*tp_dealloc*/244 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 245 245 0, /*tp_print*/ 246 246 0, /*tp_getattr*/ … … 258 258 0, /*tp_as_buffer*/ 259 259 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 260 " CCylinderModelobjects", /* tp_doc */260 "[PYTHONCLASS] objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 CCylinderModel_methods, /* tp_methods */268 CCylinderModel_members, /* tp_members */267 [PYTHONCLASS]_methods, /* tp_methods */ 268 [PYTHONCLASS]_members, /* tp_members */ 269 269 0, /* tp_getset */ 270 270 0, /* tp_base */ … … 273 273 0, /* tp_descr_set */ 274 274 0, /* tp_dictoffset */ 275 (initproc) CCylinderModel_init, /* tp_init */275 (initproc)[PYTHONCLASS]_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 CCylinderModel_new, /* tp_new */277 [PYTHONCLASS]_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add CCylinderModel(PyObject *module) {289 void add[PYTHONCLASS](PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& CCylinderModelType) < 0)292 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 293 293 return; 294 294 295 Py_INCREF(& CCylinderModelType);296 PyModule_AddObject(module, " CCylinderModel", (PyObject *)&CCylinderModelType);295 Py_INCREF(&[PYTHONCLASS]Type); 296 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 297 297 298 298 d = PyModule_GetDict(module); 299 CCylinderModelError = PyErr_NewException("CCylinderModel.error", NULL, NULL);300 PyDict_SetItemString(d, " CCylinderModelError", CCylinderModelError);301 } 302 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 300 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 301 } 302
Note: See TracChangeset
for help on using the changeset viewer.