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