GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
base-min.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1995-2013 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_base_min_h)
24 #define octave_base_min_h 1
25 
26 #include "dColVector.h"
27 
28 class
30 {
31 public:
32 
33  base_minimizer (void) : x () { }
34 
35  base_minimizer (const ColumnVector& xx) : x (xx) { }
36 
37  base_minimizer (const base_minimizer& a) : x (a.x) { }
38 
39  virtual ~base_minimizer (void) { }
40 
41  base_minimizer& operator = (const base_minimizer& a)
42  {
43  if (this != &a)
44  x = a.x;
45 
46  return *this;
47  }
48 
49  // Derived classes must provide a function to actually do the
50  // minimization.
51 
52  virtual ColumnVector do_minimize (double& objf, octave_idx_type& inform,
53  ColumnVector& lambda) = 0;
54 
55  // Lots of ways to call the single function and optionally set and
56  // get additional information.
57 
58  virtual ColumnVector minimize (void)
59  {
60  double objf;
61  octave_idx_type inform;
62  ColumnVector lambda;
63  return do_minimize (objf, inform, lambda);
64  }
65 
66  virtual ColumnVector minimize (double& objf)
67  {
68  octave_idx_type inform;
69  ColumnVector lambda;
70  return do_minimize (objf, inform, lambda);
71  }
72 
73  virtual ColumnVector minimize (double& objf, octave_idx_type& inform)
74  {
75  ColumnVector lambda;
76  return do_minimize (objf, inform, lambda);
77  }
78 
79  virtual ColumnVector minimize (double& objf, octave_idx_type& inform,
80  ColumnVector& lambda)
81  {
82  return do_minimize (objf, inform, lambda);
83  }
84 
85  virtual ColumnVector minimize (const ColumnVector& x0)
86  {
87  x = x0;
88  double objf;
89  octave_idx_type inform;
90  ColumnVector lambda;
91  return do_minimize (objf, inform, lambda);
92  }
93 
94  virtual ColumnVector minimize (const ColumnVector& x0, double& objf)
95  {
96  x = x0;
97  octave_idx_type inform;
98  ColumnVector lambda;
99  return do_minimize (objf, inform, lambda);
100  }
101 
102  virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
103  octave_idx_type& inform)
104  {
105  x = x0;
106  ColumnVector lambda;
107  return do_minimize (objf, inform, lambda);
108  }
109 
110  virtual ColumnVector minimize (const ColumnVector& x0, double& objf,
111  octave_idx_type& inform, ColumnVector& lambda)
112  {
113  x = x0;
114  return do_minimize (objf, inform, lambda);
115  }
116 
117  octave_idx_type size (void) const { return x.capacity (); }
118 
119 protected:
120 
122 };
123 
124 #endif