sh_ptens_rr.C

00001 /*
00002  *  Methods for computing the homogeneous solutions for Ope_pois_tens_rr.
00003  *
00004  *    (see file Ope_elementary 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 sh_ptens_rr_C[] = "$Heade$" ;
00029 
00030 /*
00031  * $Id: sh_ptens_rr.C,v 1.1 2004/12/23 16:30:15 j_novak Exp $
00032  * $Log: sh_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  *
00039  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_pois_vect_r/sh_ptens_rr.C,v 1.1 2004/12/23 16:30:15 j_novak Exp $
00040  *
00041  */
00042 
00043 //fichiers includes
00044 #include <stdlib.h>
00045 #include <math.h>
00046 
00047 #include "matrice.h"
00048 #include "type_parite.h"
00049 #include "proto.h"
00050 
00051 /*
00052  * 
00053  * Renvoie une ou 2 solution homogene
00054  *  Si base_r = R_CHEB deux solutions (x+echelle)^(l-2) dans (0, *) et
00055  *              1/(x+echelle)^(l+3) dans (1, *)
00056  *  Si base_r = R_CHEBU 1 solution (x-1)^(l+3) dans (*) 
00057  *  Si base_r = R_CHEBP ou R_CHEBI x^(l-2) dans (*)
00058  * l est necessairement > 2...
00059  * 
00060  * Entree : 
00061  *  n : nbre de points en r
00062  *  l : nbre quantique associe
00063  *  echelle : cf ci-dessus, utile que dans le cas R_CHEB
00064  *  base_r : base de decomposition
00065  * 
00066  * Sortie :
00067  *  Tbl contenant les coefficient de la ou des solution homogenes
00068  * 
00069  */
00070 
00071 Tbl _sh_ptens_rr_pas_prevu (int, int, double) ;
00072 Tbl _sh_ptens_rr_cheb (int, int, double) ;
00073 Tbl _sh_ptens_rr_chebp (int, int, double) ;
00074 Tbl _sh_ptens_rr_chebi (int, int, double) ;
00075 Tbl _sh_ptens_rr_chebu (int, int, double) ;
00076 
00077         //------------------------------------
00078         // Routine pour les cas non prevus --
00079         //------------------------------------
00080 Tbl _sh_ptens_rr_pas_prevu (int n, int l, double echelle) {
00081 
00082     cout << " Solution homogene pas prevue ..... : "<< endl ;
00083     cout << " N : " << n << endl ;
00084     cout << " l : " << l << endl ;
00085     cout << " echelle : " << echelle << endl ;
00086     abort() ;
00087     exit(-1) ;
00088     Tbl res(1) ;
00089     return res;
00090 }
00091     
00092     
00093         //-------------------
00094            //--  R_CHEB   ------
00095           //-------------------
00096 
00097 Tbl _sh_ptens_rr_cheb (int n, int l, double echelle) {
00098                 
00099    const int nmax = 200 ; // Nombre de Tbl stockes
00100    static Tbl* tab[nmax] ;  // les Tbl calcules
00101    static int nb_dejafait = 0 ; // nbre de Tbl calcules
00102    static int l_dejafait[nmax] ;
00103    static int nr_dejafait[nmax] ;
00104    static double vieux_echelle = 0;
00105    
00106    // Si on a change l'echelle : on detruit tout :
00107    if (vieux_echelle != echelle) {
00108        for (int i=0 ; i<nb_dejafait ; i++) {
00109        l_dejafait[i] = -1 ;
00110        nr_dejafait[i] = -1 ;
00111        delete tab[i] ;
00112        }
00113     nb_dejafait = 0 ;
00114     vieux_echelle = echelle ;
00115    }
00116       
00117    int indice = -1 ;
00118    
00119    // On determine si la matrice a deja ete calculee :
00120    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00121     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00122     indice = conte ;
00123     
00124    // Calcul a faire : 
00125    if (indice  == -1) {
00126        if (nb_dejafait >= nmax) {
00127        cout << "_sh_ptens_rr_cheb : trop de Tbl" << endl ;
00128        abort() ;
00129        exit (-1) ;
00130        }
00131        
00132         
00133     l_dejafait[nb_dejafait] = l ;
00134     nr_dejafait[nb_dejafait] = n ;
00135         
00136     Tbl res(2, n) ;
00137     res.set_etat_qcq() ;
00138     double* coloc = new double[n] ;
00139     
00140     int * deg = new int[3] ;
00141     deg[0] = 1 ; 
00142     deg[1] = 1 ;
00143     deg[2] = n ;
00144     
00145     //Construction de la premiere solution homogene :
00146     // cad celle polynomiale.
00147     
00148     if (l==2) {
00149     res.set(0, 0) = 1 ;
00150     for (int i=1 ; i<n ; i++)
00151         res.set(0, i) = 0 ;
00152     }
00153     else {
00154     for (int i=0 ; i<n ; i++)
00155         coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(l-2)) ;
00156     
00157     cfrcheb(deg, deg, coloc, deg, coloc) ;
00158     for (int i=0 ; i<n ;i++)
00159         res.set(0, i) = coloc[i] ;
00160     }
00161     
00162     
00163     // construction de la seconde solution homogene :
00164     // cad celle fractionnelle.
00165     for (int i=0 ; i<n ; i++)
00166       coloc[i] = 1/pow(echelle-cos(M_PI*i/(n-1)), double(l+3)) ;
00167     
00168       cfrcheb(deg, deg, coloc, deg, coloc) ;
00169       for (int i=0 ; i<n ;i++)
00170     res.set(1, i) = coloc[i] ;  
00171     
00172     delete [] coloc ;
00173     delete [] deg ;
00174     tab[nb_dejafait] = new Tbl(res) ;
00175     nb_dejafait ++ ;
00176     return res ;
00177     }
00178     
00179     else return *tab[indice] ;
00180 }   
00181     
00182         //-------------------
00183            //--  R_CHEBP  ------
00184           //-------------------
00185 
00186 Tbl _sh_ptens_rr_chebp (int n, int l, double) {
00187    
00188    const int nmax = 200 ; // Nombre de Tbl stockes
00189    static Tbl* tab[nmax] ;  // les Tbl calcules
00190    static int nb_dejafait = 0 ; // nbre de Tbl calcules
00191    static int l_dejafait[nmax] ;
00192    static int nr_dejafait[nmax] ;
00193     
00194    int indice = -1 ;
00195    
00196    // On determine si la matrice a deja ete calculee :
00197    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00198     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00199     indice = conte ;
00200     
00201    // Calcul a faire : 
00202    if (indice  == -1) {
00203        if (nb_dejafait >= nmax) {
00204        cout << "_sh_ptens_rr_chebp : trop de Tbl" << endl ;
00205        abort() ;
00206        exit (-1) ;
00207        }
00208        
00209     
00210     l_dejafait[nb_dejafait] = l ;
00211     nr_dejafait[nb_dejafait] = n ;
00212     
00213     Tbl res(n) ;
00214     res.set_etat_qcq() ;
00215     double* coloc = new double[n] ;
00216     
00217     int * deg = new int[3] ;
00218     deg[0] = 1 ; 
00219     deg[1] = 1 ;
00220     deg[2] = n ;
00221     
00222     assert (l % 2 == 0)  ;
00223    if (l==0) {
00224       res.set(0) = 1 ;
00225       for (int i=1 ; i<n ; i++)
00226     res.set(i) = 0 ;
00227     }
00228     else {
00229       for (int i=0 ; i<n ; i++)
00230     coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l-2)) ;
00231     
00232     cfrchebp(deg, deg, coloc, deg, coloc) ;
00233     for (int i=0 ; i<n ;i++)
00234         res.set(i) = coloc[i] ;
00235     }
00236 
00237     delete [] coloc ;
00238     delete [] deg ;
00239     tab[nb_dejafait] = new Tbl(res) ;
00240     nb_dejafait ++ ;
00241     return res ;
00242     }
00243     
00244     else return *tab[indice] ;
00245 }
00246     
00247     
00248             //-------------------
00249            //--  R_CHEBI   -----
00250           //-------------------
00251     
00252 Tbl _sh_ptens_rr_chebi (int n, int l, double) {
00253        
00254    const int nmax = 200 ; // Nombre de Tbl stockes
00255    static Tbl* tab[nmax] ;  // les Tbl calcules
00256    static int nb_dejafait = 0 ; // nbre de Tbl calcules
00257    static int l_dejafait[nmax] ;
00258    static int nr_dejafait[nmax] ;
00259     
00260    int indice = -1 ;
00261    
00262    // On determine si la matrice a deja ete calculee :
00263    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00264     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00265     indice = conte ;
00266     
00267    // Calcul a faire : 
00268    if (indice  == -1) {
00269        if (nb_dejafait >= nmax) {
00270        cout << "_sh_ptens_rr_chebi : trop de Tbl" << endl ;
00271        abort() ;
00272        exit (-1) ;
00273        }
00274        
00275         
00276     l_dejafait[nb_dejafait] = l ;
00277     nr_dejafait[nb_dejafait] = n ;
00278     
00279     
00280     assert (l%2 == 1)  ;
00281     
00282     Tbl res(n) ;
00283     res.set_etat_qcq() ;
00284     double* coloc = new double[n] ;
00285     
00286     int * deg = new int[3] ;
00287     deg[0] = 1 ; 
00288     deg[1] = 1 ;
00289     deg[2] = n ;
00290     
00291     for (int i=0 ; i<n ; i++)
00292     coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l-2)) ;
00293     
00294     cfrchebi(deg, deg, coloc, deg, coloc) ;
00295     for (int i=0 ; i<n ;i++)
00296     res.set(i) = coloc[i] ;
00297     
00298     
00299     delete [] coloc ;
00300     delete [] deg ;
00301     tab[nb_dejafait] = new Tbl(res) ;
00302     nb_dejafait ++ ;
00303     return res ;
00304    }
00305     
00306    else return *tab[indice] ;
00307 }
00308     
00309     
00310     
00311             //-------------------
00312            //--  R_CHEBU   -----
00313           //-------------------
00314     
00315 Tbl _sh_ptens_rr_chebu (int n, int l, double) {
00316            
00317    const int nmax = 200 ; // Nombre de Tbl stockes
00318    static Tbl* tab[nmax] ;  // les Tbl calcules
00319    static int nb_dejafait = 0 ; // nbre de Tbl calcules
00320    static int l_dejafait[nmax] ;
00321    static int nr_dejafait[nmax] ;
00322     
00323    int indice = -1 ;
00324    
00325    // On determine si la matrice a deja ete calculee :
00326    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00327     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00328     indice = conte ;
00329     
00330    // Calcul a faire : 
00331    if (indice  == -1) {
00332        if (nb_dejafait >= nmax) {
00333        cout << "_sh_ptens_rr_chebu : trop de Tbl" << endl ;
00334        abort() ;
00335        exit (-1) ;
00336       }
00337        
00338         
00339     l_dejafait[nb_dejafait] = l ;
00340     nr_dejafait[nb_dejafait] = n ;
00341     
00342     Tbl res(n) ;
00343     res.set_etat_qcq() ;
00344     double* coloc = new double[n] ;
00345     
00346     int * deg = new int[3] ;
00347     deg[0] = 1 ; 
00348     deg[1] = 1 ;
00349     deg[2] = n ;
00350     
00351     for (int i=0 ; i<n ; i++)
00352     coloc[i] = pow(-1-cos(M_PI*i/(n-1)), double(l+3)) ;
00353     
00354     cfrcheb(deg, deg, coloc, deg, coloc) ;
00355     for (int i=0 ; i<n ;i++)
00356     res.set(i) = coloc[i] ;
00357     
00358     delete [] coloc ;
00359     delete [] deg ;
00360     tab[nb_dejafait] = new Tbl(res) ;
00361     nb_dejafait ++ ;
00362     return res ;
00363     }
00364     
00365     else return *tab[indice] ;
00366 }
00367     
00368     
00369     
00370     
00371             //-------------------
00372            //--  Fonction   ----
00373           //-------------------
00374           
00375           
00376 Tbl sh_ptens_rr(int n, int l, double echelle, int base_r) {
00377 
00378         // Routines de derivation
00379     static Tbl (*sh_ptens_rr[MAX_BASE])(int, int, double) ;
00380     static int nap = 0 ;
00381 
00382         // Premier appel
00383     if (nap==0) {
00384     nap = 1 ;
00385     for (int i=0 ; i<MAX_BASE ; i++) {
00386         sh_ptens_rr[i] = _sh_ptens_rr_pas_prevu ;
00387     }
00388         // Les routines existantes
00389     sh_ptens_rr[R_CHEB >> TRA_R] = _sh_ptens_rr_cheb ;
00390     sh_ptens_rr[R_CHEBU >> TRA_R] = _sh_ptens_rr_chebu ;
00391     sh_ptens_rr[R_CHEBP >> TRA_R] = _sh_ptens_rr_chebp ;
00392     sh_ptens_rr[R_CHEBI >> TRA_R] = _sh_ptens_rr_chebi ;
00393     }
00394 
00395     assert (l > 1) ;
00396     
00397     Tbl res(sh_ptens_rr[base_r](n, l, echelle)) ;
00398     return res ;
00399 }

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