base-min.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1995-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_base_min_h)
00024 #define octave_base_min_h 1
00025 
00026 #include "dColVector.h"
00027 
00028 class
00029 base_minimizer
00030 {
00031 public:
00032 
00033   base_minimizer (void) : x () { }
00034 
00035   base_minimizer (const ColumnVector& xx) : x (xx) { }
00036 
00037   base_minimizer (const base_minimizer& a) : x (a.x) { }
00038 
00039   virtual ~base_minimizer (void) { }
00040 
00041   base_minimizer& operator = (const base_minimizer& a)
00042     {
00043       if (this != &a)
00044         x = a.x;
00045 
00046       return *this;
00047     }
00048 
00049   // Derived classes must provide a function to actually do the
00050   // minimization.
00051 
00052   virtual ColumnVector do_minimize (double& objf, octave_idx_type& inform,
00053                                     ColumnVector& lambda) = 0;
00054 
00055   // Lots of ways to call the single function and optionally set and
00056   // get additional information.
00057 
00058   virtual ColumnVector minimize (void)
00059     {
00060       double objf;
00061       octave_idx_type inform;
00062       ColumnVector lambda;
00063       return do_minimize (objf, inform, lambda);
00064     }
00065 
00066   virtual ColumnVector minimize (double& objf)
00067     {
00068       octave_idx_type inform;
00069       ColumnVector lambda;
00070       return do_minimize (objf, inform, lambda);
00071     }
00072 
00073   virtual ColumnVector minimize (double& objf, octave_idx_type& inform)
00074     {
00075       ColumnVector lambda;
00076       return do_minimize (objf, inform, lambda);
00077     }
00078 
00079   virtual ColumnVector minimize (double& objf, octave_idx_type& inform,
00080                                  ColumnVector& lambda)
00081     {
00082       return do_minimize (objf, inform, lambda);
00083     }
00084 
00085   virtual ColumnVector minimize (const ColumnVector& x0)
00086     {
00087       x = x0;
00088       double objf;
00089       octave_idx_type inform;
00090       ColumnVector lambda;
00091       return do_minimize (objf, inform, lambda);
00092     }
00093 
00094   virtual ColumnVector minimize (const ColumnVector& x0, double& objf)
00095     {
00096       x = x0;
00097       octave_idx_type inform;
00098       ColumnVector lambda;
00099       return do_minimize (objf, inform, lambda);
00100     }
00101 
00102   virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
00103                                  octave_idx_type& inform)
00104     {
00105       x = x0;
00106       ColumnVector lambda;
00107       return do_minimize (objf, inform, lambda);
00108     }
00109 
00110   virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
00111                                  octave_idx_type& inform, ColumnVector& lambda)
00112     {
00113       x = x0;
00114       return do_minimize (objf, inform, lambda);
00115     }
00116 
00117   octave_idx_type size (void) const { return x.capacity (); }
00118 
00119 protected:
00120 
00121   ColumnVector x;
00122 };
00123 
00124 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines