Changeset a8d6888 in sasview for sansmodels/src/sans/models/c_extensions
- Timestamp:
- Aug 24, 2009 10:08:37 AM (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:
- df4702f
- Parents:
- 2339ff1e
- Location:
- sansmodels/src/sans/models/c_extensions
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/CCoreShellCylinderModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CCoreShellCylinderModel 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * [PYTHONCLASS]Error = NULL;22 static PyObject * CCoreShellCylinderModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CoreShellCylinderParameters model_pars; 34 } [PYTHONCLASS];34 } CCoreShellCylinderModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CCoreShellCylinderModel_dealloc(CCoreShellCylinderModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CCoreShellCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;48 CCoreShellCylinderModel *self; 49 49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);50 self = (CCoreShellCylinderModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CCoreShellCylinderModel_init(CCoreShellCylinderModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 83 83 } 84 84 85 static PyMemberDef [PYTHONCLASS]_members[] = {86 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,85 static PyMemberDef CCoreShellCylinderModel_members[] = { 86 {"params", T_OBJECT, offsetof(CCoreShellCylinderModel, params), 0, 87 87 "Parameters"}, 88 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,88 {"log", T_OBJECT, offsetof(CCoreShellCylinderModel, log), 0, 89 89 "Log"}, 90 90 {NULL} /* Sentinel */ … … 95 95 @return double 96 96 */ 97 double [PYTHONCLASS]_readDouble(PyObject *p) {97 double CCoreShellCylinderModel_readDouble(PyObject *p) { 98 98 if (PyFloat_Check(p)==1) { 99 99 return (double)(((PyFloatObject *)(p))->ob_fval); … … 113 113 * @return: function value 114 114 */ 115 static PyObject * run( [PYTHONCLASS]*self, PyObject *args) {115 static PyObject * run(CCoreShellCylinderModel *self, PyObject *args) { 116 116 double q_value, phi_value; 117 117 PyObject* pars; … … 135 135 // Get input and determine whether we have to supply a 1D or 2D return value. 136 136 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 137 PyErr_SetString( [PYTHONCLASS]Error,138 " [PYTHONCLASS].run expects a q value.");137 PyErr_SetString(CCoreShellCylinderModelError, 138 "CCoreShellCylinderModel.run expects a q value."); 139 139 return NULL; 140 140 } … … 146 146 npars = PyList_GET_SIZE(pars); 147 147 if(npars!=2) { 148 PyErr_SetString( [PYTHONCLASS]Error,149 " [PYTHONCLASS].run expects a double or a list of dimension 2.");148 PyErr_SetString(CCoreShellCylinderModelError, 149 "CCoreShellCylinderModel.run expects a double or a list of dimension 2."); 150 150 return NULL; 151 151 } 152 152 // We have a vector q, get the q and phi values at which 153 153 // to evaluate I(q,phi) 154 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));155 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));154 q_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 155 phi_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 156 156 // Skip zero 157 157 if (q_value==0) { … … 163 163 164 164 // We have a scalar q, we will evaluate I(q) 165 q_value = [PYTHONCLASS]_readDouble(pars);165 q_value = CCoreShellCylinderModel_readDouble(pars); 166 166 167 167 return Py_BuildValue("d",core_shell_cylinder_analytical_1D(&(self->model_pars),q_value)); … … 174 174 * @return: function value 175 175 */ 176 static PyObject * runXY( [PYTHONCLASS]*self, PyObject *args) {176 static PyObject * runXY(CCoreShellCylinderModel *self, PyObject *args) { 177 177 double qx_value, qy_value; 178 178 PyObject* pars; … … 196 196 // Get input and determine whether we have to supply a 1D or 2D return value. 197 197 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 198 PyErr_SetString( [PYTHONCLASS]Error,199 " [PYTHONCLASS].run expects a q value.");198 PyErr_SetString(CCoreShellCylinderModelError, 199 "CCoreShellCylinderModel.run expects a q value."); 200 200 return NULL; 201 201 } … … 207 207 npars = PyList_GET_SIZE(pars); 208 208 if(npars!=2) { 209 PyErr_SetString( [PYTHONCLASS]Error,210 " [PYTHONCLASS].run expects a double or a list of dimension 2.");209 PyErr_SetString(CCoreShellCylinderModelError, 210 "CCoreShellCylinderModel.run expects a double or a list of dimension 2."); 211 211 return NULL; 212 212 } 213 213 // We have a vector q, get the qx and qy values at which 214 214 // to evaluate I(qx,qy) 215 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));216 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));215 qx_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 216 qy_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 217 217 return Py_BuildValue("d",core_shell_cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 218 218 … … 220 220 221 221 // We have a scalar q, we will evaluate I(q) 222 qx_value = [PYTHONCLASS]_readDouble(pars);222 qx_value = CCoreShellCylinderModel_readDouble(pars); 223 223 224 224 return Py_BuildValue("d",core_shell_cylinder_analytical_1D(&(self->model_pars),qx_value)); … … 226 226 } 227 227 228 static PyObject * reset( [PYTHONCLASS]*self, PyObject *args) {228 static PyObject * reset(CCoreShellCylinderModel *self, PyObject *args) { 229 229 230 230 … … 233 233 234 234 235 static PyMethodDef [PYTHONCLASS]_methods[] = {235 static PyMethodDef CCoreShellCylinderModel_methods[] = { 236 236 {"run", (PyCFunction)run , METH_VARARGS, 237 237 "Evaluate the model at a given Q or Q, phi"}, … … 245 245 }; 246 246 247 static PyTypeObject [PYTHONCLASS]Type = {247 static PyTypeObject CCoreShellCylinderModelType = { 248 248 PyObject_HEAD_INIT(NULL) 249 249 0, /*ob_size*/ 250 " [PYTHONCLASS]", /*tp_name*/251 sizeof( [PYTHONCLASS]), /*tp_basicsize*/250 "CCoreShellCylinderModel", /*tp_name*/ 251 sizeof(CCoreShellCylinderModel), /*tp_basicsize*/ 252 252 0, /*tp_itemsize*/ 253 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/253 (destructor)CCoreShellCylinderModel_dealloc, /*tp_dealloc*/ 254 254 0, /*tp_print*/ 255 255 0, /*tp_getattr*/ … … 267 267 0, /*tp_as_buffer*/ 268 268 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 269 " [PYTHONCLASS]objects", /* tp_doc */269 "CCoreShellCylinderModel objects", /* tp_doc */ 270 270 0, /* tp_traverse */ 271 271 0, /* tp_clear */ … … 274 274 0, /* tp_iter */ 275 275 0, /* tp_iternext */ 276 [PYTHONCLASS]_methods, /* tp_methods */277 [PYTHONCLASS]_members, /* tp_members */276 CCoreShellCylinderModel_methods, /* tp_methods */ 277 CCoreShellCylinderModel_members, /* tp_members */ 278 278 0, /* tp_getset */ 279 279 0, /* tp_base */ … … 282 282 0, /* tp_descr_set */ 283 283 0, /* tp_dictoffset */ 284 (initproc) [PYTHONCLASS]_init, /* tp_init */284 (initproc)CCoreShellCylinderModel_init, /* tp_init */ 285 285 0, /* tp_alloc */ 286 [PYTHONCLASS]_new, /* tp_new */286 CCoreShellCylinderModel_new, /* tp_new */ 287 287 }; 288 288 … … 296 296 * @param module: module to add the class to 297 297 */ 298 void add [PYTHONCLASS](PyObject *module) {298 void addCCoreShellCylinderModel(PyObject *module) { 299 299 PyObject *d; 300 300 301 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)301 if (PyType_Ready(&CCoreShellCylinderModelType) < 0) 302 302 return; 303 303 304 Py_INCREF(& [PYTHONCLASS]Type);305 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);304 Py_INCREF(&CCoreShellCylinderModelType); 305 PyModule_AddObject(module, "CCoreShellCylinderModel", (PyObject *)&CCoreShellCylinderModelType); 306 306 307 307 d = PyModule_GetDict(module); 308 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);309 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);310 } 311 308 CCoreShellCylinderModelError = PyErr_NewException("CCoreShellCylinderModel.error", NULL, NULL); 309 PyDict_SetItemString(d, "CCoreShellCylinderModelError", CCoreShellCylinderModelError); 310 } 311 -
sansmodels/src/sans/models/c_extensions/CCoreShellModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CCoreShellModel 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * [PYTHONCLASS]Error = NULL;22 static PyObject * CCoreShellModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CoreShellParameters model_pars; 34 } [PYTHONCLASS];34 } CCoreShellModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CCoreShellModel_dealloc(CCoreShellModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CCoreShellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;48 CCoreShellModel *self; 49 49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);50 self = (CCoreShellModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CCoreShellModel_init(CCoreShellModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef [PYTHONCLASS]_members[] = {83 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,82 static PyMemberDef CCoreShellModel_members[] = { 83 {"params", T_OBJECT, offsetof(CCoreShellModel, params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,85 {"log", T_OBJECT, offsetof(CCoreShellModel, log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double [PYTHONCLASS]_readDouble(PyObject *p) {94 double CCoreShellModel_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( [PYTHONCLASS]*self, PyObject *args) {112 static PyObject * run(CCoreShellModel *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( [PYTHONCLASS]Error,132 " [PYTHONCLASS].run expects a q value.");131 PyErr_SetString(CCoreShellModelError, 132 "CCoreShellModel.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( [PYTHONCLASS]Error,143 " [PYTHONCLASS].run expects a double or a list of dimension 2.");142 PyErr_SetString(CCoreShellModelError, 143 "CCoreShellModel.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 = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));148 q_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { … … 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = [PYTHONCLASS]_readDouble(pars);159 q_value = CCoreShellModel_readDouble(pars); 160 160 161 161 return Py_BuildValue("d",core_shell_analytical_1D(&(self->model_pars),q_value)); … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( [PYTHONCLASS]*self, PyObject *args) {170 static PyObject * runXY(CCoreShellModel *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( [PYTHONCLASS]Error,190 " [PYTHONCLASS].run expects a q value.");189 PyErr_SetString(CCoreShellModelError, 190 "CCoreShellModel.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( [PYTHONCLASS]Error,201 " [PYTHONCLASS].run expects a double or a list of dimension 2.");200 PyErr_SetString(CCoreShellModelError, 201 "CCoreShellModel.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 = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));206 qx_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1)); 208 208 return Py_BuildValue("d",core_shell_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 … … 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = [PYTHONCLASS]_readDouble(pars);213 qx_value = CCoreShellModel_readDouble(pars); 214 214 215 215 return Py_BuildValue("d",core_shell_analytical_1D(&(self->model_pars),qx_value)); … … 217 217 } 218 218 219 static PyObject * reset( [PYTHONCLASS]*self, PyObject *args) {219 static PyObject * reset(CCoreShellModel *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef [PYTHONCLASS]_methods[] = {226 static PyMethodDef CCoreShellModel_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 [PYTHONCLASS]Type = {238 static PyTypeObject CCoreShellModelType = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " [PYTHONCLASS]", /*tp_name*/242 sizeof( [PYTHONCLASS]), /*tp_basicsize*/241 "CCoreShellModel", /*tp_name*/ 242 sizeof(CCoreShellModel), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/244 (destructor)CCoreShellModel_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 " [PYTHONCLASS]objects", /* tp_doc */260 "CCoreShellModel objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 [PYTHONCLASS]_methods, /* tp_methods */268 [PYTHONCLASS]_members, /* tp_members */267 CCoreShellModel_methods, /* tp_methods */ 268 CCoreShellModel_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) [PYTHONCLASS]_init, /* tp_init */275 (initproc)CCoreShellModel_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 [PYTHONCLASS]_new, /* tp_new */277 CCoreShellModel_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add [PYTHONCLASS](PyObject *module) {289 void addCCoreShellModel(PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)292 if (PyType_Ready(&CCoreShellModelType) < 0) 293 293 return; 294 294 295 Py_INCREF(& [PYTHONCLASS]Type);296 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);295 Py_INCREF(&CCoreShellModelType); 296 PyModule_AddObject(module, "CCoreShellModel", (PyObject *)&CCoreShellModelType); 297 297 298 298 d = PyModule_GetDict(module); 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);300 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);301 } 302 299 CCoreShellModelError = PyErr_NewException("CCoreShellModel.error", NULL, NULL); 300 PyDict_SetItemString(d, "CCoreShellModelError", CCoreShellModelError); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CCylinderModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CCylinderModel 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 * [PYTHONCLASS]Error = NULL;22 static PyObject * CCylinderModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CylinderParameters model_pars; 34 } [PYTHONCLASS];34 } CCylinderModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CCylinderModel_dealloc(CCylinderModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;48 CCylinderModel *self; 49 49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);50 self = (CCylinderModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CCylinderModel_init(CCylinderModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef [PYTHONCLASS]_members[] = {83 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,82 static PyMemberDef CCylinderModel_members[] = { 83 {"params", T_OBJECT, offsetof(CCylinderModel, params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,85 {"log", T_OBJECT, offsetof(CCylinderModel, log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double [PYTHONCLASS]_readDouble(PyObject *p) {94 double CCylinderModel_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( [PYTHONCLASS]*self, PyObject *args) {112 static PyObject * run(CCylinderModel *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( [PYTHONCLASS]Error,132 " [PYTHONCLASS].run expects a q value.");131 PyErr_SetString(CCylinderModelError, 132 "CCylinderModel.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( [PYTHONCLASS]Error,143 " [PYTHONCLASS].run expects a double or a list of dimension 2.");142 PyErr_SetString(CCylinderModelError, 143 "CCylinderModel.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 = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));148 q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = CCylinderModel_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 = [PYTHONCLASS]_readDouble(pars);159 q_value = CCylinderModel_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( [PYTHONCLASS]*self, PyObject *args) {170 static PyObject * runXY(CCylinderModel *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( [PYTHONCLASS]Error,190 " [PYTHONCLASS].run expects a q value.");189 PyErr_SetString(CCylinderModelError, 190 "CCylinderModel.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( [PYTHONCLASS]Error,201 " [PYTHONCLASS].run expects a double or a list of dimension 2.");200 PyErr_SetString(CCylinderModelError, 201 "CCylinderModel.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 = [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));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)); 209 209 210 210 } else { 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = [PYTHONCLASS]_readDouble(pars);213 qx_value = CCylinderModel_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( [PYTHONCLASS]*self, PyObject *args) {219 static PyObject * reset(CCylinderModel *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef [PYTHONCLASS]_methods[] = {226 static PyMethodDef CCylinderModel_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 [PYTHONCLASS]Type = {238 static PyTypeObject CCylinderModelType = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " [PYTHONCLASS]", /*tp_name*/242 sizeof( [PYTHONCLASS]), /*tp_basicsize*/241 "CCylinderModel", /*tp_name*/ 242 sizeof(CCylinderModel), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/244 (destructor)CCylinderModel_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 " [PYTHONCLASS]objects", /* tp_doc */260 "CCylinderModel objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 [PYTHONCLASS]_methods, /* tp_methods */268 [PYTHONCLASS]_members, /* tp_members */267 CCylinderModel_methods, /* tp_methods */ 268 CCylinderModel_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) [PYTHONCLASS]_init, /* tp_init */275 (initproc)CCylinderModel_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 [PYTHONCLASS]_new, /* tp_new */277 CCylinderModel_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add [PYTHONCLASS](PyObject *module) {289 void addCCylinderModel(PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)292 if (PyType_Ready(&CCylinderModelType) < 0) 293 293 return; 294 294 295 Py_INCREF(& [PYTHONCLASS]Type);296 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);295 Py_INCREF(&CCylinderModelType); 296 PyModule_AddObject(module, "CCylinderModel", (PyObject *)&CCylinderModelType); 297 297 298 298 d = PyModule_GetDict(module); 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);300 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);301 } 302 299 CCylinderModelError = PyErr_NewException("CCylinderModel.error", NULL, NULL); 300 PyDict_SetItemString(d, "CCylinderModelError", CCylinderModelError); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CEllipsoidModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CEllipsoidModel 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * [PYTHONCLASS]Error = NULL;22 static PyObject * CEllipsoidModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 EllipsoidParameters model_pars; 34 } [PYTHONCLASS];34 } CEllipsoidModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CEllipsoidModel_dealloc(CEllipsoidModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CEllipsoidModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;48 CEllipsoidModel *self; 49 49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);50 self = (CEllipsoidModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CEllipsoidModel_init(CEllipsoidModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef [PYTHONCLASS]_members[] = {83 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,82 static PyMemberDef CEllipsoidModel_members[] = { 83 {"params", T_OBJECT, offsetof(CEllipsoidModel, params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,85 {"log", T_OBJECT, offsetof(CEllipsoidModel, log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double [PYTHONCLASS]_readDouble(PyObject *p) {94 double CEllipsoidModel_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( [PYTHONCLASS]*self, PyObject *args) {112 static PyObject * run(CEllipsoidModel *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( [PYTHONCLASS]Error,132 " [PYTHONCLASS].run expects a q value.");131 PyErr_SetString(CEllipsoidModelError, 132 "CEllipsoidModel.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( [PYTHONCLASS]Error,143 " [PYTHONCLASS].run expects a double or a list of dimension 2.");142 PyErr_SetString(CEllipsoidModelError, 143 "CEllipsoidModel.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 = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));148 q_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { … … 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = [PYTHONCLASS]_readDouble(pars);159 q_value = CEllipsoidModel_readDouble(pars); 160 160 161 161 return Py_BuildValue("d",ellipsoid_analytical_1D(&(self->model_pars),q_value)); … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( [PYTHONCLASS]*self, PyObject *args) {170 static PyObject * runXY(CEllipsoidModel *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( [PYTHONCLASS]Error,190 " [PYTHONCLASS].run expects a q value.");189 PyErr_SetString(CEllipsoidModelError, 190 "CEllipsoidModel.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( [PYTHONCLASS]Error,201 " [PYTHONCLASS].run expects a double or a list of dimension 2.");200 PyErr_SetString(CEllipsoidModelError, 201 "CEllipsoidModel.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 = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));206 qx_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1)); 208 208 return Py_BuildValue("d",ellipsoid_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 … … 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = [PYTHONCLASS]_readDouble(pars);213 qx_value = CEllipsoidModel_readDouble(pars); 214 214 215 215 return Py_BuildValue("d",ellipsoid_analytical_1D(&(self->model_pars),qx_value)); … … 217 217 } 218 218 219 static PyObject * reset( [PYTHONCLASS]*self, PyObject *args) {219 static PyObject * reset(CEllipsoidModel *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef [PYTHONCLASS]_methods[] = {226 static PyMethodDef CEllipsoidModel_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 [PYTHONCLASS]Type = {238 static PyTypeObject CEllipsoidModelType = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " [PYTHONCLASS]", /*tp_name*/242 sizeof( [PYTHONCLASS]), /*tp_basicsize*/241 "CEllipsoidModel", /*tp_name*/ 242 sizeof(CEllipsoidModel), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/244 (destructor)CEllipsoidModel_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 " [PYTHONCLASS]objects", /* tp_doc */260 "CEllipsoidModel objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 [PYTHONCLASS]_methods, /* tp_methods */268 [PYTHONCLASS]_members, /* tp_members */267 CEllipsoidModel_methods, /* tp_methods */ 268 CEllipsoidModel_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) [PYTHONCLASS]_init, /* tp_init */275 (initproc)CEllipsoidModel_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 [PYTHONCLASS]_new, /* tp_new */277 CEllipsoidModel_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add [PYTHONCLASS](PyObject *module) {289 void addCEllipsoidModel(PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)292 if (PyType_Ready(&CEllipsoidModelType) < 0) 293 293 return; 294 294 295 Py_INCREF(& [PYTHONCLASS]Type);296 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);295 Py_INCREF(&CEllipsoidModelType); 296 PyModule_AddObject(module, "CEllipsoidModel", (PyObject *)&CEllipsoidModelType); 297 297 298 298 d = PyModule_GetDict(module); 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);300 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);301 } 302 299 CEllipsoidModelError = PyErr_NewException("CEllipsoidModel.error", NULL, NULL); 300 PyDict_SetItemString(d, "CEllipsoidModelError", CEllipsoidModelError); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CEllipticalCylinderModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CEllipticalCylinderModel 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * [PYTHONCLASS]Error = NULL;22 static PyObject * CEllipticalCylinderModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 EllipticalCylinderParameters model_pars; 34 } [PYTHONCLASS];34 } CEllipticalCylinderModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CEllipticalCylinderModel_dealloc(CEllipticalCylinderModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CEllipticalCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;48 CEllipticalCylinderModel *self; 49 49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);50 self = (CEllipticalCylinderModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CEllipticalCylinderModel_init(CEllipticalCylinderModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 82 82 } 83 83 84 static PyMemberDef [PYTHONCLASS]_members[] = {85 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,84 static PyMemberDef CEllipticalCylinderModel_members[] = { 85 {"params", T_OBJECT, offsetof(CEllipticalCylinderModel, params), 0, 86 86 "Parameters"}, 87 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,87 {"log", T_OBJECT, offsetof(CEllipticalCylinderModel, log), 0, 88 88 "Log"}, 89 89 {NULL} /* Sentinel */ … … 94 94 @return double 95 95 */ 96 double [PYTHONCLASS]_readDouble(PyObject *p) {96 double CEllipticalCylinderModel_readDouble(PyObject *p) { 97 97 if (PyFloat_Check(p)==1) { 98 98 return (double)(((PyFloatObject *)(p))->ob_fval); … … 112 112 * @return: function value 113 113 */ 114 static PyObject * run( [PYTHONCLASS]*self, PyObject *args) {114 static PyObject * run(CEllipticalCylinderModel *self, PyObject *args) { 115 115 double q_value, phi_value; 116 116 PyObject* pars; … … 133 133 // Get input and determine whether we have to supply a 1D or 2D return value. 134 134 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 135 PyErr_SetString( [PYTHONCLASS]Error,136 " [PYTHONCLASS].run expects a q value.");135 PyErr_SetString(CEllipticalCylinderModelError, 136 "CEllipticalCylinderModel.run expects a q value."); 137 137 return NULL; 138 138 } … … 144 144 npars = PyList_GET_SIZE(pars); 145 145 if(npars!=2) { 146 PyErr_SetString( [PYTHONCLASS]Error,147 " [PYTHONCLASS].run expects a double or a list of dimension 2.");146 PyErr_SetString(CEllipticalCylinderModelError, 147 "CEllipticalCylinderModel.run expects a double or a list of dimension 2."); 148 148 return NULL; 149 149 } 150 150 // We have a vector q, get the q and phi values at which 151 151 // to evaluate I(q,phi) 152 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));153 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));152 q_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 153 phi_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 154 154 // Skip zero 155 155 if (q_value==0) { … … 161 161 162 162 // We have a scalar q, we will evaluate I(q) 163 q_value = [PYTHONCLASS]_readDouble(pars);163 q_value = CEllipticalCylinderModel_readDouble(pars); 164 164 165 165 return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),q_value)); … … 172 172 * @return: function value 173 173 */ 174 static PyObject * runXY( [PYTHONCLASS]*self, PyObject *args) {174 static PyObject * runXY(CEllipticalCylinderModel *self, PyObject *args) { 175 175 double qx_value, qy_value; 176 176 PyObject* pars; … … 193 193 // Get input and determine whether we have to supply a 1D or 2D return value. 194 194 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 195 PyErr_SetString( [PYTHONCLASS]Error,196 " [PYTHONCLASS].run expects a q value.");195 PyErr_SetString(CEllipticalCylinderModelError, 196 "CEllipticalCylinderModel.run expects a q value."); 197 197 return NULL; 198 198 } … … 204 204 npars = PyList_GET_SIZE(pars); 205 205 if(npars!=2) { 206 PyErr_SetString( [PYTHONCLASS]Error,207 " [PYTHONCLASS].run expects a double or a list of dimension 2.");206 PyErr_SetString(CEllipticalCylinderModelError, 207 "CEllipticalCylinderModel.run expects a double or a list of dimension 2."); 208 208 return NULL; 209 209 } 210 210 // We have a vector q, get the qx and qy values at which 211 211 // to evaluate I(qx,qy) 212 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));213 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));212 qx_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 213 qy_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 214 214 return Py_BuildValue("d",elliptical_cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 215 215 … … 217 217 218 218 // We have a scalar q, we will evaluate I(q) 219 qx_value = [PYTHONCLASS]_readDouble(pars);219 qx_value = CEllipticalCylinderModel_readDouble(pars); 220 220 221 221 return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),qx_value)); … … 223 223 } 224 224 225 static PyObject * reset( [PYTHONCLASS]*self, PyObject *args) {225 static PyObject * reset(CEllipticalCylinderModel *self, PyObject *args) { 226 226 227 227 … … 230 230 231 231 232 static PyMethodDef [PYTHONCLASS]_methods[] = {232 static PyMethodDef CEllipticalCylinderModel_methods[] = { 233 233 {"run", (PyCFunction)run , METH_VARARGS, 234 234 "Evaluate the model at a given Q or Q, phi"}, … … 242 242 }; 243 243 244 static PyTypeObject [PYTHONCLASS]Type = {244 static PyTypeObject CEllipticalCylinderModelType = { 245 245 PyObject_HEAD_INIT(NULL) 246 246 0, /*ob_size*/ 247 " [PYTHONCLASS]", /*tp_name*/248 sizeof( [PYTHONCLASS]), /*tp_basicsize*/247 "CEllipticalCylinderModel", /*tp_name*/ 248 sizeof(CEllipticalCylinderModel), /*tp_basicsize*/ 249 249 0, /*tp_itemsize*/ 250 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/250 (destructor)CEllipticalCylinderModel_dealloc, /*tp_dealloc*/ 251 251 0, /*tp_print*/ 252 252 0, /*tp_getattr*/ … … 264 264 0, /*tp_as_buffer*/ 265 265 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 266 " [PYTHONCLASS]objects", /* tp_doc */266 "CEllipticalCylinderModel objects", /* tp_doc */ 267 267 0, /* tp_traverse */ 268 268 0, /* tp_clear */ … … 271 271 0, /* tp_iter */ 272 272 0, /* tp_iternext */ 273 [PYTHONCLASS]_methods, /* tp_methods */274 [PYTHONCLASS]_members, /* tp_members */273 CEllipticalCylinderModel_methods, /* tp_methods */ 274 CEllipticalCylinderModel_members, /* tp_members */ 275 275 0, /* tp_getset */ 276 276 0, /* tp_base */ … … 279 279 0, /* tp_descr_set */ 280 280 0, /* tp_dictoffset */ 281 (initproc) [PYTHONCLASS]_init, /* tp_init */281 (initproc)CEllipticalCylinderModel_init, /* tp_init */ 282 282 0, /* tp_alloc */ 283 [PYTHONCLASS]_new, /* tp_new */283 CEllipticalCylinderModel_new, /* tp_new */ 284 284 }; 285 285 … … 293 293 * @param module: module to add the class to 294 294 */ 295 void add [PYTHONCLASS](PyObject *module) {295 void addCEllipticalCylinderModel(PyObject *module) { 296 296 PyObject *d; 297 297 298 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)298 if (PyType_Ready(&CEllipticalCylinderModelType) < 0) 299 299 return; 300 300 301 Py_INCREF(& [PYTHONCLASS]Type);302 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);301 Py_INCREF(&CEllipticalCylinderModelType); 302 PyModule_AddObject(module, "CEllipticalCylinderModel", (PyObject *)&CEllipticalCylinderModelType); 303 303 304 304 d = PyModule_GetDict(module); 305 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);306 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);307 } 308 305 CEllipticalCylinderModelError = PyErr_NewException("CEllipticalCylinderModel.error", NULL, NULL); 306 PyDict_SetItemString(d, "CEllipticalCylinderModelError", CEllipticalCylinderModelError); 307 } 308 -
sansmodels/src/sans/models/c_extensions/CParallelepipedModel.c
r8a48713 ra8d6888 4 4 * 5 5 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 6 * DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\parallelepiped.h6 * DO NOT MODIFY THIS FILE, MODIFY parallelepiped.h 7 7 * AND RE-RUN THE GENERATOR SCRIPT 8 8 * … … 17 17 #include <time.h> 18 18 19 #include " ..\c_extensions\parallelepiped.h"19 #include "parallelepiped.h" 20 20 21 21 /// Error object for raised exceptions … … 62 62 63 63 // Initialize parameter dictionary 64 PyDict_SetItemString(self->params,"short_a",Py_BuildValue("d",35.000000)); 65 PyDict_SetItemString(self->params,"short_b",Py_BuildValue("d",75.000000)); 64 66 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 65 PyDict_SetItemString(self->params,"long er_edgeB",Py_BuildValue("d",75.000000));66 PyDict_SetItemString(self->params," longuest_edgeC",Py_BuildValue("d",400.000000));67 PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d", 1.000000));68 PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d", 1.000000));67 PyDict_SetItemString(self->params,"long_c",Py_BuildValue("d",400.000000)); 68 PyDict_SetItemString(self->params,"parallel_psi",Py_BuildValue("d",0.000000)); 69 PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d",0.000000)); 70 PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d",0.000000)); 69 71 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 70 PyDict_SetItemString(self->params,"short_edgeA",Py_BuildValue("d",35.000000));71 72 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005)); 72 73 … … 119 120 120 121 // Reader parameter dictionary 122 self->model_pars.short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") ); 123 self->model_pars.short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") ); 121 124 self->model_pars.scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 122 self->model_pars.long er_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") );123 self->model_pars. longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") );125 self->model_pars.long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") ); 126 self->model_pars.parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 124 127 self->model_pars.parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); 125 128 self->model_pars.parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") ); 126 129 self->model_pars.background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 127 self->model_pars.short_edgeA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_edgeA") );128 130 self->model_pars.contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 129 131 … … 154 156 return Py_BuildValue("d",0.0); 155 157 } 156 return Py_BuildValue("d", _analytical_2D(&(self->model_pars),q_value,phi_value));158 return Py_BuildValue("d",parallelepiped_analytical_2D(&(self->model_pars),q_value,phi_value)); 157 159 158 160 } else { … … 161 163 q_value = CParallelepipedModel_readDouble(pars); 162 164 163 return Py_BuildValue("d", _analytical_1D(&(self->model_pars),q_value));165 return Py_BuildValue("d",parallelepiped_analytical_1D(&(self->model_pars),q_value)); 164 166 } 165 167 } … … 178 180 179 181 // Reader parameter dictionary 182 self->model_pars.short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") ); 183 self->model_pars.short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") ); 180 184 self->model_pars.scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") ); 181 self->model_pars.long er_edgeB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longer_edgeB") );182 self->model_pars. longuest_edgeC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longuest_edgeC") );185 self->model_pars.long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") ); 186 self->model_pars.parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") ); 183 187 self->model_pars.parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") ); 184 188 self->model_pars.parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") ); 185 189 self->model_pars.background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") ); 186 self->model_pars.short_edgeA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_edgeA") );187 190 self->model_pars.contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") ); 188 191 … … 209 212 qx_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,0)); 210 213 qy_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,1)); 211 return Py_BuildValue("d", _analytical_2DXY(&(self->model_pars),qx_value,qy_value));214 return Py_BuildValue("d",parallelepiped_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 212 215 213 216 } else { … … 216 219 qx_value = CParallelepipedModel_readDouble(pars); 217 220 218 return Py_BuildValue("d", _analytical_1D(&(self->model_pars),qx_value));221 return Py_BuildValue("d",parallelepiped_analytical_1D(&(self->model_pars),qx_value)); 219 222 } 220 223 } -
sansmodels/src/sans/models/c_extensions/CSphereModel.c
r9316609 ra8d6888 1 /** [PYTHONCLASS]1 /** CSphereModel 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * [PYTHONCLASS]Error = NULL;22 static PyObject * CSphereModelError = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 SphereParameters model_pars; 34 } [PYTHONCLASS];34 } CSphereModel; 35 35 36 36 37 37 static void 38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self)38 CSphereModel_dealloc(CSphereModel* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 CSphereModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 [PYTHONCLASS]*self;49 50 self = ( [PYTHONCLASS]*)type->tp_alloc(type, 0);48 CSphereModel *self; 49 50 self = (CSphereModel *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 [PYTHONCLASS]_init([PYTHONCLASS]*self, PyObject *args, PyObject *kwds)56 CSphereModel_init(CSphereModel *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 62 62 63 63 // Initialize parameter dictionary 64 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d", 0.000001));64 PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000)); 65 65 PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",60.000000)); 66 66 PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000)); 67 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d", 1.000000));67 PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000001)); 68 68 69 69 … … 77 77 } 78 78 79 static PyMemberDef [PYTHONCLASS]_members[] = {80 {"params", T_OBJECT, offsetof( [PYTHONCLASS], params), 0,79 static PyMemberDef CSphereModel_members[] = { 80 {"params", T_OBJECT, offsetof(CSphereModel, params), 0, 81 81 "Parameters"}, 82 {"log", T_OBJECT, offsetof( [PYTHONCLASS], log), 0,82 {"log", T_OBJECT, offsetof(CSphereModel, log), 0, 83 83 "Log"}, 84 84 {NULL} /* Sentinel */ … … 89 89 @return double 90 90 */ 91 double [PYTHONCLASS]_readDouble(PyObject *p) {91 double CSphereModel_readDouble(PyObject *p) { 92 92 if (PyFloat_Check(p)==1) { 93 93 return (double)(((PyFloatObject *)(p))->ob_fval); … … 107 107 * @return: function value 108 108 */ 109 static PyObject * run( [PYTHONCLASS]*self, PyObject *args) {109 static PyObject * run(CSphereModel *self, PyObject *args) { 110 110 double q_value, phi_value; 111 111 PyObject* pars; … … 123 123 // Get input and determine whether we have to supply a 1D or 2D return value. 124 124 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 125 PyErr_SetString( [PYTHONCLASS]Error,126 " [PYTHONCLASS].run expects a q value.");125 PyErr_SetString(CSphereModelError, 126 "CSphereModel.run expects a q value."); 127 127 return NULL; 128 128 } … … 134 134 npars = PyList_GET_SIZE(pars); 135 135 if(npars!=2) { 136 PyErr_SetString( [PYTHONCLASS]Error,137 " [PYTHONCLASS].run expects a double or a list of dimension 2.");136 PyErr_SetString(CSphereModelError, 137 "CSphereModel.run expects a double or a list of dimension 2."); 138 138 return NULL; 139 139 } 140 140 // We have a vector q, get the q and phi values at which 141 141 // to evaluate I(q,phi) 142 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));143 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));142 q_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 143 phi_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 144 144 // Skip zero 145 145 if (q_value==0) { … … 151 151 152 152 // We have a scalar q, we will evaluate I(q) 153 q_value = [PYTHONCLASS]_readDouble(pars);153 q_value = CSphereModel_readDouble(pars); 154 154 155 155 return Py_BuildValue("d",sphere_analytical_1D(&(self->model_pars),q_value)); … … 162 162 * @return: function value 163 163 */ 164 static PyObject * runXY( [PYTHONCLASS]*self, PyObject *args) {164 static PyObject * runXY(CSphereModel *self, PyObject *args) { 165 165 double qx_value, qy_value; 166 166 PyObject* pars; … … 178 178 // Get input and determine whether we have to supply a 1D or 2D return value. 179 179 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 180 PyErr_SetString( [PYTHONCLASS]Error,181 " [PYTHONCLASS].run expects a q value.");180 PyErr_SetString(CSphereModelError, 181 "CSphereModel.run expects a q value."); 182 182 return NULL; 183 183 } … … 189 189 npars = PyList_GET_SIZE(pars); 190 190 if(npars!=2) { 191 PyErr_SetString( [PYTHONCLASS]Error,192 " [PYTHONCLASS].run expects a double or a list of dimension 2.");191 PyErr_SetString(CSphereModelError, 192 "CSphereModel.run expects a double or a list of dimension 2."); 193 193 return NULL; 194 194 } 195 195 // We have a vector q, get the qx and qy values at which 196 196 // to evaluate I(qx,qy) 197 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0));198 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1));197 qx_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0)); 198 qy_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1)); 199 199 return Py_BuildValue("d",sphere_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 200 200 … … 202 202 203 203 // We have a scalar q, we will evaluate I(q) 204 qx_value = [PYTHONCLASS]_readDouble(pars);204 qx_value = CSphereModel_readDouble(pars); 205 205 206 206 return Py_BuildValue("d",sphere_analytical_1D(&(self->model_pars),qx_value)); … … 208 208 } 209 209 210 static PyObject * reset( [PYTHONCLASS]*self, PyObject *args) {210 static PyObject * reset(CSphereModel *self, PyObject *args) { 211 211 212 212 … … 215 215 216 216 217 static PyMethodDef [PYTHONCLASS]_methods[] = {217 static PyMethodDef CSphereModel_methods[] = { 218 218 {"run", (PyCFunction)run , METH_VARARGS, 219 219 "Evaluate the model at a given Q or Q, phi"}, … … 227 227 }; 228 228 229 static PyTypeObject [PYTHONCLASS]Type = {229 static PyTypeObject CSphereModelType = { 230 230 PyObject_HEAD_INIT(NULL) 231 231 0, /*ob_size*/ 232 " [PYTHONCLASS]", /*tp_name*/233 sizeof( [PYTHONCLASS]), /*tp_basicsize*/232 "CSphereModel", /*tp_name*/ 233 sizeof(CSphereModel), /*tp_basicsize*/ 234 234 0, /*tp_itemsize*/ 235 (destructor) [PYTHONCLASS]_dealloc, /*tp_dealloc*/235 (destructor)CSphereModel_dealloc, /*tp_dealloc*/ 236 236 0, /*tp_print*/ 237 237 0, /*tp_getattr*/ … … 249 249 0, /*tp_as_buffer*/ 250 250 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 251 " [PYTHONCLASS]objects", /* tp_doc */251 "CSphereModel objects", /* tp_doc */ 252 252 0, /* tp_traverse */ 253 253 0, /* tp_clear */ … … 256 256 0, /* tp_iter */ 257 257 0, /* tp_iternext */ 258 [PYTHONCLASS]_methods, /* tp_methods */259 [PYTHONCLASS]_members, /* tp_members */258 CSphereModel_methods, /* tp_methods */ 259 CSphereModel_members, /* tp_members */ 260 260 0, /* tp_getset */ 261 261 0, /* tp_base */ … … 264 264 0, /* tp_descr_set */ 265 265 0, /* tp_dictoffset */ 266 (initproc) [PYTHONCLASS]_init, /* tp_init */266 (initproc)CSphereModel_init, /* tp_init */ 267 267 0, /* tp_alloc */ 268 [PYTHONCLASS]_new, /* tp_new */268 CSphereModel_new, /* tp_new */ 269 269 }; 270 270 … … 278 278 * @param module: module to add the class to 279 279 */ 280 void add [PYTHONCLASS](PyObject *module) {280 void addCSphereModel(PyObject *module) { 281 281 PyObject *d; 282 282 283 if (PyType_Ready(& [PYTHONCLASS]Type) < 0)283 if (PyType_Ready(&CSphereModelType) < 0) 284 284 return; 285 285 286 Py_INCREF(& [PYTHONCLASS]Type);287 PyModule_AddObject(module, " [PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type);286 Py_INCREF(&CSphereModelType); 287 PyModule_AddObject(module, "CSphereModel", (PyObject *)&CSphereModelType); 288 288 289 289 d = PyModule_GetDict(module); 290 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL);291 PyDict_SetItemString(d, " [PYTHONCLASS]Error", [PYTHONCLASS]Error);292 } 293 290 CSphereModelError = PyErr_NewException("CSphereModel.error", NULL, NULL); 291 PyDict_SetItemString(d, "CSphereModelError", CSphereModelError); 292 } 293
Note: See TracChangeset
for help on using the changeset viewer.