mtbl.h

00001 /*
00002  *  Definition of Lorene class Mtbl
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 1999-2000 Jean-Alain Marck
00008  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 #ifndef __MTBL_H_
00030 #define __MTBL_H_
00031 
00032 /*
00033  * $Id: mtbl.h,v 1.6 2012/01/17 10:22:13 j_penner Exp $
00034  * $Log: mtbl.h,v $
00035  * Revision 1.6  2012/01/17 10:22:13  j_penner
00036  * function added: Heaviside
00037  *
00038  * Revision 1.5  2004/03/22 13:12:42  j_novak
00039  * Modification of comments to use doxygen instead of doc++
00040  *
00041  * Revision 1.4  2003/11/06 14:43:37  e_gourgoulhon
00042  * Gave a name to const arguments in certain method prototypes (e.g.
00043  * constructors) to correct a bug of DOC++.
00044  *
00045  * Revision 1.3  2002/09/13 09:17:33  j_novak
00046  * Modif. commentaires
00047  *
00048  * Revision 1.2  2002/06/17 14:05:17  j_novak
00049  * friend functions are now also declared outside the class definition
00050  *
00051  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00052  * LORENE
00053  *
00054  * Revision 2.9  2000/08/16  10:29:45  eric
00055  * Suppression du membre dzpuis.
00056  *
00057  * Revision 2.8  2000/08/04  11:40:58  eric
00058  * Ajout de l'operateur (int l) et de la fonction set(int l) pour l'acces
00059  * individuel aux Tbl.
00060  *
00061  * Revision 2.7  1999/12/02  17:55:07  phil
00062  * *** empty log message ***
00063  *
00064  * Revision 2.6  1999/10/29  15:05:43  eric
00065  * Suppression des fonctions membres min() et max():
00066  * elles deviennent des fonctions externes.
00067  * Ajout de fonctions mathematiques (abs, norme, etc...).
00068  *
00069  * Revision 2.5  1999/10/18  15:06:25  eric
00070  * La fonction membre annule() est rebaptisee annule_hard().
00071  * Introduction de la fonction membre annule(int, int).
00072  *
00073  * Revision 2.4  1999/10/01  10:35:58  eric
00074  * Amelioration des commentaires.
00075  *
00076  * Revision 2.3  1999/10/01  10:08:25  eric
00077  * Depoussierage
00078  * Documentation.
00079  *
00080  * Revision 2.2  1999/03/02  18:54:50  eric
00081  * Ajout de la fonction affiche_seuil.
00082  *
00083  * Revision 2.1  1999/02/22  15:23:49  hyc
00084  * *** empty log message ***
00085  *
00086  *
00087  * Revision 2.0  1999/01/15  09:10:39  hyc
00088  * *** empty log message ***
00089  *
00090  *
00091  * $Header: /cvsroot/Lorene/C++/Include/mtbl.h,v 1.6 2012/01/17 10:22:13 j_penner Exp $
00092  *
00093  */
00094 
00095 
00096 // Headers Lorene 
00097 #include "tbl.h"
00098 #include "grilles.h"
00099 
00100 class Coord ;
00101 
00114 class Mtbl {
00115 
00116     // Data : 
00117     // -----
00118     private:
00120     const Mg3d* mg ;  
00122     int nzone ; 
00124     int etat ;  
00125 
00126     public:
00128     Tbl** t;    
00129 
00130     // Constructors - Destructor
00131     // -------------------------
00132     
00133     public:
00135     explicit Mtbl(const Mg3d& mgrid) ;  
00137     explicit Mtbl(const Mg3d* p_mgrid) ;    
00139     Mtbl(const Mg3d&, FILE* ) ;         
00141     Mtbl(const Coord& c) ;      
00143     Mtbl(const Mtbl& a) ;           
00145     ~Mtbl() ;               
00146 
00147     // Assignement
00148     // -----------
00149     public:
00151     void operator=(const Mtbl& ) ;      
00153     void operator=(double ) ;       
00155     void operator=(int ) ;          
00156 
00157     // Memory management
00158     // -----------------
00159     private:
00163     void del_t() ;  
00164             
00165     public:
00166 
00171     void set_etat_nondef() ;
00172     
00177     void set_etat_zero() ;          
00178 
00185     void set_etat_qcq() ;           
00186 
00195     void annule_hard() ;    
00196     
00207     void annule(int l_min, int l_max) ; 
00208 
00209 
00210     // Access to individual elements
00211     // -----------------------------
00212     public:
00217     Tbl& set(int l) {
00218         assert(l < nzone) ;
00219         assert(etat == ETATQCQ) ;
00220         return *(t[l]) ;
00221     };
00222     
00223     
00228     const Tbl& operator()(int l) const {
00229         assert(l < nzone) ;
00230         assert(etat == ETATQCQ) ;
00231         return *(t[l]) ;
00232     };
00233 
00241     double& set(int l, int k, int j, int i) {
00242         assert(l < nzone) ;
00243         assert(etat == ETATQCQ) ;
00244         return (t[l])->set(k, j, i) ;
00245     };
00246     
00247     
00255     double operator()(int l, int k, int j, int i) const {
00256         assert(etat != ETATNONDEF) ;
00257         assert(l < nzone) ;
00258         if (etat == ETATZERO) {
00259         double zero = 0. ;
00260         return zero ; 
00261         }
00262         else return (*t[l])(k, j, i) ;
00263     };
00264 
00265 
00266     // Extraction of information
00267     // -------------------------
00268     public:
00270     const Mg3d* get_mg() const { return mg ; }; 
00271 
00273     int get_etat() const { return etat ; };   
00274     
00276     int get_nzone() const { return nzone ; } ; 
00277     
00278     // Outputs
00279     // -------
00280     public:
00282     void sauve(FILE *) const ;      
00283     
00290     void affiche_seuil(ostream& ostr, int precision = 4, 
00291                double threshold = 1.e-7) const ;
00293     friend ostream& operator<<(ostream& , const Mtbl & ) ;   
00294 
00295     // Member arithmetics
00296     // ------------------
00297     public:
00299     void operator+=(const Mtbl & ) ;    
00301     void operator+=(double ) ;      
00303     void operator-=(const Mtbl & ) ;    
00305     void operator-=(double ) ;      
00307     void operator*=(const Mtbl & ) ;    
00309     void operator*=(double ) ;      
00311     void operator/=(const Mtbl & ) ;    
00313     void operator/=(double ) ;      
00314 
00315 } ;
00316 ostream& operator<<(ostream& , const Mtbl & ) ;   
00317 
00324 
00325 Mtbl operator+(const Mtbl& ) ;          
00327 Mtbl operator-(const Mtbl& ) ;          
00329 Mtbl operator+(const Mtbl&, const Mtbl& ) ; 
00331 Mtbl operator+(const Mtbl&, double ) ;      
00333 Mtbl operator+(double , const Mtbl& ) ;     
00335 Mtbl operator+(const Mtbl&, int ) ;     
00337 Mtbl operator+(int, const Mtbl& ) ;     
00339 Mtbl operator-(const Mtbl&, const Mtbl& ) ; 
00341 Mtbl operator-(const Mtbl&, double ) ;      
00343 Mtbl operator-(double, const Mtbl& ) ;      
00345 Mtbl operator-(const Mtbl&, int ) ;     
00347 Mtbl operator-(int, const Mtbl& ) ;     
00349 Mtbl operator*(const Mtbl&, const Mtbl& ) ; 
00351 Mtbl operator*(const Mtbl&, double ) ;      
00353 Mtbl operator*(double, const Mtbl& ) ;      
00355 Mtbl operator*(const Mtbl&, int ) ;     
00357 Mtbl operator*(int, const Mtbl& ) ;     
00359 Mtbl operator/(const Mtbl&, const Mtbl& ) ; 
00361 Mtbl operator/(const Mtbl&, double ) ;      
00363 Mtbl operator/(double, const Mtbl& ) ;      
00365 Mtbl operator/(const Mtbl&, int ) ;     
00367 Mtbl operator/(int, const Mtbl& ) ;     
00368 
00370 Mtbl sin(const Mtbl& ) ;        
00372 Mtbl cos(const Mtbl& ) ;        
00374 Mtbl tan(const Mtbl& ) ;        
00376 Mtbl asin(const Mtbl& ) ;       
00378 Mtbl acos(const Mtbl& ) ;       
00380 Mtbl atan(const Mtbl& ) ;       
00382 Mtbl exp(const Mtbl& ) ;        
00384 Mtbl Heaviside(const Mtbl& ) ;      
00386 Mtbl log(const Mtbl& ) ;        
00388 Mtbl log(const Mtbl& ) ;        
00390 Mtbl log10(const Mtbl& ) ;    
00392 Mtbl sqrt(const Mtbl& ) ;       
00394 Mtbl racine_cubique (const Mtbl&) ; 
00396 Mtbl pow(const Mtbl& , int ) ;  
00398 Mtbl pow(const Mtbl& , double ) ; 
00400 Mtbl abs(const Mtbl& ) ;        
00401 
00406 double totalmax(const Mtbl& ) ;   
00407 
00412 double totalmin(const Mtbl& ) ;   
00413 
00419 Tbl max(const Mtbl& ) ;   
00420 
00426 Tbl min(const Mtbl& ) ;   
00427 
00433 Tbl norme(const Mtbl& ) ;   
00434 
00443 Tbl diffrel(const Mtbl& a, const Mtbl& b) ; 
00444 
00453 Tbl diffrelmax(const Mtbl& a, const Mtbl& b) ; 
00454 
00458 #endif

Generated on Tue Feb 7 01:35:18 2012 for LORENE by  doxygen 1.4.6