ope_poisson_2d_non_dege.C

00001 /*
00002  *   Copyright (c) 2004 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 version 2
00008  *   as published by the Free Software Foundation.
00009  *
00010  *   LORENE is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with LORENE; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 char ope_poisson_2d_non_dege_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_2d/ope_poisson_2d_non_dege.C,v 1.1 2004/08/24 09:14:47 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_poisson_2d_non_dege.C,v 1.1 2004/08/24 09:14:47 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_2d/ope_poisson_2d_non_dege.C,v 1.1 2004/08/24 09:14:47 p_grandclement Exp $
00026  *
00027  */
00028 #include <math.h>
00029 #include <stdlib.h>
00030 
00031 #include "proto.h"
00032 #include "ope_elementary.h"
00033 
00034 
00035         //------------------------------------
00036         // Routine pour les cas non prevus --
00037         //-----------------------------------
00038 
00039 Matrice _poisson_2d_non_dege_pas_prevu(const Matrice &lap, int, double, int) {
00040     cout << "Construction non degeneree pas prevue..." << endl ;
00041     abort() ;
00042     exit(-1) ;
00043     return lap ;
00044 }
00045 
00046 
00047 
00048             //-------------------
00049            //--  R_CHEB   -------
00050           //--------------------
00051 
00052 Matrice _poisson_2d_non_dege_r_cheb (const Matrice &lap, int l, double echelle, int) {
00053     
00054     
00055     int n = lap.get_dim(0) ;
00056     
00057    const int nmax = 200 ; // Nombre de Matrices stockees
00058    static Matrice* tab[nmax] ;  // les matrices calculees
00059    static int nb_dejafait = 0 ; // nbre de matrices calculees
00060    static int l_dejafait[nmax] ;
00061    static int nr_dejafait[nmax] ;
00062    static double vieux_echelle = 0;
00063    
00064    // Si on a change l'echelle : on detruit tout :
00065    if (vieux_echelle != echelle) {
00066        for (int i=0 ; i<nb_dejafait ; i++) {
00067        l_dejafait[i] = -1 ;
00068        nr_dejafait[i] = -1 ;
00069        delete tab[i] ;   
00070        }
00071     vieux_echelle = echelle ;
00072      nb_dejafait = 0 ;
00073    }
00074       
00075    int indice = -1 ;
00076    
00077    // On determine si la matrice a deja ete calculee :
00078    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00079     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00080     indice = conte ;
00081     
00082    // Calcul a faire : 
00083    if (indice  == -1) {
00084        if (nb_dejafait >= nmax) {
00085        cout << "_poisson_2d_non_dege_r_cheb : trop de matrices" << endl ;
00086        abort() ;
00087        exit (-1) ;
00088        }
00089        
00090         
00091     l_dejafait[nb_dejafait] = l ;
00092     nr_dejafait[nb_dejafait] = n ;
00093     
00094     
00095     //assert (l<n) ;
00096     
00097     Matrice res(n-2, n-2) ;
00098     res.set_etat_qcq() ;
00099     for (int i=0 ; i<n-2 ; i++)
00100     for (int j=0 ; j<n-2 ; j++)
00101         res.set(i, j) = lap(i, j+2) ;
00102     
00103     res.set_band(2, 2) ;
00104     res.set_lu() ;
00105     tab[nb_dejafait] = new Matrice(res) ;
00106     nb_dejafait ++ ;
00107     return res ;
00108     } 
00109     
00110     // Cas ou le calcul a deja ete effectue :
00111     else
00112     return *tab[indice] ;  
00113 }
00114 
00115 
00116 
00117 
00118             //------------------
00119            //--  R_CHEBP   ----
00120           //------------------
00121           
00122 Matrice _poisson_2d_non_dege_r_chebp (const Matrice &lap, int l, double, int) {
00123     
00124     int n = lap.get_dim(0) ;
00125     
00126        
00127    const int nmax = 200 ; // Nombre de Matrices stockees
00128    static Matrice* tab[nmax] ;  // les matrices calculees
00129    static int nb_dejafait = 0 ; // nbre de matrices calculees
00130    static int l_dejafait[nmax] ;
00131    static int nr_dejafait[nmax] ;
00132     
00133    int indice = -1 ;
00134    
00135    // On determine si la matrice a deja ete calculee :
00136    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00137     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00138     indice = conte ;
00139     
00140    // Calcul a faire : 
00141    if (indice  == -1) {
00142        if (nb_dejafait >= nmax) {
00143        cout << "_poisson_2d_non_dege_r_chebp : trop de matrices" << endl ;
00144        abort() ;
00145        exit (-1) ;
00146        }
00147        
00148         
00149     l_dejafait[nb_dejafait] = l ;
00150     nr_dejafait[nb_dejafait] = n ;
00151     
00152     assert (div(l, 2).rem == 0) ;
00153   //  assert (l<=2*n-2) ;
00154     
00155     if (l==0) {
00156     Matrice res(n-1, n-1) ;
00157     res.set_etat_qcq() ;
00158     for (int i=0 ; i<n-1 ; i++)
00159         for (int j=0 ; j<n-1 ; j++)
00160         res.set(i, j) = lap(i, j+1) ;
00161     res.set_band(3, 0) ;
00162     res.set_lu() ;
00163     tab[nb_dejafait] = new Matrice(res) ;
00164     nb_dejafait ++ ;
00165     return res ;
00166     }
00167     else {
00168     Matrice res(n-2, n-2) ;
00169     res.set_etat_qcq() ;
00170     for (int i=0 ;i<n-2 ; i++)
00171         for (int j=0 ; j<n-2 ; j++)
00172         res.set(i, j) = lap(i, j+2) ;
00173     
00174     res.set_band(2, 1) ;    
00175     res.set_lu() ;
00176     tab[nb_dejafait] = new Matrice(res) ;
00177     nb_dejafait ++ ;
00178     return res ;
00179      }
00180     }
00181     // Cas ou le calcul a deja ete effectue :
00182     else
00183     return *tab[indice] ;
00184 }
00185 
00186 
00187 
00188 
00189             //-------------------
00190            //--  R_CHEBI   -----
00191           //-------------------
00192           
00193 Matrice _poisson_2d_non_dege_r_chebi (const Matrice &lap, int l, double, int) {
00194     
00195     int n = lap.get_dim(0) ;
00196        
00197    const int nmax = 200 ; // Nombre de Matrices stockees
00198    static Matrice* tab[nmax] ;  // les matrices calculees
00199    static int nb_dejafait = 0 ; // nbre de matrices calculees
00200    static int l_dejafait[nmax] ;
00201    static int nr_dejafait[nmax] ;
00202     
00203    int indice = -1 ;
00204    
00205    // On determine si la matrice a deja ete calculee :
00206    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00207     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00208     indice = conte ;
00209     
00210    // Calcul a faire : 
00211    if (indice  == -1) {
00212        if (nb_dejafait >= nmax) {
00213        cout << "_poisson_2d_non_dege_r_chebi : trop de matrices" << endl ;
00214        abort() ;
00215        exit (-1) ;
00216        }
00217        
00218         
00219     l_dejafait[nb_dejafait] = l ;
00220     nr_dejafait[nb_dejafait] = n ;
00221     
00222     
00223     assert (div(l, 2).rem == 1) ;
00224   //  assert (l<=2*n-1) ;
00225     
00226     if (l==1) {
00227     Matrice res(n-1, n-1) ;
00228     res.set_etat_qcq() ;
00229     for (int i=0 ; i<n-1 ; i++)
00230         for (int j=0 ; j<n-1 ; j++)
00231         res.set(i, j) = lap(i, j+1) ;
00232     res.set_band(3, 0) ;
00233     res.set_lu() ;
00234     tab[nb_dejafait] = new Matrice(res) ;
00235     nb_dejafait ++ ;
00236     return res ;
00237     }
00238     else {
00239     Matrice res(n-2, n-2) ;
00240     res.set_etat_qcq() ;
00241     for (int i=0 ;i<n-2 ; i++)
00242         for (int j=0 ; j<n-2 ; j++)
00243         res.set(i, j) = lap(i, j+2) ;
00244     
00245     res.set_band(2, 1) ;
00246     res.set_lu() ;
00247     tab[nb_dejafait] = new Matrice(res) ;
00248     nb_dejafait ++ ;
00249     return res ;
00250     } 
00251     }
00252     // Cas ou le calcul a deja ete effectue :
00253     else
00254     return *tab[indice] ;
00255 }
00256 
00257 
00258 
00259 
00260             //-------------------
00261            //--  R_CHEBU   -----
00262           //-------------------
00263 Matrice _poisson_2d_non_dege_r_chebu_quatre (const Matrice&, int) ;  
00264 Matrice _poisson_2d_non_dege_r_chebu_trois (const Matrice&, int) ;  
00265 Matrice _poisson_2d_non_dege_r_chebu_deux (const Matrice&, int) ;    
00266           
00267 Matrice _poisson_2d_non_dege_r_chebu (const Matrice &lap, int l, double, int puis) {
00268 
00269     switch (puis) {
00270     case 4 :
00271         return _poisson_2d_non_dege_r_chebu_quatre (lap, l) ;
00272     case 3 :
00273         return _poisson_2d_non_dege_r_chebu_trois (lap, l) ;
00274     case 2 :
00275         return _poisson_2d_non_dege_r_chebu_deux (lap, l) ;
00276     default :
00277         abort() ;
00278         exit(-1) ;
00279         return Matrice(0, 0) ;
00280     }
00281 }
00282 
00283 // Cas dzpuis = 4 ;
00284 Matrice _poisson_2d_non_dege_r_chebu_quatre (const Matrice &lap, int l) {
00285     
00286     int n = lap.get_dim(0) ;
00287     
00288    const int nmax = 200; // Nombre de Matrices stockees
00289    static Matrice* tab[nmax] ;  // les matrices calculees
00290    static int nb_dejafait = 0 ; // nbre de matrices calculees
00291    static int l_dejafait[nmax] ;
00292    static int nr_dejafait[nmax] ;
00293     
00294    int indice = -1 ;
00295    
00296    // On determine si la matrice a deja ete calculee :
00297    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00298     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00299     indice = conte ;
00300     
00301    // Calcul a faire : 
00302    if (indice  == -1) {
00303        if (nb_dejafait >= nmax) {
00304        cout << "_poisson_2d_non_dege_r_chebu : trop de matrices" << endl ;
00305        abort() ;
00306        exit (-1) ;
00307        }
00308        
00309         
00310     l_dejafait[nb_dejafait] = l ;
00311     nr_dejafait[nb_dejafait] = n ;
00312     
00313   //  assert (l<=n-2) ;
00314     
00315     if (l==0) {
00316     Matrice res(n-2, n-2) ;
00317     res.set_etat_qcq() ;
00318     for (int i=0 ; i<n-2 ; i++)
00319         for (int j=0 ; j<n-2 ; j++)
00320         res.set(i, j) = lap(i, j+2) ;
00321     res.set_band(3, 0) ;
00322     res.set_lu() ;
00323     tab[nb_dejafait] = new Matrice(res) ;
00324     nb_dejafait ++ ;
00325     return res ;
00326     }
00327     else {
00328     Matrice res(n-3, n-3) ;
00329     res.set_etat_qcq() ;
00330     for (int i=0 ;i<n-3 ; i++)
00331         for (int j=0 ; j<n-3 ; j++)
00332         res.set(i, j) = lap(i, j+3) ;
00333     
00334     res.set_band(2, 1) ;
00335     res.set_lu() ;
00336     tab[nb_dejafait] = new Matrice(res) ;
00337     nb_dejafait ++ ;
00338     return res ;
00339     } 
00340     }
00341     // Cas ou le calcul a deja ete effectue :
00342     else
00343     return *tab[indice] ;
00344 }
00345 // Cas dzpuis = 3 ;
00346 Matrice _poisson_2d_non_dege_r_chebu_trois (const Matrice &lap, int l) {
00347     
00348     int n = lap.get_dim(0) ;
00349     
00350    const int nmax = 200; // Nombre de Matrices stockees
00351    static Matrice* tab[nmax] ;  // les matrices calculees
00352    static int nb_dejafait = 0 ; // nbre de matrices calculees
00353    static int l_dejafait[nmax] ;
00354    static int nr_dejafait[nmax] ;
00355     
00356    int indice = -1 ;
00357    
00358    // On determine si la matrice a deja ete calculee :
00359    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00360     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00361     indice = conte ;
00362     
00363    // Calcul a faire : 
00364    if (indice  == -1) {
00365        if (nb_dejafait >= nmax) {
00366        cout << "_poisson_2d_non_dege_r_chebu_trois : trop de matrices" << endl ;
00367        abort() ;
00368        exit (-1) ;
00369        }
00370        
00371     l_dejafait[nb_dejafait] = l ;
00372     nr_dejafait[nb_dejafait] = n ;
00373     
00374     Matrice res(n-2, n-2) ;
00375     res.set_etat_qcq() ;
00376     for (int i=0 ; i<n-2 ; i++)
00377     for (int j=0 ; j<n-2 ; j++)
00378         res.set(i, j) = lap(i, j+2) ;
00379     res.set_band(2, 1) ;
00380     res.set_lu() ;
00381     tab[nb_dejafait] = new Matrice(res) ;
00382     nb_dejafait ++ ;
00383     return res ;
00384     }
00385     // Cas ou le calcul a deja ete effectue :
00386     else
00387     return *tab[indice] ;
00388 }
00389 
00390 // Cas dzpuis = 2 ;
00391 Matrice _poisson_2d_non_dege_r_chebu_deux (const Matrice &lap, int l) {
00392     
00393    int n = lap.get_dim(0) ;
00394     
00395    const int nmax = 200; // Nombre de Matrices stockees
00396    static Matrice* tab[nmax] ;  // les matrices calculees
00397    static int nb_dejafait = 0 ; // nbre de matrices calculees
00398    static int l_dejafait[nmax] ;
00399    static int nr_dejafait[nmax] ;
00400     
00401    int indice = -1 ;
00402    
00403    // On determine si la matrice a deja ete calculee :
00404    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00405     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00406     indice = conte ;
00407     
00408    // Calcul a faire : 
00409    if (indice  == -1) {
00410        if (nb_dejafait >= nmax) {
00411        cout << "_poisson_2d_non_dege_r_chebu : trop de matrices" << endl ;
00412        abort() ;
00413        exit (-1) ;
00414        }
00415        
00416         
00417     l_dejafait[nb_dejafait] = l ;
00418     nr_dejafait[nb_dejafait] = n ;
00419     
00420   //  assert (l<=n-2) ;
00421     
00422     if (l==0) {
00423     Matrice res(n-2, n-2) ;
00424     res.set_etat_qcq() ;
00425     for (int i=0 ;i<n-2 ; i++)
00426         for (int j=0 ; j<n-2 ; j++)
00427         res.set(i, j) = lap(i, j+2) ;
00428     res.set_band(3, 2) ;
00429     res.set_lu() ;
00430     tab[nb_dejafait] = new Matrice(res) ;
00431     nb_dejafait ++ ;
00432     return res ;
00433     }
00434     else {
00435     Matrice res(n-1, n-1) ;
00436     res.set_etat_qcq() ;
00437     for (int i=0 ;i<n-1 ; i++)
00438         for (int j=0 ; j<n-1 ; j++)
00439         res.set(i, j) = lap(i, j+1) ;
00440     res.set_band(4, 1) ;
00441     res.set_lu() ;
00442     tab[nb_dejafait] = new Matrice(res) ;
00443     nb_dejafait ++ ;
00444     return res ;
00445     }
00446     }
00447     // Cas ou le calcul a deja ete effectue :
00448     else
00449     return *tab[indice] ;
00450 }
00451 
00452 
00453 void Ope_poisson_2d::do_non_dege() const {
00454   if (ope_cl == 0x0)
00455     do_ope_cl() ;
00456   
00457   if (non_dege != 0x0)
00458     delete non_dege ;
00459   
00460   // Routines de derivation
00461   static Matrice (*poisson_2d_non_dege[MAX_BASE])(const Matrice&, 
00462                             int, double,int);
00463   static int nap = 0 ;
00464   
00465   // Premier appel
00466   if (nap==0) {
00467     nap = 1 ;
00468     for (int i=0 ; i<MAX_BASE ; i++) {
00469       poisson_2d_non_dege[i] = _poisson_2d_non_dege_pas_prevu ;
00470     }
00471     // Les routines existantes
00472     poisson_2d_non_dege[R_CHEB >> TRA_R] = _poisson_2d_non_dege_r_cheb ;
00473     poisson_2d_non_dege[R_CHEBP >> TRA_R] = _poisson_2d_non_dege_r_chebp ;
00474     poisson_2d_non_dege[R_CHEBI >> TRA_R] = _poisson_2d_non_dege_r_chebi ;
00475     poisson_2d_non_dege[R_CHEBU >> TRA_R] = _poisson_2d_non_dege_r_chebu ;
00476   }
00477   non_dege = new Matrice(poisson_2d_non_dege[base_r](*ope_cl, l_quant, 
00478                                beta/alpha, dzpuis)) ;
00479 }

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