TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Polynome.cpp
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Polynome.h>
17
18Implemente_instanciable(Polynome,"Polynome",Objet_U);
19
20
21
22/*! @brief Ecriture sur un flot de sortie Ecrit le tableau des coefficients
23 *
24 * @param (Sortie& os) le flot de sortie a utiliser
25 * @return (Sortie&) le flot de sortie modifie
26 */
28{
29 os << coeff_;
30 return os;
31}
32
33
34/*! @brief Lecture dans un flot d'entree Lecture du tableau des coefficients
35 *
36 * @param (Entree& is) le flot d'entree a utiliser
37 * @return (Entree& le flot d'entree modifie)
38 */
40{
41 is >> coeff_;
42 return is;
43}
44
45
46/*! @brief Calcul de la valeur du polynome au point x1
47 *
48 * @param (double x1) point
49 * @return (double) valeur du polynome
50 */
51double Polynome::operator()(double x1) const
52{
53 int n=coeff_.dimension(0);
54 int i=0;
55 double xi=1;
56 double sum=0;
57 while(n--)
58 {
59 sum+=coeff_(i++)*xi;
60 xi*=x1;
61 }
62 return sum;
63}
64
65/*! @brief Calcul de la valeur du polynome au point x1,x2
66 *
67 * @param (double x1) point
68 * @param (double x2) point
69 * @return (double) valeur du polynome
70 */
71double Polynome::operator()(double x1, double x2) const
72{
73 int n1=coeff_.dimension(0);
74 int n2=coeff_.dimension(1);
75 int i=0;
76 int j=0;
77 double xi=1;
78 double xj=1;
79 double sum=0;
80 while(n1--)
81 {
82 xj=1.;
83 n2=coeff_.dimension(1);
84 j=0;
85 while(n2--)
86 {
87 sum+=coeff_(i,j++)*xj*xi;
88 xj*=x2;
89 }
90 xi*=x1;
91 i++;
92 }
93 return sum;
94}
95
96/*! @brief Calcul de la valeur du polynome au point x1,x2,x3
97 *
98 * @param (double x1) point
99 * @param (double x2) point
100 * @param (double x3) point
101 * @return (double) valeur du polynome
102 */
103double Polynome::operator()(double x1, double x2, double x3) const
104{
105 int n1=coeff_.dimension(0);
106 int n2=coeff_.dimension(1);
107 int n3=coeff_.dimension(2);
108 int i=0;
109 int j=0;
110 int k=0;
111 double xi=1;
112 double xj=1;
113 double xk=1;
114 double sum=0;
115 while(n1--)
116 {
117 xj=1.;
118 n2=coeff_.dimension(1);
119 j=0;
120 while(n2--)
121 {
122 xk=1.;
123 n3=coeff_.dimension(2);
124 k=0;
125 while(n3--)
126 {
127 sum+=coeff_(i,j,k++)*xk*xj*xi;
128 xk*=x3;
129 }
130 xj*=x2;
131 j++;
132 }
133 xi*=x1;
134 i++;
135 }
136 return sum;
137}
138
139/*! @brief Calcul de la valeur du polynome au point x1,x2,x3,x4
140 *
141 * @param (double x1) point
142 * @param (double x2) point
143 * @param (double x3) point
144 * @param (double x4) point
145 * @return (double) valeur du polynome
146 */
147double Polynome::operator()(double x1, double x2, double x3, double x4) const
148{
149 int n1=coeff_.dimension(0);
150 int n2=coeff_.dimension(1);
151 int n3=coeff_.dimension(2);
152 int n4=coeff_.dimension(3);
153 int i=0;
154 int j=0;
155 int k=0;
156 int l=0;
157 double xi=1;
158 double xj=1;
159 double xk=1;
160 double xl=1;
161 double sum=0;
162 while(n1--)
163 {
164 xj=1.;
165 n2=coeff_.dimension(1);
166 j=0;
167 while(n2--)
168 {
169 xk=1.;
170 n3=coeff_.dimension(2);
171 k=0;
172 while(n3--)
173 {
174 xl=1.;
175 n4=coeff_.dimension(3);
176 l=0;
177 while(n4--)
178 {
179 sum+=coeff_(i,j,k,l++)*xl*xk*xj*xi;
180 xl*=x4;
181 }
182 xk*=x3;
183 k++;
184 }
185 xj*=x2;
186 j++;
187 }
188 xi*=x1;
189 i++;
190 }
191 return sum;
192}
193
194
195/*! @brief Non code.
196 *
197 * Ne fait rien
198 *
199 */
201{
202}
203
204/*! @brief Non code.
205 *
206 * Ne fait rien
207 *
208 */
210{
211}
212
213
214/*! @brief Non code.
215 *
216 * retourne 0.
217 *
218 */
219double Polynome::derive(double ) const
220{
221 return 0;
222}
223
224/*! @brief Non code.
225 *
226 * retourne 0.
227 *
228 */
229double Polynome::derive(double , double ) const
230{
231 return 0;
232}
233
234/*! @brief Non code.
235 *
236 * retourne 0.
237 *
238 */
239double Polynome::derive(double , double , double ) const
240{
241 return 0;
242}
243
244/*! @brief Non code.
245 *
246 * retourne 0.
247 *
248 */
249double Polynome::derive(double , double , double , double ) const
250{
251 return 0;
252}
253
254
255/*! @brief Non code.
256 *
257 * retourne 0.
258 *
259 */
260double Polynome::integre(double ) const
261{
262 return 0;
263}
264
265/*! @brief Non code.
266 *
267 * retourne 0.
268 *
269 */
270double Polynome::integre(double , double ) const
271{
272 return 0;
273}
274
275/*! @brief Non code.
276 *
277 * retourne 0.
278 *
279 */
280double Polynome::integre(double , double , double ) const
281{
282 return 0;
283}
284
285/*! @brief Non code.
286 *
287 * retourne 0.
288 *
289 */
290double Polynome::integre(double , double , double , double ) const
291{
292 return 0;
293}
294
295
296/*! @brief Non code.
297 *
298 * Ne fait rien. Retourne *this.
299 *
300 */
302{
303 return *this;
304}
305
306/*! @brief Non code.
307 *
308 * Ne fait rien. Retourne *this.
309 *
310 */
312{
313 return *this;
314}
315
316/*! @brief Non code.
317 *
318 * Ne fait rien. Retourne *this.
319 *
320 */
322{
323 return *this;
324}
325
326/*! @brief Non code.
327 *
328 * Ne fait rien. Retourne *this.
329 *
330 */
332{
333 return *this;
334}
335
336/*! @brief Non code.
337 *
338 * Ne fait rien. Retourne *this.
339 *
340 */
342{
343 return *this;
344}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Polynome a n variables, n <= 4 Implementation des coefficients a l'aide d'un DoubleTab.
Definition Polynome.h:26
void derive(int=0)
Non code.
Definition Polynome.cpp:200
Polynome(int n1)
Construction d'un polynome a une variable de degre n1.
Definition Polynome.h:78
Polynome & operator/=(double)
Non code.
Definition Polynome.cpp:341
Polynome & operator+=(const Polynome &)
Non code.
Definition Polynome.cpp:301
Polynome & operator*=(const Polynome &)
Non code.
Definition Polynome.cpp:321
double operator()(double x1) const
Calcul de la valeur du polynome au point x1.
Definition Polynome.cpp:51
void integre(int=0)
Non code.
Definition Polynome.cpp:209
Polynome & operator-=(const Polynome &)
Non code.
Definition Polynome.cpp:311
Classe de base des flux de sortie.
Definition Sortie.h:52