gsl_min_fminimizer.h

Go to the documentation of this file.
00001 
00002 
00003 //
00014 
00015 //  This function minimizer class has been adapted from the gslwrap project.
00016 //  It is a C++ wrapper for the GNU Scientific Library
00017 //  Copyright (C) 2001 Ramin Nakisa
00018 
00019 //  This program is free software; you can redistribute it and/or modify
00020 //  it under the terms of the GNU General Public License as published by
00021 //  the Free Software Foundation; either version 2 of the License, or
00022 //  (at your option) any later version.
00023 
00024 //  This program is distributed in the hope that it will be useful,
00025 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 //  GNU General Public License for more details.
00028 
00029 //  You should have received a copy of the GNU General Public License
00030 //  along with this program; if not, write to the Free Software
00031 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00032 
00033 
00034 #ifndef __GSL_MIN_FMINIMIZER_H
00035 #define __GSL_MIN_FMINIMIZER_H 
00036 
00037 #include <gsl/gsl_errno.h>
00038 #include <gsl/gsl_min.h>
00039 
00041 //
00042 
00043 class min_f
00044 {
00045   public:
00046 
00048 //
00050 //
00051 
00052         virtual double operator()(const double& x);
00053 
00055 //
00058 //
00059 
00060         static double f(double x, void *p);
00061 
00062 };
00063 
00065 //
00066 
00067 class min_fminimizer 
00068 {
00069  public:
00070  
00072 //
00075 //
00076         
00077         min_fminimizer(const gsl_min_fminimizer_type* type=gsl_min_fminimizer_brent);
00078 
00080 //
00082 //
00083         
00084         ~min_fminimizer();
00085 
00087 //
00095 //
00096 
00097         int set(min_f& function, double minimum, double x_lower, double x_upper);
00099 //
00108         
00109         int set_with_values(min_f& function, 
00110                                                 double minimum, double f_minimum, 
00111                                                 double x_lower,double f_lower, 
00112                                                 double x_upper, double f_upper);
00113 
00115 //
00121 
00122         int iterate();
00123 
00125 //
00126 
00127         double minimum();
00128 
00130 //
00131 
00132         double x_upper();
00133 
00135 //
00136 
00137         double x_lower();
00138 
00140 //
00142 //
00143         void SetMaxIterations(int n);
00144 
00146 //
00147         
00148         int GetNIterations();
00149 
00151 //
00153 //
00154 
00155         bool is_converged();
00156         
00157  private:
00158  
00160 //
00161 
00162         void assert_set(); 
00163         
00165 //
00166 
00167         bool isSet;
00168 
00170 //
00171 
00172         bool isConverged;
00173 
00175 //
00176         
00177         int nIterations;
00178 
00180 //
00181 
00182         int maxIterations;
00183 
00185 //
00186         
00187         gsl_min_fminimizer* s;
00188 
00190 //
00191         gsl_function f;
00192 };
00193 
00194 #endif //__min_fminimizer_h
All Classes Files Functions Variables Typedefs Friends Defines