comb_lin.C

00001 /*
00002  *   Copyright (c) 1999-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_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin.C,v 1.8 2008/02/18 13:53:42 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: comb_lin.C,v 1.8 2008/02/18 13:53:42 j_novak Exp $
00027  * $Log: comb_lin.C,v $
00028  * Revision 1.8  2008/02/18 13:53:42  j_novak
00029  * Removal of special indentation instructions.
00030  *
00031  * Revision 1.7  2007/12/12 12:30:48  jl_cornou
00032  * *** empty log message ***
00033  *
00034  * Revision 1.6  2007/06/06 07:43:28  p_grandclement
00035  * nmax increased to 200
00036  *
00037  * Revision 1.5  2004/02/09 09:33:56  j_novak
00038  * Minor modif.
00039  *
00040  * Revision 1.4  2004/02/06 10:53:54  j_novak
00041  * New dzpuis = 5 -> dzpuis = 3 case (not ready yet).
00042  *
00043  * Revision 1.3  2002/10/16 14:37:11  j_novak
00044  * Reorganization of #include instructions of standard C++, in order to
00045  * use experimental version 3 of gcc.
00046  *
00047  * Revision 1.2  2002/10/09 12:47:31  j_novak
00048  * Execution speed improved
00049  *
00050  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00051  * LORENE
00052  *
00053  * Revision 2.15  2000/09/07  12:52:04  phil
00054  * *** empty log message ***
00055  *
00056  * Revision 2.14  2000/05/22  13:39:01  phil
00057  * ajout du cas dzpuis == 3
00058  *
00059  * Revision 2.13  2000/01/04  18:59:58  phil
00060  * Double nmax
00061  *
00062  * Revision 2.12  1999/10/12  09:38:52  phil
00063  * passage en const Matrice&
00064  *
00065  * Revision 2.11  1999/10/11  14:26:07  phil
00066  * & _> &&
00067  *
00068  * Revision 2.10  1999/09/30  09:25:36  phil
00069  * ajout condition sur dirac=0
00070  *
00071  * Revision 2.9  1999/09/30  09:21:51  phil
00072  * remplacement des && en &
00073  *
00074  * Revision 2.8  1999/09/17  15:22:47  phil
00075  * correction definition NMAX
00076  *
00077  * Revision 2.7  1999/06/23  12:34:29  phil
00078  * ajout de dzpuis = 2
00079  *
00080  * Revision 2.6  1999/04/28  10:48:19  phil
00081  * augmentation de NMAX a 50
00082  *
00083  * Revision 2.5  1999/04/19  14:01:45  phil
00084  * *** empty log message ***
00085  *
00086  * Revision 2.4  1999/04/16  13:15:45  phil
00087  * *** empty log message ***
00088  *
00089  * Revision 2.3  1999/04/14  13:56:17  phil
00090  * Sauvegarde des Matrices deja calculees
00091  *
00092  * Revision 2.2  1999/04/07  14:37:34  phil
00093  * *** empty log message ***
00094  *
00095  * Revision 2.1  1999/04/07  14:29:51  phil
00096  * passage par reference
00097  *
00098  * Revision 2.0  1999/04/07  14:09:11  phil
00099  * *** empty log message ***
00100  *
00101  *
00102  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin.C,v 1.8 2008/02/18 13:53:42 j_novak Exp $
00103  *
00104  */
00105 
00106 //fichiers includes
00107 #include <stdio.h>
00108 #include <stdlib.h>
00109 #include <math.h>
00110 
00111 #include "matrice.h"
00112 #include "type_parite.h"
00113 #include "proto.h"
00114 
00115 /*   FONCTIONS FAISANT DES COMBINAISONS LINEAIRES DES LIGNES.
00116  * Existe en deux versions Tbl ou Matrice.
00117  * 
00118  * Entree :
00119  *  La Matrice ou le Tbl ( a une dimension)
00120  *  l : nbre quantique
00121  *  puis = puissance dans la ZEC
00122  *  La base de developpement en R
00123  * 
00124  * Sortie :
00125  *  Renvoie la matrice ou le tableau apres Combinaison lineaire
00126  * 
00127  */
00128 
00129 // Version Matrice --> Matrice
00130 Matrice _cl_pas_prevu (const Matrice &source, int l, double echelle, int puis) {
00131     cout << "Combinaison lineaire pas prevu..." << endl ;
00132     cout << "Source : " << source << endl ;
00133     cout << "l : " << l << endl ;
00134     cout << "dzpuis : " << puis << endl ;
00135     cout << "Echelle : " << echelle << endl ;
00136     abort() ;
00137     exit(-1) ;
00138     return source;
00139 }
00140 
00141 
00142         //-------------------
00143            //--  R_CHEB   ------
00144           //-------------------
00145 
00146 Matrice _cl_r_cheb (const Matrice &source, int l, double echelle, int) {
00147     int n = source.get_dim(0) ;assert (n == source.get_dim(1)) ;
00148     
00149                 
00150    const int nmax = 200 ; // Nombre de Matrices stockees
00151    static Matrice* tab[nmax] ;  // les matrices calculees
00152    static int nb_dejafait = 0 ; // nbre de matrices calculees
00153    static int l_dejafait[nmax] ;
00154    static int nr_dejafait[nmax] ;
00155    static double vieux_echelle = 0 ;
00156    
00157    // Si on a change l'echelle : on detruit tout :
00158    if (vieux_echelle != echelle) {
00159        for (int i=0 ; i<nb_dejafait ; i++) {
00160        l_dejafait[i] = -1 ;
00161        nr_dejafait[i] = -1 ;
00162        delete tab[i] ;
00163        }
00164        nb_dejafait = 0 ;
00165        vieux_echelle = echelle ;
00166    }
00167       
00168    int indice = -1 ;
00169    
00170    // On determine si la matrice a deja ete calculee :
00171    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00172     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00173     indice = conte ;
00174     
00175    // Calcul a faire : 
00176    if (indice  == -1) {
00177        if (nb_dejafait >= nmax) {
00178        cout << "_cl_r_cheb : trop de matrices" << endl ;
00179        abort() ;
00180        exit (-1) ;
00181        }
00182        
00183     l_dejafait[nb_dejafait] = l ;
00184     nr_dejafait[nb_dejafait] = n ;
00185     
00186     Matrice barre(source) ;
00187     int dirac = 1 ;
00188     for (int i=0 ; i<n-2 ; i++) {
00189     for (int j=i ; j<(n>(i+7)? i+7 : n) ; j++)
00190         barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
00191                 /(i+1) ;
00192     if (i==0) dirac = 0 ;
00193     }
00194     
00195     Matrice res(barre) ;
00196     for (int i=0 ; i<n-4 ; i++)
00197     for (int j=i ; j<(n>(i+5)? i+5 : n) ; j++)
00198         res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00199     tab[nb_dejafait] = new Matrice(res) ;
00200     nb_dejafait ++ ;    
00201     return res ;
00202     }
00203     
00204     // Cas ou le calcul a deja ete effectue :
00205     else
00206     return *tab[indice] ;  
00207 }
00208 
00209 
00210         //-------------------
00211            //--  R_JACO02 ------
00212           //-------------------
00213 
00214 Matrice _cl_r_jaco02 (const Matrice &source, int l, double echelle, int) {
00215     int n = source.get_dim(0) ;assert (n == source.get_dim(1)) ;
00216     
00217                 
00218    const int nmax = 200 ; // Nombre de Matrices stockees
00219    static Matrice* tab[nmax] ;  // les matrices calculees
00220    static int nb_dejafait = 0 ; // nbre de matrices calculees
00221    static int l_dejafait[nmax] ;
00222    static int nr_dejafait[nmax] ;
00223    static double vieux_echelle = 0 ;
00224    
00225    // Si on a change l'echelle : on detruit tout :
00226    if (vieux_echelle != echelle) {
00227        for (int i=0 ; i<nb_dejafait ; i++) {
00228        l_dejafait[i] = -1 ;
00229        nr_dejafait[i] = -1 ;
00230        delete tab[i] ;
00231        }
00232        nb_dejafait = 0 ;
00233        vieux_echelle = echelle ;
00234    }
00235       
00236    int indice = -1 ;
00237    
00238    // On determine si la matrice a deja ete calculee :
00239    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00240     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00241     indice = conte ;
00242     
00243    // Calcul a faire : 
00244    if (indice  == -1) {
00245        if (nb_dejafait >= nmax) {
00246        cout << "_cl_r_jaco02 : trop de matrices" << endl ;
00247        abort() ;
00248        exit (-1) ;
00249        }
00250        
00251     l_dejafait[nb_dejafait] = l ;
00252     nr_dejafait[nb_dejafait] = n ;
00253     
00254     Matrice barre(source) ;
00255     for (int i=0 ; i<n ; i++) {
00256     for (int j=i ; j<n ; j++)
00257         barre.set(i, j) = source(i, j) ;
00258     }
00259     
00260     Matrice res(barre) ;
00261     for (int i=0 ; i<n ; i++)
00262     for (int j=i ; j<n ; j++)
00263         res.set(i, j) = barre(i, j);
00264     tab[nb_dejafait] = new Matrice(res) ;
00265     nb_dejafait ++ ;    
00266     return res ;
00267     }
00268     
00269     // Cas ou le calcul a deja ete effectue :
00270     else
00271     return *tab[indice] ;  
00272 }
00273 
00274 
00275         //-------------------
00276            //--  R_CHEBP   -----
00277           //-------------------
00278 
00279 
00280 Matrice _cl_r_chebp (const Matrice &source, int l, double, int) {
00281     
00282     int n = source.get_dim(0) ;
00283     assert (n == source.get_dim(1)) ;
00284     
00285    const int nmax = 200 ; // Nombre de Matrices stockees
00286    static Matrice* tab[nmax] ;  // les matrices calculees
00287    static int nb_dejafait = 0 ; // nbre de matrices calculees
00288    static int l_dejafait[nmax] ;
00289    static int nr_dejafait[nmax] ;
00290     
00291    int indice = -1 ;
00292    
00293    // On determine si la matrice a deja ete calculee :
00294    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00295     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00296     indice = conte ;
00297     
00298    // Calcul a faire : 
00299    if (indice  == -1) {
00300        if (nb_dejafait >= nmax) {
00301        cout << "_cl_r_chebp : trop de matrices" << endl ;
00302        abort() ;
00303        exit (-1) ;
00304        }
00305        
00306     l_dejafait[nb_dejafait] = l ;
00307     nr_dejafait[nb_dejafait] = n ;
00308     
00309     Matrice barre(source) ;
00310   
00311     int dirac = 1 ;
00312     for (int i=0 ; i<n-2 ; i++) {
00313     for (int j=0 ; j<n ; j++)
00314         barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
00315     if (i==0) dirac = 0 ;
00316     }
00317 
00318     Matrice tilde(barre) ;
00319     for (int i=0 ; i<n-4 ; i++)
00320     for (int j=0 ; j<n ; j++)
00321         tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
00322 
00323     Matrice res(tilde) ;
00324     for (int i=0 ; i<n-4 ; i++)
00325     for (int j=0 ; j<n ; j++)
00326         res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00327     tab[nb_dejafait] = new Matrice(res) ;
00328     nb_dejafait ++ ;    
00329     return res ;
00330     }
00331     
00332     // Cas ou le calcul a deja ete effectue :
00333     else
00334     return *tab[indice] ;
00335 }
00336 
00337         //-------------------
00338            //--  R_CHEBI   -----
00339           //-------------------
00340 
00341 
00342 Matrice _cl_r_chebi (const Matrice &source, int l, double, int) {
00343     int n = source.get_dim(0) ;
00344     assert (n == source.get_dim(1)) ;
00345     
00346        
00347    const int nmax = 200 ; // Nombre de Matrices stockees
00348    static Matrice* tab[nmax] ;  // les matrices calculees
00349    static int nb_dejafait = 0 ; // nbre de matrices calculees
00350    static int l_dejafait[nmax] ;
00351    static int nr_dejafait[nmax] ;
00352     
00353    int indice = -1 ;
00354    
00355    // On determine si la matrice a deja ete calculee :
00356    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00357     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00358     indice = conte ;
00359     
00360    // Calcul a faire : 
00361    if (indice  == -1) {
00362        if (nb_dejafait >= nmax) {
00363        cout << "_cl_r_chebi : trop de matrices" << endl ;
00364        abort() ;
00365        exit (-1) ;
00366        }
00367         
00368     l_dejafait[nb_dejafait] = l ;
00369     nr_dejafait[nb_dejafait] = n ;
00370     
00371     Matrice barre(source) ;
00372    
00373     for (int i=0 ; i<n-2 ; i++)
00374     for (int j=0 ; j<n ; j++)
00375         barre.set(i, j) = source(i, j)-source(i+2, j) ;
00376 
00377     Matrice tilde(barre) ;
00378     for (int i=0 ; i<n-4 ; i++)
00379     for (int j=0 ; j<n ; j++)
00380         tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;    
00381 
00382     Matrice res(tilde) ;
00383     for (int i=0 ; i<n-4 ; i++)
00384     for (int j=0 ; j<n ; j++)
00385         res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00386     tab[nb_dejafait] = new Matrice(res) ;
00387     nb_dejafait ++ ;
00388     return res ;
00389     } 
00390     
00391     // Cas ou le calcul a deja ete effectue :
00392     else
00393     return *tab[indice] ;
00394 }
00395         //-------------------
00396            //--  R_CHEBU   -----
00397           //-------------------
00398 
00399 Matrice _cl_r_chebu (const Matrice &source, int l, double, int puis) {
00400     int n = source.get_dim(0) ;
00401     assert (n == source.get_dim(1)) ;
00402     
00403     Matrice res(n, n) ;
00404     res.set_etat_qcq() ;
00405     
00406     switch (puis) {
00407     case 5 :
00408         res = _cl_r_chebu_cinq(source, l) ;
00409         break ;
00410     case 4 :
00411         res = _cl_r_chebu_quatre(source, l) ;
00412         break ;
00413     case 3 :
00414         res = _cl_r_chebu_trois (source, l) ;
00415         break ;
00416     case 2 :
00417         res = _cl_r_chebu_deux(source, l) ;
00418         break ;
00419     default :
00420         abort() ;
00421         exit(-1) ;
00422     }
00423     
00424     return res ;
00425 }
00426 
00427 
00428 // Cas dzpuis = 4
00429 Matrice _cl_r_chebu_quatre (const Matrice &source, int l) {
00430     int n = source.get_dim(0) ;
00431     assert (n == source.get_dim(1)) ;
00432     
00433             
00434    const int nmax = 200 ; // Nombre de Matrices stockees
00435    static Matrice* tab[nmax] ;  // les matrices calculees
00436    static int nb_dejafait = 0 ; // nbre de matrices calculees
00437    static int l_dejafait[nmax] ;
00438    static int nr_dejafait[nmax] ;
00439     
00440    int indice = -1 ;
00441    
00442    // On determine si la matrice a deja ete calculee :
00443    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00444     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00445     indice = conte ;
00446     
00447    // Calcul a faire : 
00448    if (indice  == -1) {
00449        if (nb_dejafait >= nmax) {
00450        cout << "_cl_r_chebu_quatre : trop de matrices" << endl ;
00451        abort() ;
00452        exit (-1) ;
00453        }
00454        
00455     l_dejafait[nb_dejafait] = l ;
00456     nr_dejafait[nb_dejafait] = n ;
00457     
00458     Matrice barre(source) ;
00459   
00460     int dirac = 1 ;
00461     for (int i=0 ; i<n-2 ; i++) {
00462     for (int j=0 ; j<n ; j++)
00463          barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00464     if (i==0) dirac = 0 ;
00465     }
00466     
00467     Matrice tilde(barre) ;
00468     for (int i=0 ; i<n-4 ; i++)
00469     for (int j=0 ; j<n ; j++)
00470         tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00471         
00472     Matrice prime(tilde) ;
00473     for (int i=0 ; i<n-4 ; i++)
00474     for (int j=0 ; j<n ; j++)
00475         prime.set(i, j) = (tilde(i, j)-tilde(i+1, j)) ;
00476     
00477     Matrice res(prime) ;
00478     for (int i=0 ; i<n-4 ; i++)
00479     for (int j=0 ; j<n ; j++)
00480         res.set(i, j) = (prime(i, j)-prime(i+2, j)) ;
00481     tab[nb_dejafait] = new Matrice(res) ;
00482     nb_dejafait ++ ;    
00483     return res ;
00484     } 
00485     
00486     // Cas ou le calcul a deja ete effectue :
00487     else
00488     return *tab[indice] ;
00489 }
00490 
00491 // Cas dzpuis == 3
00492 Matrice _cl_r_chebu_trois (const Matrice &source, int l) {
00493     int n = source.get_dim(0) ;
00494     assert (n == source.get_dim(1)) ;
00495     
00496             
00497    const int nmax = 200 ; // Nombre de Matrices stockees
00498    static Matrice* tab[nmax] ;  // les matrices calculees
00499    static int nb_dejafait = 0 ; // nbre de matrices calculees
00500    static int l_dejafait[nmax] ;
00501    static int nr_dejafait[nmax] ;
00502     
00503    int indice = -1 ;
00504    
00505    // On determine si la matrice a deja ete calculee :
00506    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00507     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00508     indice = conte ;
00509     
00510    // Calcul a faire : 
00511    if (indice  == -1) {
00512        if (nb_dejafait >= nmax) {
00513        cout << "_cl_r_chebu_trois : trop de matrices" << endl ;
00514        abort() ;
00515        exit (-1) ;
00516        }
00517        
00518     l_dejafait[nb_dejafait] = l ;
00519     nr_dejafait[nb_dejafait] = n ;
00520     
00521     Matrice barre(source) ;
00522   
00523     int dirac = 1 ;
00524     for (int i=0 ; i<n-2 ; i++) {
00525     for (int j=0 ; j<n ; j++)
00526          barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00527     if (i==0) dirac = 0 ;
00528     }
00529     
00530     Matrice tilde(barre) ;
00531     for (int i=0 ; i<n-4 ; i++)
00532     for (int j=0 ; j<n ; j++)
00533         tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00534     
00535     Matrice res(tilde) ;
00536     for (int i=0 ; i<n-4 ; i++)
00537     for (int j=0 ; j<n ; j++)
00538         res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
00539     
00540     tab[nb_dejafait] = new Matrice(res) ;
00541     nb_dejafait ++ ;    
00542     return res ;
00543     } 
00544     
00545     // Cas ou le calcul a deja ete effectue :
00546     else
00547     return *tab[indice] ;
00548 }
00549 
00550 
00551 //Cas dzpuis == 2
00552 Matrice _cl_r_chebu_deux (const Matrice &source, int l) {
00553     int n = source.get_dim(0) ;
00554     assert (n == source.get_dim(1)) ;
00555     
00556             
00557    const int nmax = 200 ; // Nombre de Matrices stockees
00558    static Matrice* tab[nmax] ;  // les matrices calculees
00559    static int nb_dejafait = 0 ; // nbre de matrices calculees
00560    static int l_dejafait[nmax] ;
00561    static int nr_dejafait[nmax] ;
00562     
00563    int indice = -1 ;
00564    
00565    // On determine si la matrice a deja ete calculee :
00566    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00567     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00568     indice = conte ;
00569     
00570    // Calcul a faire : 
00571    if (indice  == -1) {
00572        if (nb_dejafait >= nmax) {
00573        cout << "_cl_r_chebu_deux : trop de matrices" << endl ;
00574        abort() ;
00575        exit (-1) ;
00576        }
00577        
00578     l_dejafait[nb_dejafait] = l ;
00579     nr_dejafait[nb_dejafait] = n ;
00580     
00581     Matrice barre(source) ;
00582   
00583     int dirac = 1 ;
00584     for (int i=0 ; i<n-2 ; i++) {
00585     for (int j=0 ; j<n ; j++)
00586          barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00587     if (i==0) dirac = 0 ;
00588     }
00589    
00590     Matrice tilde(barre) ;
00591     for (int i=0 ; i<n-4 ; i++)
00592     for (int j=0 ; j<n ; j++)
00593         tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00594         
00595     Matrice res(tilde) ;
00596     for (int i=0 ; i<n-4 ; i++)
00597     for (int j=0 ; j<n ; j++)
00598         res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
00599 
00600     return res ;
00601     } 
00602     
00603     // Cas ou le calcul a deja ete effectue :
00604     else
00605     return *tab[indice] ;
00606 }
00607 
00608 
00609 //Cas dzpuis == 5
00610 Matrice _cl_r_chebu_cinq (const Matrice &source, int l) {
00611     int n = source.get_dim(0) ;
00612     assert (n == source.get_dim(1)) ;
00613     
00614             
00615    const int nmax = 200 ; // Nombre de Matrices stockees
00616    static Matrice* tab[nmax] ;  // les matrices calculees
00617    static int nb_dejafait = 0 ; // nbre de matrices calculees
00618    static int l_dejafait[nmax] ;
00619    static int nr_dejafait[nmax] ;
00620     
00621    int indice = -1 ;
00622    
00623    // On determine si la matrice a deja ete calculee :
00624    for (int conte=0 ; conte<nb_dejafait ; conte ++)
00625     if ((l_dejafait[conte] == l) && (nr_dejafait[conte] == n))
00626     indice = conte ;
00627     
00628    // Calcul a faire : 
00629    if (indice  == -1) {
00630        if (nb_dejafait >= nmax) {
00631        cout << "_cl_r_chebu_cinq : trop de matrices" << endl ;
00632        abort() ;
00633        exit (-1) ;
00634        }
00635        
00636     l_dejafait[nb_dejafait] = l ;
00637     nr_dejafait[nb_dejafait] = n ;
00638     
00639     Matrice barre(source) ;
00640   
00641     int dirac = 1 ;
00642     for (int i=0 ; i<n-2 ; i++) {
00643     for (int j=0 ; j<n ; j++)
00644          barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00645     if (i==0) dirac = 0 ;
00646     }
00647    
00648     Matrice tilde(barre) ;
00649     for (int i=0 ; i<n-4 ; i++)
00650     for (int j=0 ; j<n ; j++)
00651         tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00652         
00653     Matrice res(tilde) ;
00654     for (int i=0 ; i<n-4 ; i++)
00655     for (int j=0 ; j<n ; j++)
00656         res.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
00657 
00658 //     cout << "Apres comb. lin. : " << endl ;
00659 //     cout << res ;
00660 //     int fg ; cin >> fg ;
00661 
00662     return res ;
00663     } 
00664     
00665     // Cas ou le calcul a deja ete effectue :
00666     else
00667     return *tab[indice] ;
00668 }
00669 
00670         //-------------------------
00671            //- La routine a appeler ---
00672           //---------------------------
00673 
00674 Matrice combinaison (const Matrice &source, int l, double echelle, int puis, int base_r) {
00675     
00676         // Routines de derivation
00677     static Matrice (*combinaison[MAX_BASE])(const Matrice &, int, double, int) ;
00678     static int nap = 0 ;
00679 
00680         // Premier appel
00681     if (nap==0) {
00682     nap = 1 ;
00683     for (int i=0 ; i<MAX_BASE ; i++) {
00684         combinaison[i] = _cl_pas_prevu ;
00685     }
00686         // Les routines existantes
00687     combinaison[R_CHEB >> TRA_R] = _cl_r_cheb ;
00688     combinaison[R_CHEBU >> TRA_R] = _cl_r_chebu ;
00689     combinaison[R_CHEBP >> TRA_R] = _cl_r_chebp ;
00690     combinaison[R_CHEBI >> TRA_R] = _cl_r_chebi ;
00691     combinaison[R_JACO02 >> TRA_R] = _cl_r_jaco02 ;
00692     }
00693     
00694     Matrice res(combinaison[base_r](source, l, echelle, puis)) ;
00695     return res ;
00696 }
00697 
00698 //--------------------------------------------------
00699 // Version Tbl --> Tbl a 1D pour la source 
00700 //--------------------------------------------------
00701 
00702 
00703 Tbl _cl_pas_prevu (const Tbl &source, int puis) {
00704      cout << "Combinaison lineaire pas prevue..." << endl ;
00705     cout << "source : " << &source << endl ;
00706     cout << "dzpuis : " << puis << endl ;
00707     abort() ;
00708     exit(-1) ;
00709     return source;
00710 }
00711 
00712 
00713 
00714         //-------------------
00715            //--  R_CHEB  -------
00716           //--------------------
00717 
00718 Tbl _cl_r_cheb (const Tbl &source, int) {
00719     Tbl barre(source) ;
00720     int n = source.get_dim(0) ;
00721     
00722     int dirac = 1 ;
00723     for (int i=0 ; i<n-2 ; i++) {
00724         barre.set(i) = ((1+dirac)*source(i)-source(i+2))
00725                 /(i+1) ;
00726     if (i==0) dirac = 0 ;
00727     }
00728     
00729     Tbl res(barre) ;
00730     for (int i=0 ; i<n-4 ; i++)
00731         res.set(i) = barre(i)-barre(i+2) ;
00732    return res ;        
00733 }
00734 
00735 
00736         //-------------------
00737            //--  R_JACO02 ------
00738           //-------------------
00739 
00740 Tbl _cl_r_jaco02 (const Tbl &source, int) {
00741     Tbl barre(source) ;
00742     int n = source.get_dim(0) ;
00743     
00744     for (int i=0 ; i<n ; i++) {
00745         barre.set(i) = source(i) ;
00746     }
00747     
00748     Tbl res(barre) ;
00749     for (int i=0 ; i<n ; i++)
00750         res.set(i) = barre(i);
00751    return res ;        
00752 }
00753 
00754 
00755         //-------------------
00756            //--  R_CHEBP   -----
00757           //-------------------
00758 
00759 Tbl _cl_r_chebp (const Tbl &source, int) {
00760     Tbl barre(source) ;
00761     int n = source.get_dim(0) ;
00762     
00763     int dirac = 1 ;
00764     for (int i=0 ; i<n-2 ; i++) {
00765         barre.set(i) = (1+dirac)*source(i)-source(i+2) ;
00766     if (i==0) dirac = 0 ;
00767     }
00768 
00769     Tbl tilde(barre) ;
00770     for (int i=0 ; i<n-4 ; i++)
00771         tilde.set(i) = barre(i)-barre(i+2) ;
00772 
00773     Tbl res(tilde) ;
00774     for (int i=0 ; i<n-4 ; i++)
00775         res.set(i) = tilde(i)-tilde(i+1) ;
00776     
00777    return res ;
00778 }
00779 
00780 
00781         //-------------------
00782            //--  R_CHEBI   -----
00783           //-------------------
00784 
00785 Tbl _cl_r_chebi (const Tbl &source, int) {
00786     Tbl barre(source) ;
00787     int n = source.get_dim(0) ;
00788     
00789     for (int i=0 ; i<n-2 ; i++)
00790         barre.set(i) = source(i)-source(i+2) ;
00791 
00792     Tbl tilde(barre) ;
00793     for (int i=0 ; i<n-4 ; i++)
00794         tilde.set(i) = barre(i)-barre(i+2) ;    
00795 
00796     Tbl res(tilde) ;
00797     for (int i=0 ; i<n-4 ; i++)
00798         res.set(i) = tilde(i)-tilde(i+1) ;
00799     
00800    return res ;
00801 }
00802 
00803 
00804         //-------------------
00805            //--  R_CHEBU   -----
00806           //-------------------
00807 
00808 Tbl _cl_r_chebu (const Tbl &source, int puis) {
00809     
00810     int n=source.get_dim(0) ;
00811     Tbl res(n) ;
00812     res.set_etat_qcq() ;
00813     
00814     switch(puis) {
00815     case 5 :
00816         res = _cl_r_chebu_cinq(source) ;
00817         break ;
00818     case 4 :
00819         res = _cl_r_chebu_quatre(source) ;
00820         break ;
00821     case 3 :
00822         res = _cl_r_chebu_trois (source) ;
00823         break ;
00824     case 2 :
00825         res = _cl_r_chebu_deux(source) ;
00826         break ;
00827     
00828     default :
00829         abort() ;
00830         exit(-1) ;    
00831     }
00832    return res ;
00833 }
00834 
00835 // Cas dzpuis = 4 ;
00836 Tbl _cl_r_chebu_quatre (const Tbl &source) {
00837     Tbl barre(source) ;
00838     int n = source.get_dim(0) ;
00839     
00840     int dirac = 1 ;
00841     for (int i=0 ; i<n-2 ; i++) {
00842          barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
00843     if (i==0) dirac = 0 ;
00844     }
00845     
00846     Tbl tilde(barre) ;
00847     for (int i=0 ; i<n-4 ; i++)
00848         tilde.set(i) = (barre(i)-barre(i+2)) ;
00849         
00850     Tbl prime(tilde) ;
00851     for (int i=0 ; i<n-4 ; i++)
00852         prime.set(i) = (tilde(i)-tilde(i+1)) ;
00853     
00854      Tbl res(prime) ;
00855     for (int i=0 ; i<n-4 ; i++)
00856         res.set(i) = (prime(i)-prime(i+2)) ;
00857  
00858    return res ;
00859 }
00860 // cas dzpuis = 3
00861 Tbl _cl_r_chebu_trois (const Tbl &source) {
00862     Tbl barre(source) ;
00863     int n = source.get_dim(0) ;
00864     
00865     int dirac = 1 ;
00866     for (int i=0 ; i<n-2 ; i++) {
00867          barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
00868     if (i==0) dirac = 0 ;
00869     }
00870     
00871     Tbl tilde(barre) ;
00872     for (int i=0 ; i<n-4 ; i++)
00873         tilde.set(i) = (barre(i)-barre(i+2)) ;
00874         
00875     Tbl res(tilde) ;
00876     for (int i=0 ; i<n-4 ; i++)
00877         res.set(i) = (tilde(i)+tilde(i+1)) ;
00878  
00879    return res ;
00880 }
00881 
00882 // Cas dzpuis = 2 ;
00883 Tbl _cl_r_chebu_deux (const Tbl &source) {
00884     Tbl barre(source) ;
00885     int n = source.get_dim(0) ;
00886     
00887     int dirac = 1 ;
00888     for (int i=0 ; i<n-2 ; i++) {
00889          barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
00890     if (i==0) dirac = 0 ;
00891     }
00892     
00893     Tbl tilde(barre) ;
00894     for (int i=0 ; i<n-4 ; i++)
00895         tilde.set(i) = (barre(i)-barre(i+2)) ;
00896         
00897     Tbl res(tilde) ;
00898     for (int i=0 ; i<n-4 ; i++)
00899         res.set(i) = (tilde(i)+tilde(i+1)) ;
00900    return res ;
00901 }
00902 
00903 // Cas dzpuis = 5 ;
00904 Tbl _cl_r_chebu_cinq (const Tbl &source) {
00905     Tbl barre(source) ;
00906     int n = source.get_dim(0) ;
00907     
00908     int dirac = 1 ;
00909     for (int i=0 ; i<n-2 ; i++) {
00910          barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
00911     if (i==0) dirac = 0 ;
00912     }
00913     
00914     Tbl tilde(barre) ;
00915     for (int i=0 ; i<n-4 ; i++)
00916         tilde.set(i) = (barre(i)-barre(i+2)) ;
00917         
00918     Tbl res(tilde) ;
00919     for (int i=0 ; i<n-4 ; i++)
00920         res.set(i) = (tilde(i)+tilde(i+1)) ;
00921    return res ;
00922 }
00923 
00924 
00925         //----------------------------
00926            //- Routine a appeler        ---
00927           //------------------------------
00928 
00929 Tbl combinaison (const Tbl &source, int puis, int base_r) {
00930     
00931         // Routines de derivation
00932     static Tbl (*combinaison[MAX_BASE])(const Tbl &, int) ;
00933     static int nap = 0 ;
00934 
00935         // Premier appel
00936     if (nap==0) {
00937     nap = 1 ;
00938     for (int i=0 ; i<MAX_BASE ; i++) {
00939         combinaison[i] = _cl_pas_prevu ;
00940     }
00941         // Les routines existantes
00942     combinaison[R_CHEB >> TRA_R] = _cl_r_cheb ;
00943     combinaison[R_CHEBU >> TRA_R] = _cl_r_chebu ;
00944     combinaison[R_CHEBP >> TRA_R] = _cl_r_chebp ;
00945     combinaison[R_CHEBI >> TRA_R] = _cl_r_chebi ;
00946     combinaison[R_JACO02 >> TRA_R] = _cl_r_jaco02 ;
00947     }
00948     
00949     Tbl res(combinaison[base_r](source, puis)) ;
00950     return res ;
00951 }

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