source: sasview/sansmodels/src/sans/models/c_models/parameters.hh @ 7c427a6

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 7c427a6 was fca6936, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

First cut at better polydisp and averaging implementation for sans models.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2        This software was developed by the University of Tennessee as part of the
3        Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4        project funded by the US National Science Foundation.
5
6        If you use DANSE applications to do scientific research that leads to
7        publication, we ask that you acknowledge the use of the software with the
8        following sentence:
9
10        "This work benefited from DANSE software developed under NSF award DMR-0520547."
11
12        copyright 2008, University of Tennessee
13 */
14#ifndef PARAM_CLASS_H
15#define PARAM_CLASS_H
16/**
17 * TODO: will need to write a bridge class
18 * to convert the dispersion model parameters
19 * into dictionary parameters for python.
20 */
21#include <vector>
22#include "dispersion_visitor.hh"
23
24using namespace std;
25
26/**
27 * Weight point class to hold averaging points
28 */
29class WeightPoint {
30public:
31        /// Value of the weight point
32        double value;
33        /// Weight of the weight point
34        double weight;
35
36        WeightPoint();
37        WeightPoint(double, double);
38};
39
40/**
41 * Basic averaging model. The class instance will
42 * generate a flat distribution of weight points
43 * according to the number of points specified
44 * and the width of the distribution. The center
45 * of the distribution is specified by the
46 * Parameter object taken in as a parameter.
47 */
48class DispersionModel {
49public:
50        /// Number of points to average over
51        int npts;
52        /// Width of the distribution (step function)
53        double width;
54
55        DispersionModel();
56        /// Method that generates the weight points
57        virtual void operator()(void *, vector<WeightPoint>&);
58        virtual void set_weights(int, double*, double*);
59        virtual void accept_as_source(DispersionVisitor*, void*, void*);
60        virtual void accept_as_destination(DispersionVisitor*, void*, void*);
61};
62
63
64/**
65 * Gaussian dispersion model
66 */
67class GaussianDispersion: public DispersionModel {
68public:
69        /// Number of sigmas on each side of the mean
70        int nsigmas;
71
72        GaussianDispersion();
73        void operator()(void *, vector<WeightPoint>&);
74        void accept_as_source(DispersionVisitor*, void*, void*);
75        void accept_as_destination(DispersionVisitor*, void*, void*);
76};
77
78/**
79 * Dispersion model based on arrays provided by the user
80 */
81class ArrayDispersion: public DispersionModel {
82private:
83        /// Array of values
84        double* _values;
85        /// Array of weights
86        double* _weights;
87
88        /// Method to set the weight points from arrays
89        void set_weights(int, double*, double*);
90        void operator()(void *, vector<WeightPoint>&);
91        void accept_as_source(DispersionVisitor*, void*, void*);
92        void accept_as_destination(DispersionVisitor*, void*, void*);
93public:
94
95};
96
97/**
98 * Parameter class to hold information about a
99 * parameter.
100 */
101class Parameter {
102public:
103        /// Current value of the parameter
104        double value;
105        /// True if the parameter has a minimum bound
106        bool has_min;
107        /// True if the parameter has a maximum bound
108        bool has_max;
109        /// Minimum bound
110        double min;
111        /// Maximum bound
112        double max;
113        /// True if the parameter can be dispersed or averaged
114        bool has_dispersion;
115        /// Pointer to the dispersion model object for this parameter
116        DispersionModel* dispersion;
117
118        Parameter();
119        Parameter(double);
120        Parameter(double, bool);
121
122        /// Method to set a minimum value
123        void set_min(double);
124        /// Method to set a maximum value
125        void set_max(double);
126        /// Method to get weight points for this parameter
127        void get_weights(vector<WeightPoint>&);
128        /// Returns the value of the parameter
129        double operator()();
130        /// Sets the value of the parameter
131        double operator=(double);
132};
133#endif
Note: See TracBrowser for help on using the repository browser.