Changeset fd080830 in sasview
- Timestamp:
- Jan 6, 2012 12:04:08 PM (13 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:
- 886dde6b
- Parents:
- 5b6e0f5
- Location:
- sansmodels/src
- Files:
-
- 5 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/c_models.cpp
r101065a rfd080830 48 48 void addCSLDCalFunc(PyObject *module); 49 49 50 //void addCOblateModel(PyObject *module);51 //void addCProlateModel(PyObject *module);52 50 void addCLamellarModel(PyObject *module); 53 51 void addCLamellarFFHGModel(PyObject *module); … … 62 60 63 61 extern "C" { 64 //void addCCoreShellCylinderModel(PyObject *module); 65 //void addCCoreShellModel(PyObject *module); 66 //void addCEllipsoidModel(PyObject *module); 67 //void addCEllipticalCylinderModel(PyObject *module); 68 void addDisperser(PyObject *module); 62 void addDisperser(PyObject *module); 69 63 } 70 64 void addCLorentzian(PyObject *module); … … 77 71 */ 78 72 void del_dispersion_model(void *ptr){ 79 80 81 73 DispersionModel * disp = static_cast<DispersionModel *>(ptr); 74 delete disp; 75 return; 82 76 } 83 77 … … 86 80 */ 87 81 PyObject * new_dispersion_model(PyObject *, PyObject *args) { 88 89 82 DispersionModel *disp = new DispersionModel(); 83 return PyCObject_FromVoidPtr(disp, del_dispersion_model); 90 84 } 91 85 … … 95 89 */ 96 90 void del_lognormal_dispersion(void *ptr){ 97 98 99 91 LogNormalDispersion * disp = static_cast<LogNormalDispersion *>(ptr); 92 delete disp; 93 return; 100 94 } 101 95 … … 104 98 */ 105 99 PyObject * new_lognormal_dispersion(PyObject *, PyObject *args) { 106 107 100 LogNormalDispersion *disp = new LogNormalDispersion(); 101 return PyCObject_FromVoidPtr(disp, del_lognormal_dispersion); 108 102 } 109 103 … … 112 106 */ 113 107 void del_gaussian_dispersion(void *ptr){ 114 115 116 108 GaussianDispersion * disp = static_cast<GaussianDispersion *>(ptr); 109 delete disp; 110 return; 117 111 } 118 112 … … 121 115 */ 122 116 PyObject * new_gaussian_dispersion(PyObject *, PyObject *args) { 123 124 117 GaussianDispersion *disp = new GaussianDispersion(); 118 return PyCObject_FromVoidPtr(disp, del_gaussian_dispersion); 125 119 } 126 120 … … 130 124 */ 131 125 void del_rectangle_dispersion(void *ptr){ 132 133 134 126 RectangleDispersion * disp = static_cast<RectangleDispersion *>(ptr); 127 delete disp; 128 return; 135 129 } 136 130 … … 139 133 */ 140 134 PyObject * new_rectangle_dispersion(PyObject *, PyObject *args) { 141 142 135 RectangleDispersion *disp = new RectangleDispersion(); 136 return PyCObject_FromVoidPtr(disp, del_rectangle_dispersion); 143 137 } 144 138 … … 148 142 */ 149 143 void del_schulz_dispersion(void *ptr){ 150 151 152 144 SchulzDispersion * disp = static_cast<SchulzDispersion *>(ptr); 145 delete disp; 146 return; 153 147 } 154 148 /** … … 156 150 */ 157 151 PyObject * new_schulz_dispersion(PyObject *, PyObject *args) { 158 159 152 SchulzDispersion *disp = new SchulzDispersion(); 153 return PyCObject_FromVoidPtr(disp, del_schulz_dispersion); 160 154 } 161 155 … … 165 159 */ 166 160 void del_array_dispersion(void *ptr){ 167 168 169 161 ArrayDispersion * disp = static_cast<ArrayDispersion *>(ptr); 162 delete disp; 163 return; 170 164 } 171 165 … … 174 168 */ 175 169 PyObject * new_array_dispersion(PyObject *, PyObject *args) { 176 177 170 ArrayDispersion *disp = new ArrayDispersion(); 171 return PyCObject_FromVoidPtr(disp, del_array_dispersion); 178 172 } 179 173 180 174 #define INVECTOR(obj,buf,len) \ 181 175 do { \ 182 183 184 176 int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \ 177 if (err < 0) return NULL; \ 178 len /= sizeof(*buf); \ 185 179 } while (0) 186 180 … … 189 183 */ 190 184 PyObject * set_weights(PyObject *, PyObject *args) { 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 185 PyObject *val_obj; 186 PyObject *wei_obj; 187 PyObject *disp; 188 Py_ssize_t nval; 189 Py_ssize_t nwei; 190 double *values; 191 double *weights; 192 //int i; 193 194 if (!PyArg_ParseTuple(args, "OOO", &disp, &val_obj, &wei_obj)) return NULL; 195 INVECTOR(val_obj, values, nval); 196 INVECTOR(wei_obj, weights, nwei); 197 198 // Sanity check 199 if(nval!=nwei) return NULL; 200 201 // Set the array pointers 202 void *temp = PyCObject_AsVoidPtr(disp); 203 DispersionModel * dispersion = static_cast<DispersionModel *>(temp); 204 dispersion->set_weights(nval, values, weights); 205 206 return Py_BuildValue("i",1); 213 207 } 214 208 … … 219 213 */ 220 214 static PyMethodDef module_methods[] = { 221 222 223 224 225 226 227 {"new_lognormal_model", (PyCFunction)new_lognormal_dispersion, METH_VARARGS,228 229 {"new_schulz_model", (PyCFunction)new_schulz_dispersion, METH_VARARGS,230 231 232 233 234 235 {NULL}215 {"new_dispersion_model", (PyCFunction)new_dispersion_model , METH_VARARGS, 216 "Create a new DispersionModel object"}, 217 {"new_gaussian_model", (PyCFunction)new_gaussian_dispersion, METH_VARARGS, 218 "Create a new GaussianDispersion object"}, 219 {"new_rectangle_model", (PyCFunction)new_rectangle_dispersion, METH_VARARGS, 220 "Create a new RectangleDispersion object"}, 221 {"new_lognormal_model", (PyCFunction)new_lognormal_dispersion, METH_VARARGS, 222 "Create a new LogNormalDispersion object"}, 223 {"new_schulz_model", (PyCFunction)new_schulz_dispersion, METH_VARARGS, 224 "Create a new SchulzDispersion object"}, 225 {"new_array_model", (PyCFunction)new_array_dispersion , METH_VARARGS, 226 "Create a new ArrayDispersion object"}, 227 {"set_dispersion_weights",(PyCFunction)set_weights , METH_VARARGS, 228 "Create the dispersion weight arrays for an Array Dispersion object"}, 229 {NULL} 236 230 }; 237 231 … … 243 237 initc_models(void) 244 238 { 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 } 239 PyObject* m; 240 241 m = Py_InitModule3("c_models", module_methods, 242 "C extension module for SANS scattering models."); 243 import_array(); 244 245 addCCylinderModel(m); 246 addCBarBellModel(m); 247 addCCappedCylinderModel(m); 248 addCParallelepipedModel(m); 249 addCCSParallelepipedModel(m); 250 addCCoreShellCylinderModel(m); 251 addCCoreShellModel(m); 252 addCCoreFourShellModel(m); 253 addCEllipsoidModel(m); 254 addCSphereModel(m); 255 addCSphereSLDModel(m); 256 addCOnionModel(m); 257 addCReflModel(m); 258 addCReflAdvModel(m); 259 addCFuzzySphereModel(m); 260 addCHardsphereStructure(m); 261 addCStickyHSStructure(m); 262 addCSCCrystalModel(m); 263 addCFCCrystalModel(m); 264 addCBCCrystalModel(m); 265 addCSquareWellStructure(m); 266 addCHayterMSAStructure(m); 267 addCEllipticalCylinderModel(m); 268 addCTriaxialEllipsoidModel(m); 269 addCFlexibleCylinderModel(m); 270 addCFlexCylEllipXModel(m); 271 addCStackedDisksModel(m); 272 addCLamellarPSModel(m); 273 addCLamellarPSHGModel(m); 274 addCLamellarPCrystalModel(m); 275 addCCoreShellEllipsoidModel(m); 276 addCDiamEllipFunc(m); 277 addCDiamCylFunc(m); 278 addCSLDCalFunc(m); 279 addCPearlNecklaceModel(m); 280 addCLamellarModel(m); 281 addCLamellarFFHGModel(m); 282 addCHollowCylinderModel(m); 283 addCMultiShellModel(m); 284 addCBinaryHSModel(m); 285 addDisperser(m); 286 addCGaussian(m); 287 addCSchulz(m); 288 addCLogNormal(m); 289 addCLorentzian(m); 290 addCVesicleModel(m); 291 addCPoly_GaussCoil(m); 292 addCRPAModel(m); 293 addCFractalModel(m); 294 }
Note: See TracChangeset
for help on using the changeset viewer.