| Bsoft 2.0.5 Bernard's software package

simplex.h
Go to the documentation of this file.
1
14 #include <vector>
15
16 using namespace std;
17
41 #ifndef _Bsimplex_
42 class Bsimplex {
43 private:
44 long nvar; // Number of variables
45 long nparam; // Number of parameters
46 long nconstant; // Number of constants
47 long npoint; // Number of function values
48 vector<double> param; // Parameter values
49 vector<double> lo; // Lower limits on parameter values
50 vector<double> hi; // Upper limits on parameter values
51 vector<double> c; // Constant values
52 vector<double> x; // Independent variables: npoint*nvar array
53 vector<double> fx; // Function values
54 public:
55 Bsimplex() { }
56 Bsimplex(long nv, long np, long nc, long n, vector<double>& ax, vector<double>& ay);
57 long variables() { return nvar; }
58 long constants() { return nconstant; }
59 double constant(long i) { return c[i]; }
60 void constant(long i, double p) { c[i] = p; }
61 void constants(long n, vector<double>& p) {
62 for ( long i=0; i<nconstant && i<n; i++ ) c[i] = p[i];
63 }
64 long points() { return npoint; }
65 long parameters() { return nparam; }
66 void parameters(long n, vector<double>& p) {
67 for ( int i=0; i<nparam && i<n; i++ ) param[i] = p[i];
68 }
69 void parameter(long i, double p) { param[i] = p; }
70 double parameter(long i) { return param[i]; }
71 void limit_low(long i, double v) { lo[i] = v; }
72 double limit_low(long i) { return lo[i]; }
73 void limit_high(long i, double v) { hi[i] = v; }
74 double limit_high(long i) { return hi[i]; }
75 void limits(long i, double vlo, double vhi) { lo[i] = vlo; hi[i] = vhi; }
76 void limits_low(long n, vector<double>& p) {
77 for ( long i=0; i<nparam && i<n; i++ ) lo[i] = p[i];
78 }
79 void limits_high(long n, vector<double>& p) {
80 for ( int i=0; i<nparam && i<n; i++ ) hi[i] = p[i];
81 }
82 vector<double>& independent_values() { return x; }
83 vector<double>& dependent_values() { return fx; }
84 double run(long maxcycles, double tolerance, double (funk)(Bsimplex&));
85 double amotry(vector<double>& mp, vector<double>& R, long ihi, double fac,
86 double (funk)(Bsimplex&));
87 } ;
88 #define _Bsimplex_
89 #endif
90
Bsimplex::parameters
void parameters(long n, vector< double > &p)
Definition: simplex.h:66
Bsimplex::variables
long variables()
Definition: simplex.h:57
Bsimplex::limit_low
double limit_low(long i)
Definition: simplex.h:72
Bsimplex::constants
void constants(long n, vector< double > &p)
Definition: simplex.h:61
Bsimplex
Structure used in the downhill simplex method.
Definition: simplex.h:42
Bsimplex::Bsimplex
Bsimplex()
Definition: simplex.h:55
Bsimplex::constants
long constants()
Definition: simplex.h:58
Bsimplex::parameter
void parameter(long i, double p)
Definition: simplex.h:69
Bsimplex::dependent_values
vector< double > & dependent_values()
Definition: simplex.h:83
Bsimplex::parameter
double parameter(long i)
Definition: simplex.h:70
Bsimplex::independent_values
vector< double > & independent_values()
Definition: simplex.h:82
Bsimplex::points
long points()
Definition: simplex.h:64
Bsimplex::limit_high
void limit_high(long i, double v)
Definition: simplex.h:73
Bsimplex::limits_low
void limits_low(long n, vector< double > &p)
Definition: simplex.h:76
Bsimplex::constant
double constant(long i)
Definition: simplex.h:59
Bsimplex::limits_high
void limits_high(long n, vector< double > &p)
Definition: simplex.h:79
Bsimplex::limit_low
void limit_low(long i, double v)
Definition: simplex.h:71
Bsimplex::limit_high
double limit_high(long i)
Definition: simplex.h:74
Bsimplex::parameters
long parameters()
Definition: simplex.h:65
Bsimplex::constant
void constant(long i, double p)
Definition: simplex.h:60
Bsimplex::limits
void limits(long i, double vlo, double vhi)
Definition: simplex.h:75