MNE-CPP  beta 1.0
minimizersimplex.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef MINIMIZERSIMPLEX_H
38 #define MINIMIZERSIMPLEX_H
39 
40 //*************************************************************************************************************
41 //=============================================================================================================
42 // INCLUDES
43 //=============================================================================================================
44 
45 #include "utils_global.h"
46 #include <iostream>
47 
48 //*************************************************************************************************************
49 //=============================================================================================================
50 // Qt INCLUDES
51 //=============================================================================================================
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // Eigen INCLUDES
57 //=============================================================================================================
58 
59 #include <Eigen/Eigen>
60 
61 
62 //*************************************************************************************************************
63 //=============================================================================================================
64 // DEFINE NAMESPACE MNELIB
65 //=============================================================================================================
66 
67 namespace UTILSLIB
68 {
69 
70 
71 //*************************************************************************************************************
72 //=============================================================================================================
73 // USED NAMESPACES
74 //=============================================================================================================
75 
76 using namespace Eigen;
77 
78 
79 //*************************************************************************************************************
80 //=============================================================================================================
81 // DEFINES
82 //=============================================================================================================
83 
84 #define ALPHA 1.0
85 #define BETA 0.5
86 #define GAMMA 2.0
87 
88 
89 //=============================================================================================================
96 {
97 public:
98  //=========================================================================================================
103 
104  static int mne_simplex_minimize(MatrixXf p, /* The initial simplex */
105  VectorXf y, /* Function values at the vertices */
106  int ndim, /* Number of variables */
107  float ftol, /* Relative convergence tolerance */
108  float (*func)(const VectorXf &x,
109  int npar,
110  void *user_data), /* The function to be evaluated */
111  void *user_data, /* Data to be passed to the above function in each evaluation */
112  int max_eval, /* Maximum number of function evaluations */
113  int &neval, /* Number of function evaluations */
114  int report, /* How often to report (-1 = no_reporting) */
115  int (*report_func)(int loop,
116  const VectorXf &fitpar,
117  int npar,
118  double fval)); /* The function to be called when reporting */
119 
120 private:
121  static float tryit(MatrixXf p,
122  VectorXf y,
123  VectorXf psum,
124  int ndim,
125  float (*func)(const VectorXf &x,
126  int npar,
127  void *user_data), /* The function to be evaluated */
128  void *user_data, /* Data to be passed to the above function in each evaluation */
129  int ihi,
130  int &neval,
131  float fac);
132 
133 };
134 
135 } //NAMESPACE
136 
137 #endif // MINIMIZERSIMPLEX_H
utils library export/import macros.
Simplex minimizer code from numerical recipes.