3
|
1 // Objective.h -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
29 class Objective |
|
30 { |
|
31 public: |
|
32 |
1536
|
33 typedef double (*objective_fcn) (const ColumnVector&); |
|
34 typedef ColumnVector (*gradient_fcn) (const ColumnVector&); |
|
35 |
|
36 Objective (void) |
|
37 { |
|
38 phi = 0; |
|
39 grad = 0; |
|
40 } |
3
|
41 |
1536
|
42 Objective (const objective_fcn obj) |
|
43 { |
|
44 phi = obj; |
|
45 grad = 0; |
|
46 } |
3
|
47 |
1536
|
48 Objective (const objective_fcn obj, const gradient_fcn g) |
|
49 { |
|
50 phi = obj; |
|
51 grad = g; |
|
52 } |
3
|
53 |
1536
|
54 Objective (const Objective& a) |
|
55 { |
|
56 phi = a.phi; |
|
57 grad = a.grad; |
|
58 } |
3
|
59 |
1536
|
60 Objective& operator = (const Objective& a) |
|
61 { |
|
62 phi = a.phi; |
|
63 grad = a.grad; |
|
64 |
|
65 return *this; |
|
66 } |
3
|
67 |
1536
|
68 objective_fcn objective_function (void) const { return phi; } |
|
69 |
|
70 Objective& set_objective_function (const objective_fcn obj) |
|
71 { |
|
72 phi = obj; |
|
73 return *this; |
|
74 } |
3
|
75 |
1536
|
76 gradient_fcn gradient_function (void) const { return grad; } |
|
77 |
|
78 Objective& set_gradient_function (const gradient_fcn g) |
|
79 { |
|
80 grad = g; |
|
81 return *this; |
|
82 } |
3
|
83 |
|
84 private: |
|
85 |
|
86 objective_fcn phi; |
|
87 gradient_fcn grad; |
|
88 |
|
89 }; |
|
90 |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; page-delimiter: "^/\\*" *** |
|
97 ;;; End: *** |
|
98 */ |