Changeset a9dec92 in sasview for sansmodels/src/sans/models


Ignore:
Timestamp:
Aug 6, 2008 4:39:35 PM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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
Message:

update to sans model functors

Location:
sansmodels/src/sans/models/c_extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/models.cpp

    r129284a ra9dec92  
    1010extern "C" { 
    1111        #include "libCylinder.h" 
     12        #include "cylinder.h" 
    1213} 
    1314 
    14 Cylindser :: Cylinder() { 
    15         scale = 1.0; 
    16         radius = 10.0; 
    17         length = 400.0; 
    18         contrast = 1.0; 
    19         background = 0; 
     15Cylinder :: 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; 
    2023} 
    2124 
     25/** 
     26 * Function to evaluate 1D scattering function 
     27 * @param q: q-value 
     28 * @return: function value 
     29 */ 
    2230double 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(&parameters, q); 
     32} 
    3033 
    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 */ 
     40double Cylinder :: operator()(double qx, double qy) { 
     41        return cylinder_analytical_2DXY(&parameters, qx, qy); 
    3342} 
    3443 
     
    3746        Cylinder c = Cylinder(); 
    3847        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)); 
    3949        return 0; 
    4050} 
  • sansmodels/src/sans/models/c_extensions/models.h

    r17a6843 ra9dec92  
    22#define MODEL_CLASS_H 
    33 
     4extern "C" { 
     5        #include "cylinder.h" 
     6} 
    47 
    5 class Cylinder{ 
    6 private: 
    7         double scale; 
    8         double radius; 
    9         double length; 
    10         double contrast; 
    11         double background; 
     8class Cylinder { 
     9 
    1210public: 
     11        // Model parameters 
     12        CylinderParameters parameters; 
     13 
     14        // Constructor 
    1315        Cylinder(); 
     16 
     17        // Operators to get I(Q) 
    1418        double operator()(double q); 
     19        double operator()(double qx, double qy); 
     20 
    1521}; 
    1622 
Note: See TracChangeset for help on using the changeset viewer.