Debian Codegraph @

C++/Include/valeur.h

raw symbols SCIP
1 /*
2 * Definition of Lorene class Valeur
3 *
4 */
5
6 /*
7 * Copyright (c) 1999-2000 Jean-Alain Marck
8 * Copyright (c) 1999-2003 Eric Gourgoulhon
9 * Copyright (c) 1999-2001 Philippe Grandclement
10 * Copyright (c) 1999-2001 Jerome Novak
11 * Copyright (c) 2001 Keisuke Taniguchi
12 *
13 * This file is part of LORENE.
14 *
15 * LORENE is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * LORENE is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with LORENE; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31
32 #ifndef __VALEUR_H_
33 #define __VALEUR_H_
34
35 /*
36 * $Id: valeur.h,v 1.20 2014/10/13 08:52:37 j_novak Exp $
37 * $Log: valeur.h,v $
38 * Revision 1.20 2014/10/13 08:52:37 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.19 2014/10/06 15:09:40 j_novak
42 * Modified #include directives to use c++ syntax.
43 *
44 * Revision 1.18 2013/06/05 15:06:10 j_novak
45 * Legendre bases are treated as standard bases, when the multi-grid
46 * (Mg3d) is built with BASE_LEG.
47 *
48 * Revision 1.17 2013/01/11 15:44:54 j_novak
49 * Addition of Legendre bases (part 2).
50 *
51 * Revision 1.16 2012/01/18 14:43:42 j_penner
52 * added a routine to return the computational coordinate xi as a Valeur
53 *
54 * Revision 1.15 2012/01/17 10:17:23 j_penner
55 * functions added: Heaviside
56 *
57 * Revision 1.14 2005/11/17 15:18:46 e_gourgoulhon
58 * Added Valeur + Mtbl and Valeur - Mtbl.
59 *
60 * Revision 1.13 2005/10/25 08:56:34 p_grandclement
61 * addition of std_spectral_base in the case of odd functions near the origin
62 *
63 * Revision 1.12 2004/11/23 12:46:04 f_limousin
64 * Add functiun filtre_tp(int nn, int nz1, int nz2).
65 *
66 * Revision 1.11 2004/08/24 09:14:40 p_grandclement
67 * Addition of some new operators, like Poisson in 2d... It now requieres the
68 * GSL library to work.
69 *
70 * Also, the way a variable change is stored by a Param_elliptic is changed and
71 * no longer uses Change_var but rather 2 Scalars. The codes using that feature
72 * will requiere some modification. (It should concern only the ones about monopoles)
73 *
74 * Revision 1.10 2004/07/06 13:36:27 j_novak
75 * Added methods for desaliased product (operator |) only in r direction.
76 *
77 * Revision 1.9 2004/03/22 13:12:44 j_novak
78 * Modification of comments to use doxygen instead of doc++
79 *
80 * Revision 1.8 2003/11/06 14:43:37 e_gourgoulhon
81 * Gave a name to const arguments in certain method prototypes (e.g.
82 * constructors) to correct a bug of DOC++.
83 *
84 * Revision 1.7 2003/10/19 19:48:31 e_gourgoulhon
85 * Introduced new method display_coef.
86 *
87 * Revision 1.6 2003/10/13 20:48:52 e_gourgoulhon
88 * Added new method get_base() (to prepare the encapsulation of the member
89 * base).
90 *
91 * Revision 1.5 2003/09/23 08:52:53 e_gourgoulhon
92 * Added Scalar as a friend class.
93 *
94 * Revision 1.4 2002/10/16 14:36:30 j_novak
95 * Reorganization of #include instructions of standard C++, in order to
96 * use experimental version 3 of gcc.
97 *
98 * Revision 1.3 2002/09/13 09:17:33 j_novak
99 * Modif. commentaires
100 *
101 * Revision 1.2 2002/06/17 14:05:17 j_novak
102 * friend functions are now also declared outside the class definition
103 *
104 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
105 * LORENE
106 *
107 * Revision 2.51 2001/05/29 16:11:58 eric
108 * Modif commentaires (mise en conformite Doc++ 3.4.7).
109 *
110 * Revision 2.50 2001/05/26 14:49:37 eric
111 * Ajout de l'operator% : produit de deux Valeur avec desaliasage.
112 *
113 * Revision 2.49 2001/01/16 15:09:13 keisuke
114 * Change the argument of the function smooth.
115 *
116 * Revision 2.48 2001/01/16 14:54:01 keisuke
117 * Ajout de la fonction smooth.
118 *
119 * Revision 2.47 2000/11/10 13:31:53 eric
120 * Ajout de la fonction equipot_outward.
121 *
122 * Revision 2.46 2000/09/11 13:52:39 eric
123 * Ajout des methodes mult_cp() et mult_sp() ainsi que des membres associes
124 * p_mult_cp et p_mult_sp
125 *
126 * Revision 2.45 2000/09/08 11:43:26 eric
127 * Modif commentaires.
128 *
129 * Revision 2.44 2000/09/08 10:07:02 eric
130 * Ajout des methodes set_base_r, etc...
131 *
132 * Revision 2.43 2000/08/04 11:53:59 eric
133 * Ajout de l'operateur (int l) et de la fonction set(int l) pour l'acces
134 * individuel aux Tbl.
135 *
136 * Revision 2.42 1999/12/29 13:19:51 eric
137 * Modif commentaires.
138 *
139 * Revision 2.41 1999/12/29 13:11:08 eric
140 * Ajout de la fonction val_point_jk.
141 *
142 * Revision 2.40 1999/12/20 16:35:47 eric
143 * Ajout de la fonction set_base.
144 *
145 * Revision 2.39 1999/12/10 16:19:40 eric
146 * Modif commentaires.
147 *
148 * Revision 2.38 1999/12/10 16:11:13 eric
149 * Fonction set: suppression de l'appel a set_etat_c_qcq() pour
150 * augmenter l'efficacite.
151 *
152 * Revision 2.37 1999/12/07 14:52:43 eric
153 * Changement ordre des arguments (phi,theta,xi) --> (xi,theta,phi)
154 * dans la routine val_point.
155 *
156 * Revision 2.36 1999/12/06 16:46:46 eric
157 * Ajout de la fonction val_point.
158 *
159 * Revision 2.35 1999/11/30 12:41:21 eric
160 * Le membre base est desormais un objet de type Base_val et non plus
161 * un pointeur vers une Base_val.
162 *
163 * Revision 2.34 1999/11/29 10:25:32 eric
164 * Ajout de Valeur/Mtbl et Mtbl / Valeur dans l'arithmetique.
165 *
166 * Revision 2.33 1999/11/29 10:05:47 eric
167 * Ajout de Valeur*Mtbl dans l'arithmetique.
168 *
169 * Revision 2.32 1999/11/23 16:15:24 eric
170 * Suppression du membre statique Valeur_Zero.
171 * Suppression du constructeur par defaut.
172 *
173 * Revision 2.31 1999/11/23 14:30:47 novak
174 * Ajout des membres mult_ct et mult_st
175 *
176 * Revision 2.30 1999/11/22 15:40:48 eric
177 * Ajout des operateurs set(l,k,j,i) et (l,k,j,i).
178 * Ajout de la fonction annule(int l).
179 *
180 * Revision 2.29 1999/11/19 11:21:48 eric
181 * Ajout du membre p_stdsdp et de la fonction correspondante stdsdp().
182 *
183 * Revision 2.28 1999/11/19 09:28:38 eric
184 * Les valeurs de retour des operateurs differentiels sont desormais
185 * const Valeur &
186 * et non plus Valeur.
187 * Le laplacien angulaire (lapang) a desormais le meme statut que les
188 * autres operateurs differentiels.
189 *
190 * Revision 2.27 1999/11/16 13:09:48 novak
191 * Ajout de mult_x et scost
192 *
193 * Revision 2.26 1999/11/09 15:24:08 phil
194 * ajout de la fonction mathematique calculant la racine cubique
195 *
196 * Revision 2.25 1999/10/29 15:14:33 eric
197 * Ajout de fonctions mathematiques (abs, norme, etc...).
198 *
199 * Revision 2.24 1999/10/27 08:48:46 eric
200 * La classe Cmp est desormais amie (pour que Cmp::del_t() puisse appeler
201 * Valeur::del_t()).
202 *
203 * Revision 2.23 1999/10/21 14:21:06 eric
204 * Constructeur par lecture de fichier.
205 *
206 * Revision 2.22 1999/10/20 15:38:52 eric
207 * *** empty log message ***
208 *
209 * Revision 2.21 1999/10/20 15:31:04 eric
210 * Ajout de l'arithmetique.
211 *
212 * Revision 2.20 1999/10/19 15:30:24 eric
213 * Ajout de la fonction affiche_seuil.
214 *
215 * Revision 2.19 1999/10/18 15:07:02 eric
216 * La fonction membre annule() est rebaptisee annule_hard().
217 * Introduction de la fonction membre annule(int, int).
218 *
219 * Revision 2.18 1999/10/18 13:39:38 eric
220 * Routines de derivation --> const
221 * Suppression de sxdsdx (non implemente).
222 *
223 * Revision 2.17 1999/10/13 15:49:57 eric
224 * Depoussierage.
225 * Documentation.
226 *
227 * Revision 2.16 1999/09/14 17:17:47 phil
228 * *** empty log message ***
229 *
230 * Revision 2.15 1999/09/14 17:15:38 phil
231 * ajout de Valeur operator* (double, const Valeur&)
232 *
233 * Revision 2.14 1999/09/13 14:53:26 phil
234 * *** empty log message ***
235 *
236 * Revision 2.13 1999/09/13 14:17:52 phil
237 * ajout de Valeur friend operator+ (Valeur, Valeur)
238 *
239 * Revision 2.12 1999/04/26 16:24:23 phil
240 * ajout de mult2_xm1_zec()
241 *
242 * Revision 2.11 1999/04/26 16:12:45 phil
243 * ajout de mult_xm1_zec()
244 *
245 * Revision 2.10 1999/04/26 15:48:11 phil
246 * ajout de sxm1_zec()
247 *
248 * Revision 2.9 1999/04/26 12:57:24 phil
249 * ajout de lapang()
250 *
251 * Revision 2.8 1999/04/13 16:44:55 phil
252 * ajout de ylm_i()
253 *
254 * Revision 2.7 1999/04/13 16:31:46 phil
255 * *** empty log message ***
256 *
257 * Revision 2.6 1999/04/13 16:26:08 phil
258 * ajout ylm
259 *
260 * Revision 2.5 1999/02/24 15:24:34 hyc
261 * *** empty log message ***
262 *
263 * Revision 2.4 1999/02/23 15:55:46 hyc
264 * *** empty log message ***
265 *
266 *
267 * $Header: /cvsroot/Lorene/C++/Include/valeur.h,v 1.20 2014/10/13 08:52:37 j_novak Exp $
268 *
269 */
270
271 // Fichier includes
272 #include <cstdio>
273
274 #include "mtbl.h"
275 #include "mtbl_cf.h"
276
277 namespace Lorene {
278 class Coord ;
279 class Itbl ;
280
281 /**
282 * Values and coefficients of a (real-value) function.
283 * \ingroup (spec)
284 *
285 */
286
287 class Valeur {
288
289 // Data :
290 // -----
291 private:
292 const Mg3d* mg ; ///< Multi-grid \c Mgd3 on which \c this is defined
293
294 /// Logical state (\c ETATNONDEF , \c ETATQCQ or \c ETATZERO ).
295 int etat ;
296
297 public:
298 /// Values of the function at the points of the multi-grid
299 mutable Mtbl* c ;
300
301 /// Coefficients of the spectral expansion of the function
302 mutable Mtbl_cf* c_cf ;
303
304 /// Bases on which the spectral expansion is performed
305 Base_val base ;
306
307 // Derived data :
308 // ------------
309 private:
310 mutable Valeur* p_dsdx ; ///< Pointer on \f$\partial / \partial \xi\f$
311 mutable Valeur* p_d2sdx2 ; ///< Pointer on \f$\partial^2 / \partial \xi^2\f$
312 mutable Valeur* p_sx ; ///< Pointer on \f$1 / \xi\f$
313 mutable Valeur* p_sx2 ; ///< Pointer on \f$1 / \xi^2\f$
314 mutable Valeur* p_mult_x ; ///< Pointer on \f$\xi \, Id\f$
315
316 mutable Valeur* p_dsdt ; ///< Pointer on \f$\partial / \partial \theta\f$
317 mutable Valeur* p_d2sdt2 ; ///< Pointer on \f$\partial^2 / \partial \theta^2\f$
318 mutable Valeur* p_ssint ; ///< Pointer on \f$1 / \sin(\theta)\f$
319 mutable Valeur* p_scost ; ///< Pointer on \f$1 / \cos(\theta)\f$
320 mutable Valeur* p_mult_ct ; ///< Pointer on \f$\cos(\theta) \, Id\f$
321 mutable Valeur* p_mult_st ; ///< Pointer on \f$\sin(\theta) \, Id\f$
322
323 mutable Valeur* p_dsdp ; ///< Pointer on \f$\partial / \partial \phi\f$
324 mutable Valeur* p_stdsdp ; ///< Pointer on \f$1/\sin\theta \partial / \partial \phi\f$
325 mutable Valeur* p_d2sdp2 ; ///< Pointer on \f$\partial^2 / \partial \phi^2\f$
326 mutable Valeur* p_mult_cp ; ///< Pointer on \f$\cos(\phi) \, Id\f$
327 mutable Valeur* p_mult_sp ; ///< Pointer on \f$\sin(\phi) \, Id\f$
328
329 mutable Valeur* p_lapang ; ///< Pointer on the angular Laplacian
330
331 // Constructors - Destructor
332 // -------------------------
333
334 public:
335 explicit Valeur(const Mg3d& mgrid) ; ///< Constructor
336 explicit Valeur(const Mg3d* p_mgrid) ; ///< Constructor
337
338 /// Constructor from a file (see \c sauve(FILE*) )
339 Valeur(const Mg3d&, FILE* ) ;
340
341 Valeur(const Valeur& ) ; ///< Copy constructor
342 ~Valeur() ; ///< Destructor
343
344 // Assignement
345 // -----------
346 public:
347 void operator=(const Valeur& a) ; ///< Assignement to another \c Valeur
348 void operator=(const Mtbl& mt) ; ///< Assignement to a \c Mtbl
349 void operator=(const Mtbl_cf& mtcf) ; ///< Assignement to a \c Mtbl_cf
350 void operator=(double ) ; ///< Assignement to a \c double
351
352 // Access to individual elements
353 // -----------------------------
354 public:
355 /** Read/write of the value in a given domain (configuration space).
356 * NB: to gain in efficiency, the method \c del_deriv() (to delete
357 * the derived members) is not called by this function. It must
358 * thus be invoqued by the user.
359 *
360 * @param l [input] domain index
361 * @return Tbl containing the value of the field in domain \c l .
362 */
363 Tbl& set(int l) {
364 assert(l < mg->get_nzone()) ;
365 assert(etat == ETATQCQ) ;
366 if (c == 0x0) {
367 coef_i() ;
368 }
369 if (c_cf != 0x0) {
370 delete c_cf ;
371 c_cf = 0 ;
372 }
373 return c->set(l) ;
374 };
375
376
377 /** Read-only of the value in a given domain (configuration space).
378 * @param l [input] domain index
379 * @return Tbl containing the value of the field in domain \c l .
380 */
381 const Tbl& operator()(int l) const {
382 assert(l < mg->get_nzone()) ;
383 assert(etat == ETATQCQ) ;
384 if (c == 0x0) {
385 coef_i() ;
386 }
387 return (*c)(l) ;
388 };
389
390
391 /** Read/write of a particular element (configuration space).
392 * NB: to gain in efficiency, the method \c del_deriv() (to delete
393 * the derived members) is not called by this function. It must
394 * thus be invoqued by the user.
395 *
396 * @param l [input] domain index
397 * @param k [input] \f$\phi\f$ index
398 * @param j [input] \f$\theta\f$ index
399 * @param i [input] \e r (\f$\xi\f$) index
400 */
401 double& set(int l, int k, int j, int i) {
402 assert(l < mg->get_nzone()) ;
403 assert(etat == ETATQCQ) ;
404 if (c == 0x0) {
405 coef_i() ;
406 }
407 if (c_cf != 0x0) {
408 delete c_cf ;
409 c_cf = 0 ;
410 }
411 return c->set(l, k, j, i) ;
412 };
413
414
415 /** Read-only of a particular element (configuration space).
416 * @param l [input] domain index
417 * @param k [input] \f$\phi\f$ index
418 * @param j [input] \f$\theta\f$ index
419 * @param i [input] \e r (\f$\xi\f$) index
420 */
421 double operator()(int l, int k, int j, int i) const {
422 assert(etat != ETATNONDEF) ;
423 assert(l < mg->get_nzone()) ;
424 if (etat == ETATZERO) {
425 double zero = 0. ;
426 return zero ;
427 }
428 else{
429 if (c == 0x0) {
430 coef_i() ;
431 }
432 return (*c)(l, k, j, i) ;
433 }
434 };
435
436 /** Computes the value of the field represented by \c *this at an
437 * arbitrary point, by means of the spectral expansion.
438 * @param l [input] index of the domain
439 * @param x [input] value of the coordinate \f$\xi\f$
440 * @param theta [input] value of the coordinate \f$\theta'\f$
441 * @param phi [input] value of the coordinate \f$\phi'\f$
442 * @return value at the point \f$(\xi, \theta', \phi')\f$ in
443 * the domain no. \e l of the field represented by \c *this .
444 */
445 double val_point(int l, double x, double theta, double phi) const ;
446
447 /** Computes the value of the field represented by \c *this at an
448 * arbitrary point in \f$\xi\f$, but collocation point in
449 * \f$(\theta', \phi')\f$, by means of the spectral expansion.
450 * @param l [input] index of the domain
451 * @param x [input] value of the coordinate \f$\xi\f$
452 * @param j [input] index of the collocation point in \f$\theta'\f$
453 * @param k [input] index of the collocation point in \f$\phi'\f$
454 * @return value at the point
455 * \f$(\xi, {\theta'}_j, {\phi'}_k)\f$ in
456 * the domain no. \e l of the field represented by \c *this .
457 */
458 double val_point_jk(int l, double x, int j, int k) const ;
459
460
461 // Operations on coefficients
462 // --------------------------
463 public:
464 void coef() const ; ///< Computes the coeffcients of \c *this
465 void coef_i() const ; ///< Computes the physical value of \c *this
466 void ylm() ; ///< Computes the coefficients \f$Y_l^m\f$ of \c *this
467 void ylm_i() ; ///< Inverse of \c ylm()
468
469 /**
470 * Set the basis to the eigenvalues of
471 * \f$ \partial^2_theta - \cos\theta/\sin\theta \partial_\theta\f$.
472 **/
473 void val_propre_1d() ;
474 /**
475 * Inverse transformation of \c val_propre_1d.
476 **/
477 void val_propre_1d_i() ;
478
479 /// Return the bases for spectral expansions (member \c base )
480 const Base_val& get_base() const {return base; } ;
481
482 /// Sets the bases for spectral expansions (member \c base )
483 void set_base(const Base_val& ) ;
484
485 /** Sets the bases for spectral expansions (member \c base )
486 * to the standard ones for a scalar
487 */
488 void std_base_scal() ;
489
490 /** Sets the bases for spectral expansions (member \c base )
491 * to the standard odd ones for a scalar
492 */
493 void std_base_scal_odd() ;
494
495 /** Sets the expansion basis for \e r (\f$\xi\f$) functions in a
496 * given domain.
497 *
498 * @param l Domain index
499 * @param base_r type of basis functions in \e r (\f$\xi\f$)
500 * (e.g. \c R_CHEBP , etc...,
501 * see documentation of class \c Base_val
502 * for denomination of the various bases).
503 */
504 void set_base_r(int l, int base_r) ;
505
506 /** Sets the expansion basis for \f$\theta\f$ functions in all
507 * domains.
508 *
509 * @param base_t type of basis functions in \f$\theta\f$
510 * (e.g. \c T_COS_P , etc...,
511 * see documentation of class \c Base_val
512 * for denomination of the various bases).
513 */
514 void set_base_t(int base_t) ;
515
516 /** Sets the expansion basis for \f$\phi\f$ functions in all
517 * domains.
518 *
519 * @param base_p type of basis functions in \f$\phi\f$
520 * (e.g. \c P_COSSIN , etc...,
521 * see documentation of class \c Base_val
522 * for denomination of the various bases).
523 */
524 void set_base_p(int base_p) ;
525
526 /**
527 * Sets the \c n lasts coefficients in \f$\theta\f$ to 0 in the
528 * domain \c nz1 to \c nz2 when expressed in spherical harmonics.
529 */
530 void filtre_tp(int nn, int nz1, int nz2) ;
531
532
533
534 // Differential operators
535 // ----------------------
536 public:
537 /// Returns \f$\partial / \partial \xi\f$ of \c *this
538 const Valeur& dsdx() const ;
539 /// Returns \f$\partial^2 / \partial \xi^2\f$ of \c *this
540 const Valeur& d2sdx2() const ;
541
542 /// Returns \f$\partial / \partial \theta\f$ of \c *this
543 const Valeur& dsdt() const ;
544 /// Returns \f$\partial^2 / \partial \theta^2\f$ of \c *this
545 const Valeur& d2sdt2() const ;
546 /// Returns \f$1 / \sin(\theta)\f$ of \c *this
547 const Valeur& ssint() const ;
548 /// Returns \f$1 / \cos(\theta)\f$ of \c *this
549 const Valeur& scost() const ;
550 /// Returns \f$\cos(\theta) \, Id\f$ applied to \c *this
551 const Valeur& mult_ct() const ;
552 /// Returns \f$\sin(\theta) \, Id\f$ applied to \c *this
553 const Valeur& mult_st() const ;
554
555 /// Returns \f$\partial / \partial \phi\f$ of \c *this
556 const Valeur& dsdp() const ;
557 /// Returns \f$1/\sin(\theta) \, \partial / \partial \phi\f$ of \c *this
558 const Valeur& stdsdp() const ;
559 /// Returns \f$\partial^2 / \partial \phi^2\f$ of \c *this
560 const Valeur& d2sdp2() const ;
561 /// Returns \f$\cos(\phi) \, Id\f$ applied to \c *this
562 const Valeur& mult_cp() const ;
563 /// Returns \f$\sin(\phi) \, Id\f$ applied to \c *this
564 const Valeur& mult_sp() const ;
565
566 /// Returns the angular Laplacian of \c *this
567 const Valeur& lapang() const ;
568
569 /** Returns \f${1 \over \xi}\f$ (\e r -sampling = \c RARE ) \\
570 * Id (\e r sampling = \c FIN ) \\
571 * \f${1 \over \xi-1}\f$ (\e r -sampling = \c UNSURR )
572 */
573 const Valeur& sx() const ;
574
575 /** Returns \f${1 \over \xi^2}\f$ (\e r -sampling = \c RARE ) \\
576 * Id (\e r sampling = \c FIN ) \\
577 * \f${1 \over (\xi-1)^2}\f$ (\e r -sampling = \c UNSURR )
578 */
579 const Valeur& sx2() const ;
580
581 /** Returns \f$\xi \, Id\f$ (\e r -sampling = \c RARE ) \\
582 * Id (\e r sampling = \c FIN ) \\
583 * \f$(\xi-1) \, Id \f$ (\e r -sampling = \c UNSURR )
584 */
585 const Valeur& mult_x() const ;
586
587 /** Applies the following operator to \c *this : \\
588 * Id (\e r sampling = \c RARE, FIN ) \\
589 * \f${1 \over (\xi-1)}\f$ (\e r -sampling = \c UNSURR )
590 */
591 void sxm1_zec() ;
592
593 /** Applies the following operator to \c *this : \\
594 * Id (\e r sampling = \c RARE, FIN ) \\
595 * \f$(\xi-1) \, Id\f$ (\e r -sampling = \c UNSURR )
596 */
597 void mult_xm1_zec() ;
598
599 /** Applies the following operator to \c *this : \\
600 * Id (\e r sampling = \c RARE, FIN ) \\
601 * \f$(\xi-1)^2 \, Id\f$ (\e r -sampling = \c UNSURR )
602 */
603 void mult2_xm1_zec() ;
604
605 /** Returns \f${\xi}\f$ (\e r -sampling = \c RARE ) \\
606 * (\e r sampling = \c FIN ) \\
607 * \f${1 \over \xi-1}\f$ (\e r -sampling = \c UNSURR )
608 */
609 void va_x() ;
610
611
612 // Outputs
613 // -------
614 public:
615 void sauve(FILE *) const ; ///< Save in a file
616
617 /** Displays the spectral coefficients and the associated
618 * basis functions. This function shows only the values greater than a
619 * given threshold.
620 * @param threshold [input] Value above which a coefficient is printed
621 * (default: 1.e-7)
622 * @param precision [input] Number of printed digits (default: 4)
623 * @param ostr [input] Output stream used for the printing (default: cout)
624 */
625 void display_coef(double threshold = 1.e-7, int precision = 4,
626 ostream& ostr = cout) const ;
627
628 /** Prints only the values greater than a given threshold.
629 * @param ostr [input] Output stream used for the printing
630 * @param type [input] Type of display : 0 = prints only the
631 * coefficients, 1 = prints only the values in configuration
632 * space, 2 = prints both
633 * @param precision [input] Number of printed digits (default: 4)
634 * @param threshold [input] Value above which an array element is printed
635 * (default: 1.e-7)
636 */
637 void affiche_seuil(ostream& ostr, int type = 0, int precision = 4,
638 double threshold = 1.e-7) const ;
639
640 /// Display
641 friend ostream& operator<<(ostream& , const Valeur& ) ;
642
643 // Memory management
644 // -----------------
645 private:
646 void nouveau() ; ///< Memory allocation
647 void del_t() ; ///< Logical destructor
648 void del_deriv() ; ///< Logical destructor of the derivatives
649 void set_der_0x0() ; ///< Sets the pointers for derivatives to 0x0
650
651 // State manipulations
652 public:
653
654 /**
655 * Sets the logical state to \c ETATNONDEF (undefined).
656 * Deallocates the memory occupied by the \c Mtbl \c c and
657 * the \c Mtbl_cf \c c_cf , as well as by all the derivatives.
658 */
659 void set_etat_nondef() ;
660
661 /**
662 * Sets the logical state to \c ETATZERO (zero).
663 * Deallocates the memory occupied by the \c Mtbl \c c and
664 * the \c Mtbl_cf \c c_cf , as well as by all the derivatives.
665 */
666 void set_etat_zero() ;
667
668 /**
669 * Sets the logical state to \c ETATQCQ (ordinary state) for
670 * values in the configuration space (\c Mtbl \c c ).
671 * If \c c is not 0x0, this
672 * function does nothing on \c c . Otherwise, it performs the memory
673 * allocation for \c c .
674 * In all cases, this function deallocates the memory occupied by the
675 * \c Mtbl_cf \c c_cf , as well as by all the derivatives.
676 *
677 */
678 void set_etat_c_qcq() ;
679
680 /**
681 * Sets the logical state to \c ETATQCQ (ordinary state) for
682 * values in the configuration space (\c Mtbl_cf \c c_cf ).
683 * If \c c_cf is not 0x0, this
684 * function does nothing on \c c_cf . Otherwise, it performs the memory
685 * allocation for \c c_cf .
686 * In all cases, this function deallocates the memory occupied by the
687 * \c Mtbl \c c , as well as by all the derivatives.
688 *
689 */
690 void set_etat_cf_qcq() ;
691
692 /**
693 * Sets the \c Valeur to zero in a hard way.
694 * 1/ Sets the logical state to \c ETATQCQ , i.e. to an ordinary state.
695 * 2/ Allocates the memory for \c c and \c c_cf , and fills it
696 * with zeros. NB: this function must be used for debugging purposes only.
697 * For other operations, the functions \c set_etat_zero()
698 * or \c annule(int,int) must be perferred.
699 */
700 void annule_hard() ;
701
702 /**
703 * Sets the \c Valeur to zero in a given domain.
704 * @param l [input] Index of the domain in which the \c Valeur
705 * will be set (logically) to zero.
706 */
707 void annule(int l) ;
708
709 /**
710 * Sets the \c Valeur to zero in several domains.
711 * @param l_min [input] The \c Valeur will be set (logically) to zero
712 * in the domains whose indices are in the range
713 * \c [l_min,l_max] .
714 * @param l_max [input] see the comments for \c l_min .
715 *
716 * Note that \c annule(0,mg->get_nzone()-1) is equivalent to
717 * \c set_etat_zero() .
718 */
719 void annule(int l_min, int l_max) ;
720
721
722 // Extraction of information
723 // -------------------------
724 public:
725 /// Returns the logical state
726 int get_etat() const {return etat ; };
727
728 /// Returns the \c Mg3d on which the \c this is defined
729 const Mg3d* get_mg() const { return mg ; };
730
731 // Member arithmetics
732 // ------------------
733 public:
734 void operator+=(const Valeur& ) ; ///< += Valeur
735 void operator-=(const Valeur& ) ; ///< -= Valeur
736 void operator*=(const Valeur& ) ; ///< *= Valeur
737
738 // Miscellaneous
739 // -------------
740 public:
741 /** Determines an equipotential surface of the field represented
742 * by \c *this (inward search).
743 * The equipotential is supposed to have the form \\
744 * \f$l=L(\theta', \phi') \qquad (1) \f$ \\
745 * \f$\xi = X(\theta', \phi') \qquad (2)\f$ \\
746 * where \e l is the domain index and \f$\xi\f$ the radial variable in
747 * each domain.
748 * @param uu0 [input] Value defining the equipotential by
749 * \e u = const = \c uu0 where \e u is
750 * the field represented by \c *this .
751 * @param nz_search [input] Number of domains where the equipotential is
752 * searched : the routine scans inward
753 * the \c nz_search
754 * innermost domains, starting from the domain
755 * of index \c nz_search-1
756 * @param precis [input] Required absolute precision in the
757 * determination of zeros by the secant
758 * method (standard value: 1.e-14).
759 * @param nitermax [input] Maximum number of iterations in the secant
760 * method (standard value: 100).
761 * @param niter [output] Number of iterations effectively used
762 * in the secant method
763 * @param l_iso [output] 2-D \c Itbl containing the values
764 * of \e l on the equipotential surface at the collocation points
765 * in \f$(\theta', \phi')\f$ [Eq. (1)], with the following storage
766 * convention \\
767 * \c l_iso(k,j) = \f$L({\theta'}_j, {\phi'}_k)\f$
768 * @param xi_iso [output] 2-D \c Tbl containing the values
769 * of \f$\xi\f$ on the equipotential surface at the collocation points
770 * in \f$(\theta', \phi')\f$ [Eq. (2)], with the following storage
771 * convention \\
772 * \c xi_iso(k,j) = \f$X({\theta'}_j, {\phi'}_k)\f$
773 *
774 */
775 void equipot(double uu0, int nz_search, double precis, int nitermax,
776 int& niter, Itbl& l_iso, Tbl& xi_iso) const ;
777
778 /** Determines an equipotential surface of the field represented
779 * by \c *this (outward search).
780 * The equipotential is supposed to have the form \\
781 * \f$l=L(\theta', \phi') \qquad (1) \f$ \\
782 * \f$\xi = X(\theta', \phi') \qquad (2)\f$ \\
783 * where \e l is the domain index and \f$\xi\f$ the radial variable in
784 * each domain.
785 * @param uu0 [input] Value defining the equipotential by
786 * \e u = const = \c uu0 where \e u is
787 * the field represented by \c *this .
788 * @param nz_search [input] Number of domains where the equipotential is
789 * searched : the routine scans outward the
790 * \c nz_search innermost domains, starting
791 * from the domain of index 0
792 * @param precis [input] Required absolute precision in the
793 * determination of zeros by the secant
794 * method (standard value: 1.e-14).
795 * @param nitermax [input] Maximum number of iterations in the secant
796 * method (standard value: 100).
797 * @param niter [output] Number of iterations effectively used
798 * in the secant method
799 * @param l_iso [output] 2-D \c Itbl containing the values
800 * of \e l on the equipotential surface at the collocation points
801 * in \f$(\theta', \phi')\f$ [Eq. (1)], with the following storage
802 * convention \\
803 * \c l_iso(k,j) = \f$L({\theta'}_j, {\phi'}_k)\f$
804 * @param xi_iso [output] 2-D \c Tbl containing the values
805 * of \f$\xi\f$ on the equipotential surface at the collocation points
806 * in \f$(\theta', \phi')\f$ [Eq. (2)], with the following storage
807 * convention \\
808 * \c xi_iso(k,j) = \f$X({\theta'}_j, {\phi'}_k)\f$
809 *
810 */
811 void equipot_outward(double uu0, int nz_search, double precis,
812 int nitermax, int& niter, Itbl& l_iso,
813 Tbl& xi_iso) const ;
814
815 /** Changes the function \c *this as a smooth one
816 * when there exists a discontinuity
817 * between the nucleus and the first shell.
818 *
819 * @param nzet [input] Number of domains covering a star.
820 * @param uuva [output] Smoothed function.
821 *
822 */
823 void smooth(int nzet, Valeur& uuva) const ;
824
825 friend class Cmp ; ///< Friend class
826 friend class Scalar ; ///< Friend class
827 friend void rotate_propre_pair (Valeur&, bool) ; ///< Friend fonction.
828 friend void rotate_propre_impair (Valeur&, bool) ; ///< Friend fonction.
829 };
830 ostream& operator<<(ostream& , const Valeur& ) ;
831
832 /**
833 * \defgroup val_m Valeur Mathematics
834 * \ingroup (spec)
835 * @{
836 */
837 Valeur operator+(const Valeur& ) ; ///< + Valeur
838 Valeur operator-(const Valeur& ) ; ///< \c - Valeur
839 Valeur operator+(const Valeur&, const Valeur& ) ; ///< Valeur + Valeur
840 Valeur operator+(const Valeur&, const Mtbl& ) ; ///< Valeur + Mtbl
841 Valeur operator+(const Mtbl&, const Valeur& ) ; ///< Mtbl + Valeur
842 Valeur operator+(const Valeur&, double ) ; ///< Valeur + double
843 Valeur operator+(double, const Valeur& ) ; ///< double + Valeur
844 Valeur operator+(const Valeur&, int ) ; ///< Valeur + int
845 Valeur operator+(int, const Valeur& ) ; ///< int + Valeur
846 Valeur operator-(const Valeur&, const Valeur& ) ; ///< Valeur - Valeur
847 Valeur operator-(const Valeur&, const Mtbl& ) ; ///< Valeur - Mtbl
848 Valeur operator-(const Mtbl&, const Valeur& ) ; ///< Mtbl - Valeur
849 Valeur operator-(const Valeur&, double ) ; ///< Valeur - double
850 Valeur operator-(double, const Valeur& ) ; ///< double - Valeur
851 Valeur operator-(const Valeur&, int ) ; ///< Valeur - int
852 Valeur operator-(int, const Valeur& ) ; ///< int - Valeur
853 Valeur operator*(const Valeur&, const Valeur& ) ; ///< Valeur * Valeur
854
855 /// Valeur * Valeur with desaliasing
856 Valeur operator%(const Valeur&, const Valeur& ) ;
857
858 /// Valeur * Valeur with desaliasing only in \e r direction
859 Valeur operator|(const Valeur&, const Valeur& ) ;
860
861 Valeur operator*(const Valeur&, double ) ; ///< Valeur * double
862 Valeur operator*(double, const Valeur& ) ; ///< double * Valeur
863 Valeur operator*(const Valeur&, int ) ; ///< Valeur * int
864 Valeur operator*(int, const Valeur& ) ; ///< int * Valeur
865 Valeur operator*(const Valeur& a, const Mtbl& b) ; ///< Valeur * Mtbl
866 Valeur operator*(const Mtbl& b, const Valeur& a) ; ///< Mtbl * Valeur
867 Valeur operator*(const Valeur& a, const Coord& c) ; ///< Valeur * Coord
868 Valeur operator*(const Coord& c, const Valeur& a) ; ///< Coord * Valeur
869 Valeur operator/(const Valeur& a, const Valeur& b) ; ///< Valeur / Valeur
870 Valeur operator/(const Valeur&, double ) ; ///< Valeur / double
871 Valeur operator/(double, const Valeur& ) ; ///< double / Valeur
872 Valeur operator/(const Valeur&, int ) ; ///< Valeur / int
873 Valeur operator/(int, const Valeur& ) ; ///< int / Valeur
874 Valeur operator/(const Valeur& a, const Mtbl& b) ; ///< Valeur / Mtbl
875 Valeur operator/(const Mtbl& b, const Valeur& a) ; ///< Mtbl / Valeur
876
877 Valeur sin(const Valeur& ) ; ///< Sine
878 Valeur cos(const Valeur& ) ; ///< Cosine
879 Valeur tan(const Valeur& ) ; ///< Tangent
880 Valeur asin(const Valeur& ) ; ///< Arcsine
881 Valeur acos(const Valeur& ) ; ///< Arccosine
882 Valeur atan(const Valeur& ) ; ///< Arctangent
883 Valeur exp(const Valeur& ) ; ///< Exponential
884 Valeur Heaviside(const Valeur& ) ; ///< Heaviside function
885 Valeur log(const Valeur& ) ; ///< Neperian logarithm
886 Valeur log10(const Valeur& ) ; ///< Basis 10 logarithm
887 Valeur sqrt(const Valeur& ) ; ///< Square root
888 Valeur pow(const Valeur& , int ) ; ///< Power \f${\tt Valeur}^{\tt int}\f$
889 Valeur pow(const Valeur& , double ) ; ///< Power \f${\tt Valeur}^{\tt double}\f$
890 Valeur abs(const Valeur& ) ; ///< Absolute value
891 Valeur racine_cubique (const Valeur&) ; ///< Cube root
892
893 /**
894 * Maximum values of the \c Valeur in entire space.
895 * @return 1-D \c Tbl of size the number of domains, the elements of which
896 * are the set of the maximum values in each domain.
897 */
898 double totalmax(const Valeur& ) ;
899
900 /**
901 * Minimum values of the \c Valeur in entire space.
902 * @return 1-D \c Tbl of size the number of domains, the elements of which
903 * are the set of the minimum values in each domain.
904 */
905 double totalmin(const Valeur& ) ;
906
907 /**
908 * Maximum values of the \c Valeur (configuration space)
909 * in each domain.
910 * @return 1-D \c Tbl of size the number of domains, the elements of which
911 * are the set of the maximum values in each domain.
912 */
913 Tbl max(const Valeur& ) ;
914
915 /**
916 * Minimum values of the \c Valeur (configuration space)
917 * in each domain.
918 * @return 1-D \c Tbl of size the number of domains, the elements of which
919 * are the set of the minimum values in each domain.
920 */
921 Tbl min(const Valeur& ) ;
922
923 /**
924 * Sums of the absolute values of all the \c Valeur (configuration space)
925 * in each domain.
926 * @return 1-D \c Tbl of size the number of domains, the elements of which
927 * are the set of the sums of the absolute values in each domain.
928 */
929 Tbl norme(const Valeur& ) ;
930
931 /**
932 * Relative difference between two \c Valeur (configuration space)
933 * (norme version).
934 * @return 1-D \c Tbl of size the number of domains, the elements of which
935 * are \c norme[a(l)-b(l)]/norme[b(l)] if \c b(l)!=0 and
936 * \c norme[a(l)-b(l)] if \c b(l)=0 , where \c a(l) and
937 * \c b(l) denote symbolically the values of \c a and \c b
938 * in domain no. \c l .
939 */
940 Tbl diffrel(const Valeur& a, const Valeur& b) ;
941
942 /**
943 * Relative difference between two \c Valeur (configuration space)
944 * (max version).
945 * @return 1-D \c Tbl of size the number of domains, the elements of which
946 * are \c max[abs(a(l)-b(l))]/max[abs(b(l))] if \c b(l)!=0 and
947 * \c max[abs(a(l)-b(l))] if \c b(l)=0 , where \c a(l) and
948 * \c b(l) denote symbolically the values of \c a and \c b
949 * in domain no. \c l .
950 */
951 Tbl diffrelmax(const Valeur& a, const Valeur& b) ;
952
953
954 /** @} */
955
956 }
957 #endif