prepa_ptens_rr.C

00001 /*
00002  *  Methods preparing the operators of Ope_pois_tens_rr for inversion.
00003  *
00004  *    (see file ope_elementary.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2004 Jerome Novak
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License version 2
00015  *   as published by the Free Software Foundation.
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 char prepa_ptens_rr_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/prepa_ptens_rr.C,v 1.1 2004/12/23 16:30:15 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: prepa_ptens_rr.C,v 1.1 2004/12/23 16:30:15 j_novak Exp $
00032  * $Log: prepa_ptens_rr.C,v $
00033  * Revision 1.1  2004/12/23 16:30:15  j_novak
00034  * New files and class for the solution of the rr component of the tensor Poisson
00035  * equation.
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/prepa_ptens_rr.C,v 1.1 2004/12/23 16:30:15 j_novak Exp $
00039  *
00040  */
00041 
00042 //fichiers includes
00043 #include <stdlib.h>
00044 
00045 #include "matrice.h"
00046 #include "type_parite.h"
00047 
00048 /*
00049  * Fonctions supprimant le nombre de colonnes (les premieres)
00050   et de lignes (les dernieres) a l'operateur renvoye par laplacien_mat, de facon
00051   a ce qu'il ne soit plus degenere. Ceci doit etre fait apres les combinaisons
00052   lineaires. La mise a bandes et la decomposition LU sont egalement effectuees ici
00053   
00054   
00055   Entree : lap :  resultat de laplacien_mat
00056         l : associe a lap
00057         puis : puissance dans la ZEC
00058         base_r : base de developpement
00059         
00060   Sortie : renvoie un operateur non degenere ....
00061  */
00062  
00063 Matrice _nondeg_ptens_rr_pas_prevu(const Matrice &, int , double, int) ;
00064 Matrice _nondeg_ptens_rr_cheb (const Matrice&, int, double, int) ;
00065 Matrice _nondeg_ptens_rr_chebp (const Matrice&, int, double, int) ;
00066 Matrice _nondeg_ptens_rr_chebi (const Matrice&, int, double, int) ;
00067 Matrice _nondeg_ptens_rr_chebu (const Matrice&, int, double, int) ; 
00068 
00069 
00070         //------------------------------------
00071         // Routine pour les cas non prevus --
00072         //-----------------------------------
00073 
00074 Matrice _nondeg_ptens_rr_pas_prevu(const Matrice &lap, int l, double echelle, int puis) {
00075     cout << "Construction non degeneree pas prevue..." << endl ;
00076     cout << "l : " << l << endl ;
00077     cout << "lap : " << lap << endl ;
00078     cout << "echelle : " << echelle << endl ;
00079     cout << " puis : " << puis << endl ;
00080     abort() ;
00081     exit(-1) ;
00082     Matrice res(1, 1) ;
00083     return res;
00084 }
00085 
00086 
00087 
00088             //-------------------
00089            //--  R_CHEB   -------
00090           //--------------------
00091 
00092 Matrice _nondeg_ptens_rr_cheb (const Matrice &lap, int l, double echelle, int) {
00093     
00094     
00095     int n = lap.get_dim(0) ;
00096     
00097    const int nmax = 200 ; // Nombre de Matrices stockees
00098    static Matrice* tab[nmax] ;  // les matrices calculees
00099    static int nb_dejafait = 0 ; // nbre de matrices calculees
00100    static int l_dejafait[nmax] ;
00101    static int nr_dejafait[nmax] ;
00102    static double vieux_echelle = 0;
00103    
00104    // Si on a change l'echelle : on detruit tout :
00105    if (vieux_echelle != echelle) {
00106        for (int i=0 ; i<nb_dejafait ; i++) {
00107        l_dejafait[i] = -1 ;
00108        nr_dejafait[i] = -1 ;
00109        delete tab[i] ;   
00110        }
00111     vieux_echelle = echelle ;
00112      nb_dejafait = 0 ;
00113    }
00114       
00115    int indice = -1 ;
00116    
00117    // On determine si la matrice a deja ete calculee :
00118    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00119     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00120     indice = conte ;
00121     
00122    // Calcul a faire : 
00123    if (indice  == -1) {
00124        if (nb_dejafait >= nmax) {
00125        cout << "_nondeg_ptens_rr_cheb : trop de matrices" << endl ;
00126        abort() ;
00127        exit (-1) ;
00128        }
00129        
00130         
00131     l_dejafait[nb_dejafait] = l ;
00132     nr_dejafait[nb_dejafait] = n ;
00133     
00134     
00135     //assert (l<n) ;
00136     
00137     Matrice res(n-2, n-2) ;
00138     res.set_etat_qcq() ;
00139     for (int i=0 ; i<n-2 ; i++)
00140     for (int j=0 ; j<n-2 ; j++)
00141         res.set(i, j) = lap(i, j+2) ;
00142     
00143     res.set_band(2, 2) ;
00144     res.set_lu() ;
00145     tab[nb_dejafait] = new Matrice(res) ;
00146     nb_dejafait ++ ;
00147     return res ;
00148     } 
00149     
00150     // Cas ou le calcul a deja ete effectue :
00151     else
00152     return *tab[indice] ;  
00153 }
00154 
00155 
00156 
00157 
00158             //------------------
00159            //--  R_CHEBP   ----
00160           //------------------
00161           
00162 Matrice _nondeg_ptens_rr_chebp (const Matrice &lap, int l, double, int) {
00163     
00164     int n = lap.get_dim(0) ;
00165     
00166        
00167    const int nmax = 200 ; // Nombre de Matrices stockees
00168    static Matrice* tab[nmax] ;  // les matrices calculees
00169    static int nb_dejafait = 0 ; // nbre de matrices calculees
00170    static int l_dejafait[nmax] ;
00171    static int nr_dejafait[nmax] ;
00172     
00173    int indice = -1 ;
00174    
00175    // On determine si la matrice a deja ete calculee :
00176    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00177     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00178     indice = conte ;
00179     
00180    // Calcul a faire : 
00181    if (indice  == -1) {
00182        if (nb_dejafait >= nmax) {
00183        cout << "_nondeg_ptens_rr_chebp : trop de matrices" << endl ;
00184        abort() ;
00185        exit (-1) ;
00186        }
00187        
00188         
00189     l_dejafait[nb_dejafait] = l ;
00190     nr_dejafait[nb_dejafait] = n ;
00191     
00192     assert (l%2 == 0) ;
00193     
00194     if (l==2) {
00195     Matrice res(n-1, n-1) ;
00196     res.set_etat_qcq() ;
00197     for (int i=0 ; i<n-1 ; i++)
00198         for (int j=0 ; j<n-1 ; j++)
00199         res.set(i, j) = lap(i, j+1) ;
00200     res.set_band(3, 0) ;
00201     res.set_lu() ;
00202     tab[nb_dejafait] = new Matrice(res) ;
00203     nb_dejafait ++ ;
00204     return res ;
00205     }
00206     else {
00207     Matrice res(n-2, n-2) ;
00208     res.set_etat_qcq() ;
00209     for (int i=0 ;i<n-2 ; i++)
00210         for (int j=0 ; j<n-2 ; j++)
00211         res.set(i, j) = lap(i, j+2) ;
00212     
00213     res.set_band(2, 1) ;    
00214     res.set_lu() ;
00215     tab[nb_dejafait] = new Matrice(res) ;
00216     nb_dejafait ++ ;
00217     return res ;
00218      }
00219     }
00220     // Cas ou le calcul a deja ete effectue :
00221     else
00222     return *tab[indice] ;
00223 }
00224 
00225 
00226 
00227 
00228             //-------------------
00229            //--  R_CHEBI   -----
00230           //-------------------
00231           
00232 Matrice _nondeg_ptens_rr_chebi (const Matrice &lap, int l, double, int) {
00233     
00234     int n = lap.get_dim(0) ;
00235        
00236    const int nmax = 200 ; // Nombre de Matrices stockees
00237    static Matrice* tab[nmax] ;  // les matrices calculees
00238    static int nb_dejafait = 0 ; // nbre de matrices calculees
00239    static int l_dejafait[nmax] ;
00240    static int nr_dejafait[nmax] ;
00241     
00242    int indice = -1 ;
00243    
00244    // On determine si la matrice a deja ete calculee :
00245    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00246     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00247     indice = conte ;
00248     
00249    // Calcul a faire : 
00250    if (indice  == -1) {
00251        if (nb_dejafait >= nmax) {
00252        cout << "_nondeg_ptens_rr_chebi : trop de matrices" << endl ;
00253        abort() ;
00254        exit (-1) ;
00255        }
00256        
00257         
00258     l_dejafait[nb_dejafait] = l ;
00259     nr_dejafait[nb_dejafait] = n ;
00260     
00261     
00262     assert (l%2 == 1) ;
00263   //  assert (l<=2*n-1) ;
00264     
00265     Matrice res(n-2, n-2) ;
00266     res.set_etat_qcq() ;
00267     for (int i=0 ;i<n-2 ; i++)
00268     for (int j=0 ; j<n-2 ; j++)
00269         res.set(i, j) = lap(i, j+2) ;
00270     
00271     res.set_band(2, 1) ;
00272     res.set_lu() ;
00273     tab[nb_dejafait] = new Matrice(res) ;
00274     nb_dejafait ++ ;
00275     return res ;
00276    } 
00277     // Cas ou le calcul a deja ete effectue :
00278     else
00279     return *tab[indice] ;
00280 }
00281 
00282 
00283 
00284 
00285             //-------------------
00286            //--  R_CHEBU   -----
00287           //-------------------
00288           
00289           
00290 Matrice _nondeg_ptens_rr_chebu (const Matrice &lap, int l, double, int puis) {
00291 
00292   if (puis != 4) {
00293     cout << "_ope_ptens_rr_mat_r_chebu : only the case dzpuis = 4 "
00294      << '\n' << "is implemented! \n"
00295      << "dzpuis = " << puis << endl ;
00296     abort() ;
00297   }
00298   int n = lap.get_dim(0) ;
00299     
00300   const int nmax = 200; // Nombre de Matrices stockees
00301   static Matrice* tab[nmax] ;  // les matrices calculees
00302   static int nb_dejafait = 0 ; // nbre de matrices calculees
00303   static int l_dejafait[nmax] ;
00304   static int nr_dejafait[nmax] ;
00305     
00306   int indice = -1 ;
00307    
00308   // On determine si la matrice a deja ete calculee :
00309   for (int conte=0 ; conte<nb_dejafait ; conte ++)
00310     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00311       indice = conte ;
00312     
00313   // Calcul a faire : 
00314   if (indice  == -1) {
00315     if (nb_dejafait >= nmax) {
00316       cout << "_nondeg_ptens_rr_chebu : trop de matrices" << endl ;
00317       abort() ;
00318       exit (-1) ;
00319     }
00320        
00321     l_dejafait[nb_dejafait] = l ;
00322     nr_dejafait[nb_dejafait] = n ;
00323     
00324     Matrice res(n-3, n-3) ;
00325     res.set_etat_qcq() ;
00326     for (int i=0 ;i<n-3 ; i++)
00327       for (int j=0 ; j<n-3 ; j++)
00328     res.set(i, j) = lap(i, j+3) ;
00329     
00330     res.set_band(2, 1) ;
00331     res.set_lu() ;
00332     tab[nb_dejafait] = new Matrice(res) ;
00333     nb_dejafait ++ ;
00334     return res ;
00335     
00336   }
00337   // Cas ou le calcul a deja ete effectue :
00338   else
00339     return *tab[indice] ;
00340 }
00341 
00342 
00343             //-------------------
00344            //--  Fonction   ----
00345           //-------------------
00346           
00347 
00348 Matrice nondeg_ptens_rr(const Matrice &lap, int l, double echelle, int puis, int base_r)
00349 {
00350 
00351         // Routines de derivation
00352     static Matrice (*nondeg_ptens_rr[MAX_BASE])(const Matrice&, int, double, int) ;
00353     static int nap = 0 ;
00354 
00355         // Premier appel
00356     if (nap==0) {
00357     nap = 1 ;
00358     for (int i=0 ; i<MAX_BASE ; i++) {
00359         nondeg_ptens_rr[i] = _nondeg_ptens_rr_pas_prevu ;
00360     }
00361         // Les routines existantes
00362     nondeg_ptens_rr[R_CHEB >> TRA_R] = _nondeg_ptens_rr_cheb ;
00363     nondeg_ptens_rr[R_CHEBU >> TRA_R] = _nondeg_ptens_rr_chebu ;
00364     nondeg_ptens_rr[R_CHEBP >> TRA_R] = _nondeg_ptens_rr_chebp ;
00365     nondeg_ptens_rr[R_CHEBI >> TRA_R] = _nondeg_ptens_rr_chebi ;
00366     }
00367     assert (l>=2) ;
00368     Matrice res(nondeg_ptens_rr[base_r](lap, l, echelle, puis)) ;
00369     return res ;
00370 }
00371 

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