3
|
1 // Objective.h -*- C++ -*- |
|
2 /* |
|
3 |
1861
|
4 Copyright (C) 1996 John W. Eaton |
3
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_Objective_h) |
|
25 #define octave_Objective_h 1 |
|
26 |
1296
|
27 #include "dColVector.h" |
3
|
28 |
1861
|
29 class |
|
30 Objective |
3
|
31 { |
1861
|
32 public: |
3
|
33 |
1536
|
34 typedef double (*objective_fcn) (const ColumnVector&); |
|
35 typedef ColumnVector (*gradient_fcn) (const ColumnVector&); |
|
36 |
|
37 Objective (void) |
1861
|
38 : phi (0), grad (0) { } |
3
|
39 |
1536
|
40 Objective (const objective_fcn obj) |
1861
|
41 : phi (obj), grad (0) { } |
3
|
42 |
1536
|
43 Objective (const objective_fcn obj, const gradient_fcn g) |
1861
|
44 : phi (obj), grad (g) { } |
3
|
45 |
1536
|
46 Objective (const Objective& a) |
1861
|
47 : phi (a.phi), grad (a.grad) { } |
3
|
48 |
1536
|
49 Objective& operator = (const Objective& a) |
|
50 { |
1861
|
51 if (this != &a) |
|
52 { |
|
53 phi = a.phi; |
|
54 grad = a.grad; |
|
55 } |
1536
|
56 return *this; |
|
57 } |
3
|
58 |
1861
|
59 ~Objective (void) { } |
|
60 |
1536
|
61 objective_fcn objective_function (void) const { return phi; } |
|
62 |
|
63 Objective& set_objective_function (const objective_fcn obj) |
|
64 { |
|
65 phi = obj; |
|
66 return *this; |
|
67 } |
3
|
68 |
1536
|
69 gradient_fcn gradient_function (void) const { return grad; } |
|
70 |
|
71 Objective& set_gradient_function (const gradient_fcn g) |
|
72 { |
|
73 grad = g; |
|
74 return *this; |
|
75 } |
3
|
76 |
1861
|
77 private: |
3
|
78 |
|
79 objective_fcn phi; |
|
80 gradient_fcn grad; |
|
81 |
|
82 }; |
|
83 |
|
84 #endif |
|
85 |
|
86 /* |
|
87 ;;; Local Variables: *** |
|
88 ;;; mode: C++ *** |
|
89 ;;; page-delimiter: "^/\\*" *** |
|
90 ;;; End: *** |
|
91 */ |