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

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 b1a65b6 was 8dc02d8b, checked in by Jae Cho <jhjcho@…>, 14 years ago

added rectangular function for poly-dispersion

  • Property mode set to 100644
File size: 4.6 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        double 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 * Flat dispersion model
80 */
81class RectangleDispersion: public DispersionModel {
82public:
83        /// Number of sigmas on each side of the mean
84        double nsigmas;
85
86        RectangleDispersion();
87        void operator()(void *, vector<WeightPoint>&);
88        void accept_as_source(DispersionVisitor*, void*, void*);
89        void accept_as_destination(DispersionVisitor*, void*, void*);
90};
91
92/**
93 * Schulz dispersion model
94 */
95class SchulzDispersion: public DispersionModel {
96public:
97        /// Number of sigmas on each side of the mean
98        double nsigmas;
99
100        SchulzDispersion();
101        void operator()(void *, vector<WeightPoint>&);
102        void accept_as_source(DispersionVisitor*, void*, void*);
103        void accept_as_destination(DispersionVisitor*, void*, void*);
104};
105
106/**
107 * LogNormal dispersion model
108 */
109class LogNormalDispersion: public DispersionModel {
110public:
111        /// Number of sigmas on each side of the mean
112        double nsigmas;
113
114        LogNormalDispersion();
115        void operator()(void *, vector<WeightPoint>&);
116        void accept_as_source(DispersionVisitor*, void*, void*);
117        void accept_as_destination(DispersionVisitor*, void*, void*);
118};
119
120
121/**
122 * Dispersion model based on arrays provided by the user
123 */
124class ArrayDispersion: public DispersionModel {
125private:
126        /// Array of values
127        double* _values;
128        /// Array of weights
129        double* _weights;
130
131        /// Method to set the weight points from arrays
132        void set_weights(int, double*, double*);
133        void operator()(void *, vector<WeightPoint>&);
134        void accept_as_source(DispersionVisitor*, void*, void*);
135        void accept_as_destination(DispersionVisitor*, void*, void*);
136public:
137
138};
139
140/**
141 * Parameter class to hold information about a
142 * parameter.
143 */
144class Parameter {
145public:
146        /// Current value of the parameter
147        double value;
148        /// True if the parameter has a minimum bound
149        bool has_min;
150        /// True if the parameter has a maximum bound
151        bool has_max;
152        /// Minimum bound
153        double min;
154        /// Maximum bound
155        double max;
156        /// True if the parameter can be dispersed or averaged
157        bool has_dispersion;
158        /// Pointer to the dispersion model object for this parameter
159        DispersionModel* dispersion;
160
161        Parameter();
162        Parameter(double);
163        Parameter(double, bool);
164
165        /// Method to set a minimum value
166        void set_min(double);
167        /// Method to set a maximum value
168        void set_max(double);
169        /// Method to get weight points for this parameter
170        void get_weights(vector<WeightPoint>&);
171        /// Returns the value of the parameter
172        double operator()();
173        /// Sets the value of the parameter
174        double operator=(double);
175};
176#endif
Note: See TracBrowser for help on using the repository browser.