comb_lin_cpt.C

00001 /*
00002  *   Copyright (c) 2000-2001 Philippe Grandclement
00003  *
00004  *   This file is part of LORENE.
00005  *
00006  *   LORENE is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   LORENE is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with LORENE; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 char comb_lin_cpt_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin_cpt.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: comb_lin_cpt.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $
00027  * $Log: comb_lin_cpt.C,v $
00028  * Revision 1.2  2002/10/16 14:37:11  j_novak
00029  * Reorganization of #include instructions of standard C++, in order to
00030  * use experimental version 3 of gcc.
00031  *
00032  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00033  * LORENE
00034  *
00035  * Revision 2.1  2000/11/22  19:29:50  eric
00036  * Changement de nom_C en comb_lin_cpt_C
00037  * Nettoyage des includes
00038  *
00039  * Revision 2.0  2000/03/16  16:25:18  phil
00040  * *** empty log message ***
00041  *
00042  *
00043  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin_cpt.C,v 1.2 2002/10/16 14:37:11 j_novak Exp $
00044  *
00045  */
00046 
00047 // Headers C
00048 #include <stdlib.h>
00049 
00050 // Headers Lorene
00051 #include "matrice.h"
00052 
00053 /*
00054  * Gestion des CL permettant de mettre a bande les operateurs associes a poisson 
00055  * compact. Version pour les sources et les matrices des operateurs.
00056  */
00057 
00058 
00059 // Version Matrice --> Matrice
00060 Matrice _cl_cpt_pas_prevu (const Matrice &source, int) {
00061     cout << "Combinaison lineaire pas prevu..." << endl ;
00062     cout << "Source : " << source << endl ;
00063     abort() ;
00064     return source;
00065 }
00066 
00067 
00068         //-------------------
00069            //--  R_CHEBP   -----
00070           //-------------------
00071 
00072 
00073 Matrice _cl_cpt_r_chebp (const Matrice &source, int) {
00074     
00075     int n = source.get_dim(0) ;
00076     assert (n == source.get_dim(1)) ;
00077 
00078     Matrice barre(source) ;
00079     int dirac = 1 ;
00080     for (int i=0 ; i<n-2 ; i++) {
00081     for (int j=0 ; j<n ; j++)
00082         barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))/(i+1) ;
00083     if (i==0) dirac = 0 ;
00084     }
00085 
00086     Matrice res(barre) ;
00087     for (int i=0 ; i<n-4 ; i++)
00088     for (int j=0 ; j<n ; j++)
00089         res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00090     
00091     res.set_band(4, 1) ;
00092     res.set_lu() ;
00093     return res ;
00094 }
00095 
00096         //-------------------
00097            //--  R_CHEBI   -----
00098           //-------------------
00099 
00100 
00101 Matrice _cl_cpt_r_chebi (const Matrice &source, int l) {
00102     int n = source.get_dim(0) ;
00103     assert (n == source.get_dim(1)) ;
00104    
00105     Matrice barre(source) ;
00106     for (int i=0 ; i<n-2 ; i++)
00107     for (int j=0 ; j<n ; j++)
00108         barre.set(i, j) = (source(i, j)-source(i+1, j))/(i+1) ;
00109     
00110     Matrice res(barre) ;
00111     for (int i=0 ; i<n-4 ; i++)
00112     for (int j=0 ; j<n ; j++)
00113         res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00114     
00115     if (l==1)
00116     res.set_band(3, 0) ;
00117     else
00118     res.set_band(3, 1) ;
00119     res.set_lu() ;
00120     return res ;
00121     
00122 }
00123         
00124 
00125         //-------------------------
00126            //- La routine a appeler ---
00127           //---------------------------
00128 
00129 Matrice combinaison_cpt (const Matrice &source, int l, int base_r) {
00130     
00131         // Routines de derivation
00132     static Matrice (*combinaison_cpt[MAX_BASE])
00133             (const Matrice &, int) ;
00134     static int nap = 0 ;
00135 
00136         // Premier appel
00137     if (nap==0) {
00138     nap = 1 ;
00139     for (int i=0 ; i<MAX_BASE ; i++) {
00140         combinaison_cpt[i] = _cl_cpt_pas_prevu ;
00141     }
00142         // Les routines existantes
00143     combinaison_cpt[R_CHEBP >> TRA_R] = _cl_cpt_r_chebp ;
00144     combinaison_cpt[R_CHEBI >> TRA_R] = _cl_cpt_r_chebi ;
00145     }
00146     
00147     Matrice res(combinaison_cpt[base_r](source, l)) ;
00148     return res ;
00149 }
00150 
00151         //--------------------------------------------------------------
00152         //          Version Tbl
00153         //--------------------------------------------------------------
00154 
00155 
00156 
00157 Tbl _cl_cpt_pas_prevu(const Tbl& tb) {
00158     cout << "combinaison_nul_pas_prevu " << endl ;
00159     cout << "tb : " << tb << endl ;
00160     abort() ;
00161     return tb ;
00162 }
00163 
00164     
00165         //-------------------
00166            //--  R_CHEBP   -----
00167           //-------------------
00168 Tbl _cl_cpt_r_chebp(const Tbl& tb) {
00169     
00170     assert (tb.get_etat() != ETATNONDEF) ;
00171     int n=tb.get_dim(0) ;
00172     
00173     Tbl barre(tb) ;
00174     int dirac = 1 ;
00175     for (int i=0 ; i<n-2 ; i++) {
00176     barre.set(i) = ((1+dirac)*tb(i)-tb(i+2))/(i+1) ;
00177     if (i==0) dirac = 0 ;
00178     }
00179 
00180     Tbl res(barre) ;
00181     for (int i=0 ; i<n-4 ; i++)
00182     res.set(i) = barre(i)-barre(i+2) ;
00183         
00184     return res ;
00185 }
00186 
00187 
00188     
00189         //-------------------
00190            //--  R_CHEBI   -----
00191           //-------------------
00192 Tbl _cl_cpt_r_chebi(const Tbl& tb) {
00193    
00194     assert (tb.get_etat() != ETATNONDEF) ;
00195     int n=tb.get_dim(0) ;
00196     
00197     Tbl barre(tb) ;
00198     for (int i=0 ; i<n-2 ; i++)
00199     barre.set(i) = (tb(i)-tb(i+1))/(i+1) ;
00200 
00201     Tbl res(barre) ;
00202     for (int i=0 ; i<n-4 ; i++)
00203     res.set(i) = barre(i)-barre(i+2) ;
00204         
00205     return res ;
00206 }  
00207 
00208 
00209         //----------------------------
00210            //- Routine a appeler        ---
00211           //------------------------------
00212 
00213 Tbl combinaison_cpt (const Tbl &source, int base_r) {
00214     
00215         // Routines de derivation
00216     static Tbl (*combinaison_cpt[MAX_BASE])(const Tbl&) ;
00217     static int nap = 0 ;
00218 
00219         // Premier appel
00220     if (nap==0) {
00221     nap = 1 ;
00222     for (int i=0 ; i<MAX_BASE ; i++) {
00223         combinaison_cpt[i] = _cl_cpt_pas_prevu ;
00224     }
00225         // Les routines existantes
00226     combinaison_cpt[R_CHEBP >> TRA_R] = _cl_cpt_r_chebp ;
00227     combinaison_cpt[R_CHEBI >> TRA_R] = _cl_cpt_r_chebi ;
00228     }
00229     
00230     Tbl res(combinaison_cpt[base_r](source)) ;
00231     return res ;
00232 }
00233 

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