Changeset a9dec92 in sasview for sansmodels/src/sans
- Timestamp:
- Aug 6, 2008 4:39:35 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:
- 6fc9a2a
- Parents:
- d53bc33
- Location:
- sansmodels/src/sans/models/c_extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/models.cpp
r129284a ra9dec92 10 10 extern "C" { 11 11 #include "libCylinder.h" 12 #include "cylinder.h" 12 13 } 13 14 14 Cylindser :: Cylinder() { 15 scale = 1.0; 16 radius = 10.0; 17 length = 400.0; 18 contrast = 1.0; 19 background = 0; 15 Cylinder :: Cylinder() { 16 parameters.scale = 1.0; 17 parameters.radius = 10.0; 18 parameters.length = 400.0; 19 parameters.contrast = 1.0; 20 parameters.background = 0; 21 parameters.cyl_theta = 0; 22 parameters.cyl_phi = 0; 20 23 } 21 24 25 /** 26 * Function to evaluate 1D scattering function 27 * @param q: q-value 28 * @return: function value 29 */ 22 30 double Cylinder :: operator()(double q) { 23 double dp[5]; 24 // Fill paramater array 25 dp[0] = scale; 26 dp[1] = radius; 27 dp[2] = length; 28 dp[3] = contrast; 29 dp[4] = background; 31 return cylinder_analytical_1D(¶meters, q); 32 } 30 33 31 // Call library function to evaluate model 32 return CylinderForm(dp, q); 34 /** 35 * Function to evaluate 2D scattering function 36 * @param q_x: value of Q along x 37 * @param q_y: value of Q along y 38 * @return: function value 39 */ 40 double Cylinder :: operator()(double qx, double qy) { 41 return cylinder_analytical_2DXY(¶meters, qx, qy); 33 42 } 34 43 … … 37 46 Cylinder c = Cylinder(); 38 47 printf("I(Q=%g) = %g\n", 0.001, c(0.001)); 48 printf("I(Qx=%g, Qy=%g) = %g\n", 0.001, 0.001, c(0.001, 0.001)); 39 49 return 0; 40 50 } -
sansmodels/src/sans/models/c_extensions/models.h
r17a6843 ra9dec92 2 2 #define MODEL_CLASS_H 3 3 4 extern "C" { 5 #include "cylinder.h" 6 } 4 7 5 class Cylinder{ 6 private: 7 double scale; 8 double radius; 9 double length; 10 double contrast; 11 double background; 8 class Cylinder { 9 12 10 public: 11 // Model parameters 12 CylinderParameters parameters; 13 14 // Constructor 13 15 Cylinder(); 16 17 // Operators to get I(Q) 14 18 double operator()(double q); 19 double operator()(double qx, double qy); 20 15 21 }; 16 22
Note: See TracChangeset
for help on using the changeset viewer.