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

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 18695bf was eba9885, checked in by Gervaise Alina <gervyh@…>, 15 years ago

code for evalDistribution

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