Debian Codegraph @

src/Algo/Param.hpp

raw symbols SCIP
1 /****************************************************************************/cxx . . $ `<file>/src/Algo/Param.hpp`/
2 /* This file is part of FreeFEM. */
3 /* */
4 /* FreeFEM is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU Lesser General Public License as */
6 /* published by the Free Software Foundation, either version 3 of */
7 /* the License, or (at your option) any later version. */
8 /* */
9 /* FreeFEM is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU Lesser General Public License for more details. */
13 /* */
14 /* You should have received a copy of the GNU Lesser General Public License */
15 /* along with FreeFEM. If not, see <http://www.gnu.org/licenses/>. */
16 /****************************************************************************/
17 // SUMMARY : ...
18 // LICENSE : LGPLv3
19 // ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
20 // AUTHORS : ...
21 // E-MAIL : ...
22
23 // Param class, inherited from KN
24 // This is the class of parameters against which we optimize
25 // We can possibly add constraints
26
27 #ifndef PARAM_HH
28 #define PARAM_HHcxx . . $ `src/Algo/Param.hpp:28:9`!
29
30 #include <iostream>
31 using namespace std;
32
33 #include "defs.hpp"cxx . . $ `<file>/src/Algo/defs.hpp`/
34 //#include "mvvtp.h"
35 //#include "mvblas.h"
36
37 // We nees a Vect type for update function
38 template< class Real >
39 class Paramcxx . . $ Param# : public KNcxx . . $ KN#< Real > {
40 private:
41 int ndimcxx . . $ Param#ndim.;
42 // These bound can be used in the update method of LineSearch.hpp
43 // This is a way to implement a projected gradient
44 KNcxx . . $ KN#< Real >* maxParamcxx . . $ Param#maxParam.;
45 KNcxx . . $ KN#< Real >* minParamcxx . . $ Param#minParam.;
46
47 public:
48 Paramcxx . . $ Param#`Param<Real>`(49f6e7a06ebc5aa8).( );
49 // construct a continuous model with size n
50 explicit Paramcxx . . $ Param#`Param<Real>`(d4f767463ce0a6b3).(int n);
51 // construct a continuous model space with boundary and initial values
52 Paramcxx . . $ Param#`Param<Real>`(40d6ce1614c156f7).(const KNcxx . . $ KN#< Real >& maxp, const KNcxx . . $ KN#< Real >& minp, const KNcxx . . $ KN#< Real >& initmod);
53 // construct a continuous model space with boundary
54 Paramcxx . . $ Param#`Param<Real>`(eecacbcad9281738).(const KNcxx . . $ KN#< Real >& maxp, const KNcxx . . $ KN#< Real >& minp);
55 // construct a continuous model space with initial values
56 explicit Paramcxx . . $ Param#`Param<Real>`(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& initmod);
57 // copy operator
58 Paramcxx . . $ Param#`Param<Real>`(2871d832bed366a6).(const Paramcxx . . $ Param#< Real >& p);
59 virtual ~cxx . . $ Param#`~Param<Real>`(49f6e7a06ebc5aa8).Param( );
60
61 Paramcxx . . $ Param#< Real >& operatorcxx . . $ Param#`operator=`(ddbb4b6f9bf2de56).=(const Paramcxx . . $ Param#< Real >&);
62
63 KNcxx . . $ KN#< Real >* modMaxcxx . . $ Param#modMax(9ebc7b71e268b54e).( ) const;
64 KNcxx . . $ KN#< Real >* modMincxx . . $ Param#modMin(9ebc7b71e268b54e).( ) const;
65 void setModMaxcxx . . $ Param#setModMax(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& v);
66 void setModMincxx . . $ Param#setModMin(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& v);
67
68 // cf. Stroustrup page 612-613 for operator <<
69 virtual ostreamcxx . . $ std/ostream#& totocxx . . $ Param#toto(be3b0a5ae87fb0b4).(ostreamcxx . . $ std/ostream#&) const;
70
71 private: // no copy
72 };
73
74 // Constructors
75 template< class Real >
76 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(49f6e7a06ebc5aa8).(void) : KNcxx . . $ KN#< Real >( ) {
77 // cerr << "Param default constructor" << endl;
78 maxParamcxx . . $ Param#maxParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
79 minParamcxx . . $ Param#minParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
80 }
81
82 template< class Real >
83 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(d4f767463ce0a6b3).(int n) : KNcxx . . $ KN#< Real >(n) {
84 // cerr << "Param constructor 0" << endl;
85 maxParamcxx . . $ Param#maxParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
86 minParamcxx . . $ Param#minParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
87 }
88
89 template< class Real >
90 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(40d6ce1614c156f7).(const KNcxx . . $ KN#< Real >& maxp, const KNcxx . . $ KN#< Real >& minp, const KNcxx . . $ KN#< Real >& initmod)
91 : KNcxx . . $ KN#< Real >(initmod) {
92 int ndim = initmod.sizecxx . . $ KN_#size(57a65ae535d7db84).( );
93
94 // cerr << "Param constructor 1" << endl;
95
96 maxParamcxx . . $ Param#maxParam. = new KNcxx . . $ KN#< Real >(ndim);
97 minParamcxx . . $ Param#minParam. = new KNcxx . . $ KN#< Real >(ndim);
98 maxParamcxx . . $ Param#maxParam.[0] = maxp;
99 minParamcxx . . $ Param#minParam.[0] = minp;
100 }
101
102 template< class Real >
103 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(eecacbcad9281738).(const KNcxx . . $ KN#< Real >& maxp, const KNcxx . . $ KN#< Real >& minp)
104 : KNcxx . . $ KN#< Real >(Mincxx . . $ `src/Algo/defs.hpp:72:9`!(minp.size( ), maxp.size( ))) {
105 int ndim = Mincxx . . $ `src/Algo/defs.hpp:72:9`!(minp.size( ), maxp.size( ));
106
107 // cerr << "Param constructor 2" << endl;
108
109 maxParamcxx . . $ Param#maxParam. = new KNcxx . . $ KN#< Real >(ndim);
110 minParamcxx . . $ Param#minParam. = new KNcxx . . $ KN#< Real >(ndim);
111 maxParamcxx . . $ Param#maxParam.[0] = maxp;
112 minParamcxx . . $ Param#minParam.[0] = minp;
113 }
114
115 template< class Real >
116 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& initmod) : KNcxx . . $ KN#< Real >(initmod) {
117 // cerr << "Param constructor 3" << endl;
118
119 maxParamcxx . . $ Param#maxParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
120 minParamcxx . . $ Param#minParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
121 }
122
123 // copy operator
124 template< class Real >
125 Paramcxx . . $ Param#< Real >::Paramcxx . . $ Param#`Param<Real>`(2871d832bed366a6).(const Param& p) : KNcxx . . $ KN#< Real >(p) {
126 // cerr << "Param copy operator" << endl;
127
128 if ((p.maxParamcxx . . $ Param#maxParam.) ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!)
129 maxParamcxx . . $ Param#maxParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
130 else {
131 maxParamcxx . . $ Param#maxParam. = new KNcxx . . $ KN#< Real >(ndimcxx . . $ Param#ndim.);
132 *maxParamcxx . . $ Param#maxParam. = *(p.maxParamcxx . . $ Param#maxParam.);
133 }
134
135 if ((p.minParamcxx . . $ Param#minParam.) ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!)
136 minParamcxx . . $ Param#minParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
137 else {
138 minParamcxx . . $ Param#minParam. = new KNcxx . . $ KN#< Real >(ndimcxx . . $ Param#ndim.);
139 *minParamcxx . . $ Param#minParam. = *(p.minParamcxx . . $ Param#minParam.);
140 }
141 }
142
143 template< class Real >
144 Paramcxx . . $ Param#< Real >& Paramcxx . . $ Param#< Real >::operatorcxx . . $ Param#`operator=`(ddbb4b6f9bf2de56).=(const Paramcxx . . $ Param#< Real >& p) {
145 // cerr << "Param = operator" << endl;
146 // modif FH 042005 for gcc4.0
147 KNcxx . . $ KN#< Real >& a1 = *this;
148 const KNcxx . . $ KN#< Real >& a2 = p;
149 a1 = a2; // KN copy operator
150
151 int ndim = p.sizecxx . . $ KN_#size(57a65ae535d7db84).( );
152
153 if ((p.maxParamcxx . . $ Param#maxParam.) ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!)
154 maxParamcxx . . $ Param#maxParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
155 else {
156 if (maxParamcxx . . $ Param#maxParam.) delete maxParamcxx . . $ Param#maxParam.;
157 maxParamcxx . . $ Param#maxParam. = new KNcxx . . $ KN#< Real >(ndim);
158 *maxParamcxx . . $ Param#maxParam. = *(p.maxParamcxx . . $ Param#maxParam.);
159 }
160
161 if ((p.minParamcxx . . $ Param#minParam.) ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!)
162 minParamcxx . . $ Param#minParam. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!;
163 else {
164 if (minParamcxx . . $ Param#minParam.) delete minParamcxx . . $ Param#minParam.;
165 minParamcxx . . $ Param#minParam. = new KNcxx . . $ KN#< Real >(ndim);
166 *minParamcxx . . $ Param#minParam. = *(p.minParamcxx . . $ Param#minParam.);
167 }
168
169 return (*this);
170 }
171
172 template< class Real >
173 Paramcxx . . $ Param#< Real >::~cxx . . $ Param#`~Param<Real>`(49f6e7a06ebc5aa8).Param( ) {
174 // cerr << "Param destructor" << endl;
175
176 if (maxParamcxx . . $ Param#maxParam. !=cxx . . $ std/`operator!=`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!) delete maxParamcxx . . $ Param#maxParam.;
177 if (minParamcxx . . $ Param#minParam. !=cxx . . $ std/`operator!=`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!) delete minParamcxx . . $ Param#minParam.;
178 }
179
180 template< class Real >
181 KNcxx . . $ KN#< Real >* Paramcxx . . $ Param#< Real >::modMaxcxx . . $ Param#modMax(9ebc7b71e268b54e).( ) const {
182 return maxParamcxx . . $ Param#maxParam.;
183 }
184
185 template< class Real >
186 KNcxx . . $ KN#< Real >* Paramcxx . . $ Param#< Real >::modMincxx . . $ Param#modMin(9ebc7b71e268b54e).( ) const {
187 return minParamcxx . . $ Param#minParam.;
188 }
189
190 template< class Real >
191 void Paramcxx . . $ Param#< Real >::setModMaxcxx . . $ Param#setModMax(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& v) {
192 if (maxParamcxx . . $ Param#maxParam. !=cxx . . $ std/`operator!=`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!) delete maxParamcxx . . $ Param#maxParam.;
193 maxParamcxx . . $ Param#maxParam. = new KNcxx . . $ KN#< Real >(v);
194 }
195
196 template< class Real >
197 void Paramcxx . . $ Param#< Real >::setModMincxx . . $ Param#setModMin(13bb219bb9d16f6).(const KNcxx . . $ KN#< Real >& v) {
198 if (minParamcxx . . $ Param#minParam. !=cxx . . $ std/`operator!=`(bf4c77cd91c4b201). NULLcxx . . $ `<external>/16391990256953433862/stddef.h:416:9`!) delete minParamcxx . . $ Param#minParam.;
199 minParamcxx . . $ Param#minParam. = new KNcxx . . $ KN#< Real >(v);
200 }
201
202 template< class Real >
203 ostreamcxx . . $ std/ostream#& Paramcxx . . $ Param#< Real >::totocxx . . $ Param#toto(be3b0a5ae87fb0b4).(ostreamcxx . . $ std/ostream#& os) const {
204 for (long i = 0; i <cxx . . $ std/`operator<`(c2ad8cf295ccec45). (*this).sizecxx . . $ KN_#size(57a65ae535d7db84).( ); i++) os <<cxx . . $ `operator<<`(9ced1f356fedeebb). (*this)[i] <<cxx . . $ `operator<<`(9ced1f356fedeebb). " ";
205 os <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
206
207 return os;
208 }
209
210 template< class Real >
211 ostreamcxx . . $ std/ostream#& operatorcxx . . $ `operator<<`(2587130c0179f881).<<(ostreamcxx . . $ std/ostream#& os, const Paramcxx . . $ Param#< Real >& d) {
212 return d.totocxx . . $ Param#toto(be3b0a5ae87fb0b4).(os);
213 }
214
215 #endif