matrice.h

00001 /*
00002  *  Definition of Lorene class Matrice
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 1999-2001 Philippe Grandclement
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License as published by
00013  *   the Free Software Foundation; either version 2 of the License, or
00014  *   (at your option) any later version.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 #ifndef __MATRICE_H_
00029 #define __MATRICE_H_
00030 
00031 /*
00032  * $Id: matrice.h,v 1.12 2005/10/24 09:22:21 p_grandclement Exp $
00033  * $Log: matrice.h,v $
00034  * Revision 1.12  2005/10/24 09:22:21  p_grandclement
00035  * addition of annule_hard for matrices
00036  *
00037  * Revision 1.11  2005/09/16 12:28:16  j_novak
00038  * New method del_deriv() and shorter version for set(i,j).
00039  *
00040  * Revision 1.10  2005/01/25 12:47:32  j_novak
00041  * Added some member arithmetic and operator=(Tbl).
00042  *
00043  * Revision 1.9  2004/12/29 12:27:35  j_novak
00044  * permute is now a Itbl* which array is sent directly to the LAPACK routines.
00045  * It is now possible to solve a general system (i.e. even if the Matrice
00046  * is not in a banded form).
00047  *
00048  * Revision 1.8  2004/08/24 09:14:40  p_grandclement
00049  * Addition of some new operators, like Poisson in 2d... It now requieres the
00050  * GSL library to work.
00051  *
00052  * Also, the way a variable change is stored by a Param_elliptic is changed and
00053  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00054  * will requiere some modification. (It should concern only the ones about monopoles)
00055  *
00056  * Revision 1.7  2004/03/22 13:12:42  j_novak
00057  * Modification of comments to use doxygen instead of doc++
00058  *
00059  * Revision 1.6  2002/09/24 10:49:41  e_gourgoulhon
00060  *
00061  * Modif commentaires.
00062  *
00063  * Revision 1.5  2002/09/24 08:34:12  e_gourgoulhon
00064  *
00065  * Added member function transpose()
00066  * and matrix multiplication
00067  *
00068  * Revision 1.4  2002/09/13 09:17:33  j_novak
00069  * Modif. commentaires
00070  *
00071  * Revision 1.3  2002/06/17 14:05:17  j_novak
00072  * friend functions are now also declared outside the class definition
00073  *
00074  * Revision 1.2  2002/01/03 13:18:40  j_novak
00075  * Optimization: the members set(i,j) and operator(i,j) of class Matrice are
00076  * now defined inline. Matrice is a friend class of Tbl.
00077  *
00078  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00079  * LORENE
00080  *
00081  * Revision 2.12  1999/11/30  17:45:28  phil
00082  * changement de prototypage
00083  *
00084  * Revision 2.11  1999/10/25  08:02:11  eric
00085  * Changements commentaires.
00086  *
00087  * Revision 2.10  1999/10/12  16:04:06  phil
00088  * Doc
00089  *
00090  * Revision 2.9  1999/10/12  15:59:09  phil
00091  * Documentation
00092  *
00093  * Revision 2.8  1999/10/12  09:42:07  phil
00094  * retour
00095  *
00096  * Revision 2.7  1999/10/12  09:39:38  phil
00097  * passage en const
00098  *
00099  * Revision 2.6  1999/10/11  09:35:40  phil
00100  * changement prototypage arithmetique
00101  *
00102  * Revision 2.5  1999/10/05  17:02:32  phil
00103  * ajout de determinant et val_propre
00104  *
00105  * Revision 2.4  1999/09/20  11:25:25  phil
00106  * passage en Doc++
00107  *
00108  * Revision 2.3  1999/09/20  11:18:53  phil
00109  * *** empty log message ***
00110  *
00111  * Revision 2.2  1999/04/13  13:56:11  phil
00112  * suppression de proto.h
00113  *
00114  * Revision 2.1  1999/04/07  14:53:38  phil
00115  * Changement de prototypage
00116  *
00117  * Revision 2.0  1999/04/07  14:03:59  phil
00118  * *** empty log message ***
00119  *
00120  *
00121  * $Header: /cvsroot/Lorene/C++/Include/matrice.h,v 1.12 2005/10/24 09:22:21 p_grandclement Exp $
00122  *
00123  */
00124 
00125 //fichiers includes
00126 #include <stdio.h>
00127 
00128 #include "type_parite.h"
00129 #include "tbl.h"
00130 #include "itbl.h"
00131 
00145 class Matrice {
00146     //Elements
00147     private:
00148     
00149     int etat ; 
00150     
00151     Tbl* std ; 
00152     
00153     
00154     mutable int ku ;    
00155     mutable int kl ;    
00156     
00163     mutable Tbl* band ;
00164     
00165     
00166     mutable Tbl* lu ;   
00167     mutable Itbl* permute ; 
00168     
00169     // Constructeurs destructeurs
00170     public:
00177     Matrice (int size1, int size2 ) ;
00178     
00179     Matrice (const Matrice& ) ; 
00180     
00189     Matrice (const Tbl& tab) ;
00190 
00191     ~Matrice() ; 
00192     
00193         //Gestion memoire
00199     private:
00200     void del_t() ;
00201     void del_deriv() ; 
00202 
00203     // manipulation des etats
00204     public:
00206     int get_etat() const { return etat ; }; 
00207 
00213     void set_etat_qcq()  ;
00214 
00220     void set_etat_zero() ;
00221 
00226      void set_etat_nondef() ;
00227      
00232      void annule_hard() ;
00233 
00234 
00235     public:
00241     int get_dim(int i) const ;
00242     
00244     Tbl get_array() const {return *std; } ; 
00245     
00246     // affectation
00247     public: 
00252     void operator=(double x) ;
00253 
00254     void operator=(const Matrice& ) ; 
00255     void operator=(const Tbl& ) ; 
00256  
00257     //Impression
00258     friend ostream& operator<<(ostream& , const Matrice& ) ; 
00259         
00260     // extraction d'un element :
00261     public:
00270     double& set(int j, int i) {
00271       assert (etat == ETATQCQ) ;
00272       assert ((i>=0) && (i<std->dim.dim[0])) ;
00273       assert( (j>=0) && (j<std->dim.dim[1]) ) ;
00274       if ( (band != 0x0) || (lu != 0x0) ) del_deriv() ;
00275       return std->t[std->dim.dim[0] * j + i] ;
00276     } ;
00277     
00283     double operator()(int j , int i) const {
00284       assert(etat != ETATNONDEF) ;
00285       assert( (i>=0) && (i<std->dim.dim[0]) ) ;
00286       assert( (j>=0) && (j<std->dim.dim[1]) ) ;
00287       if (etat == ETATZERO) {
00288         double zero = 0. ;
00289         return zero ; 
00290       }
00291       else return std->t[std->dim.dim[0] * j + i] ;
00292     };
00293     
00294     // Passage matrice a bande
00302     void set_band (int up, int low) const ;
00303     
00304     // Decomposition LU
00309     void set_lu () const ;
00310         
00311     // Inversion de la matrice
00318     Tbl inverse (const Tbl& sec_membre) const ;
00319 
00320     // Les valeurs propres :
00327     Tbl val_propre() const ;    
00332     Matrice vect_propre() const ;
00333     
00338     double determinant() const ;
00339 
00343     Matrice transpose() const ;
00344     
00345 
00346     // Member arithmetics
00347     // ------------------
00348     public:
00350     void operator+=(const Matrice &) ; 
00351     void operator+=(double) ; 
00352 
00353     void operator-=(const Matrice &) ;  
00354     void operator-=(double) ; 
00355     void operator*=(double) ; 
00356     void operator/=(double) ; 
00357 
00358     // Operateurs amis
00359     friend Matrice operator+ (const Matrice&, const Matrice& ) ;
00360     friend Matrice operator- (const Matrice&, const Matrice& ) ;
00361     friend Matrice operator* (const Matrice&, double ) ;
00362     friend Matrice operator* (double, const Matrice& ) ;
00363     friend Matrice operator* (const Matrice&, const Matrice& ) ;
00364     friend Matrice operator/ (const Matrice&,  double ) ;
00365 } ;
00366 ostream& operator<<(ostream& , const Matrice& ) ; 
00367 
00373 Matrice operator+ (const Matrice&, const Matrice& ) ; 
00374 Matrice operator- (const Matrice&, const Matrice& ) ; 
00375 Matrice operator* (const Matrice&, double ) ;
00376 Matrice operator* (double, const Matrice& ) ;
00377 Matrice operator* (const Matrice&, const Matrice& ) ; 
00378 Matrice operator/ (const Matrice&,  double ) ; 
00379 
00382 #endif  

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