som_r.C

00001 /*
00002  *   Copyright (c) 1999-2000 Jean-Alain Marck
00003  *   Copyright (c) 1999-2001 Philippe Grandclement
00004  *   Copyright (c) 1999-2002 Eric Gourgoulhon
00005  *
00006  *   This file is part of LORENE.
00007  *
00008  *   LORENE is free software; you can redistribute it and/or modify
00009  *   it under the terms of the GNU General Public License as published by
00010  *   the Free Software Foundation; either version 2 of the License, or
00011  *   (at your option) any later version.
00012  *
00013  *   LORENE is distributed in the hope that it will be useful,
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *   GNU General Public License for more details.
00017  *
00018  *   You should have received a copy of the GNU General Public License
00019  *   along with LORENE; if not, write to the Free Software
00020  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 
00025 char som_r_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_r.C,v 1.8 2008/08/27 08:50:10 jl_cornou Exp $" ;
00026 
00027 /*
00028  * Ensemble des routine pour la sommation directe en r
00029  * 
00030  *   SYNOPSYS:
00031  *     double som_r_XX
00032  *  (double* ti, int nr, int nt, int np, double x, double* trtp)
00033  *
00034  *     x est l'argument du polynome de Chebychev: x in [0, 1] ou x in [-1, 1]
00035  * 
00036  *   ATTENTION: np est suppose etre le nombre de points (sans le +2)
00037  *      on suppose que trtp tient compte de ca.
00038  */
00039 
00040 
00041 /*
00042  * $Id: som_r.C,v 1.8 2008/08/27 08:50:10 jl_cornou Exp $
00043  * $Log: som_r.C,v $
00044  * Revision 1.8  2008/08/27 08:50:10  jl_cornou
00045  * Added Jacobi(0,2) polynomials
00046  *
00047  * Revision 1.7  2007/12/11 15:28:18  jl_cornou
00048  * Jacobi(0,2) polynomials partially implemented
00049  *
00050  * Revision 1.6  2006/05/17 13:15:19  j_novak
00051  * Added a test for the pure angular grid case (nr=1), in the shell.
00052  *
00053  * Revision 1.5  2005/02/18 13:14:17  j_novak
00054  * Changing of malloc/free to new/delete + suppression of some unused variables
00055  * (trying to avoid compilation warnings).
00056  *
00057  * Revision 1.4  2004/11/23 15:16:02  m_forot
00058  *
00059  * Added the bases for the cases without any equatorial symmetry
00060  *  (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
00061  *
00062  * Revision 1.3  2002/10/16 14:36:59  j_novak
00063  * Reorganization of #include instructions of standard C++, in order to
00064  * use experimental version 3 of gcc.
00065  *
00066  * Revision 1.2  2002/05/05 16:20:40  e_gourgoulhon
00067  * Error message (in unknwon basis case) in English
00068  * Added the basis T_COSSIN_SP
00069  *
00070  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00071  * LORENE
00072  *
00073  * Revision 2.4  2000/03/06  09:34:21  eric
00074  * Suppression des #include inutiles.
00075  *
00076  * Revision 2.3  1999/04/28  12:11:15  phil
00077  * changements de sommations
00078  *
00079  * Revision 2.2  1999/04/26  14:26:31  phil
00080  * remplacement des malloc en new
00081  *
00082  * Revision 2.1  1999/04/13  14:44:06  phil
00083  * ajout de som_r_chebi
00084  *
00085  * Revision 2.0  1999/04/12  15:42:33  phil
00086  * *** empty log message ***
00087  *
00088  * Revision 1.1  1999/04/12  15:40:25  phil
00089  * Initial revision
00090  *
00091  *
00092  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/som_r.C,v 1.8 2008/08/27 08:50:10 jl_cornou Exp $
00093  *
00094  */
00095 // Headers C
00096 #include <stdlib.h>
00097 
00098 #include "headcpp.h"
00099 #include "proto.h"
00100             //-------------------
00101             //- Cas Non-Prevu ---
00102             //-------------------
00103 
00104 void som_r_pas_prevu
00105     (double*, const int, const int, const int, const double, double*) {
00106     cout << "Mtbl_cf::val_point: r basis not implemented yet !"
00107          << endl ;
00108     abort() ;
00109 }
00110 
00111             //----------------
00112             //- Cas R_CHEB ---
00113             //----------------
00114 
00115 void som_r_cheb
00116     (double* ti, const int nr, const int nt, const int np, const double x, 
00117     double* trtp) {
00118 
00119 // Variables diverses
00120 int i, j, k ;
00121 double* pi = ti ;       // pointeur courant sur l'entree
00122 double* po = trtp ;     // pointeur courant sur la sortie
00123     
00124     // Valeurs des polynomes de Chebyshev au point x demande
00125     double* cheb = new double [nr] ;
00126     cheb[0] = 1. ;
00127     if (nr > 1) cheb[1] = x ;
00128     for (i=2; i<nr; i++) {
00129     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00130     }
00131     
00132     // Sommation pour le premier phi, k=0
00133     for (j=0 ; j<nt ; j++) {
00134     *po = 0 ;
00135     // Sommation sur r
00136     for (i=0 ; i<nr ; i++) {
00137         *po += (*pi) * cheb[i] ;
00138         pi++ ;  // R suivant
00139     }
00140     po++ ;      // Theta suivant
00141     }
00142     
00143     if (np > 1) {   
00144 
00145     // On saute le deuxieme phi (sin(0)), k=1
00146     pi += nr*nt ;
00147     po += nt ;
00148     
00149     // Sommation sur les phi suivants (pour k=2,...,np)
00150     for (k=2 ; k<np+1 ; k++) {
00151     for (j=0 ; j<nt ; j++) {
00152         // Sommation sur r
00153         *po = 0 ;
00154         for (i=0 ; i<nr ; i++) {
00155         *po += (*pi) * cheb[i] ;
00156         pi++ ;  // R suivant
00157         }
00158         po++ ;  // Theta suivant
00159     }
00160     }
00161     
00162     }   // fin du cas np > 1 
00163 
00164     // Menage
00165     delete [] cheb ;
00166 
00167 }
00168 
00169 
00170             //-----------------
00171             //- Cas R_CHEBP ---
00172             //-----------------
00173 
00174 void som_r_chebp
00175     (double* ti, const int nr, const int nt, const int np, const double x, 
00176     double* trtp) {
00177 
00178 // Variables diverses
00179 int i, j, k ;
00180 double* pi = ti ;       // pointeur courant sur l'entree
00181 double* po = trtp ;     // pointeur courant sur la sortie
00182     
00183     // Valeurs des polynomes de Chebyshev au point x demande
00184     double* cheb = new double [nr] ;
00185     cheb[0] = 1. ;
00186     double t2im1 = x ;
00187     for (i=1; i<nr; i++) {
00188     cheb[i] = 2*x* t2im1 - cheb[i-1] ;
00189     t2im1 = 2*x* cheb[i] - t2im1 ;      
00190     }
00191     
00192     // Sommation pour le premier phi, k=0
00193     for (j=0 ; j<nt ; j++) {
00194     *po = 0 ;
00195     // Sommation sur r
00196     for (i=0 ; i<nr ; i++) {
00197         *po += (*pi) * cheb[i] ;
00198         pi++ ;  // R suivant
00199     }
00200     po++ ;      // Theta suivant
00201     }
00202     
00203     if (np > 1) {   
00204 
00205     // On saute le deuxieme phi (sin(0)), k=1
00206     pi += nr*nt ;
00207     po += nt ;
00208     
00209     // Sommation sur les phi suivants (pour k=2,...,np)
00210     for (k=2 ; k<np+1 ; k++) {
00211     for (j=0 ; j<nt ; j++) {
00212         // Sommation sur r
00213         *po = 0 ;
00214         for (i=0 ; i<nr ; i++) {
00215         *po += (*pi) * cheb[i] ;
00216         pi++ ;  // R suivant
00217         }
00218         po++ ;  // Theta suivant
00219     }
00220     }
00221 
00222     }   // fin du cas np > 1 
00223     // Menage
00224     delete [] cheb ;
00225 
00226 }
00227 
00228 
00229             //-----------------
00230             //- Cas R_CHEBI ---
00231             //-----------------
00232 
00233 void som_r_chebi
00234     (double* ti, const int nr, const int nt, const int np, const double x, 
00235     double* trtp) {
00236 
00237 // Variables diverses
00238 int i, j, k ;
00239 double* pi = ti ;       // pointeur courant sur l'entree
00240 double* po = trtp ;     // pointeur courant sur la sortie
00241     
00242     // Valeurs des polynomes de Chebyshev au point x demande
00243     double* cheb = new double [nr] ;
00244     cheb[0] = x ;
00245     double t2im1 = 1. ;
00246     for (i=1; i<nr; i++) {
00247     t2im1 = 2*x* cheb[i-1] - t2im1 ;
00248     cheb[i] = 2*x* t2im1 - cheb[i-1] ;      
00249     }
00250     
00251     // Sommation pour le premier phi, k=0
00252     for (j=0 ; j<nt ; j++) {
00253     *po = 0 ;
00254     // Sommation sur r
00255     for (i=0 ; i<nr ; i++) {
00256         *po += (*pi) * cheb[i] ;
00257         pi++ ;  // R suivant
00258     }
00259     po++ ;      // Theta suivant
00260     }
00261     
00262     if (np > 1) {   
00263 
00264     // On saute le deuxieme phi (sin(0)), k=1
00265     pi += nr*nt ;
00266     po += nt ;
00267     
00268     // Sommation sur les phi suivants (pour k=2,...,np)
00269     for (k=2 ; k<np+1 ; k++) {
00270     for (j=0 ; j<nt ; j++) {
00271         // Sommation sur r
00272         *po = 0 ;
00273         for (i=0 ; i<nr ; i++) {
00274         *po += (*pi) * cheb[i] ;
00275         pi++ ;  // R suivant
00276         }
00277         po++ ;  // Theta suivant
00278     }
00279     }
00280 
00281     }   // fin du cas np > 1 
00282     // Menage
00283    delete [] cheb ;
00284 
00285 }
00286             //-----------------
00287             //- Cas R_CHEBU ---
00288             //-----------------
00289 
00290 void som_r_chebu
00291     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00292 
00293 // Variables diverses
00294 int i, j, k ;
00295 double* pi = ti ;       // pointeur courant sur l'entree
00296 double* po = trtp ;     // pointeur courant sur la sortie
00297     
00298     // Valeurs des polynomes de Chebyshev au point x demande
00299     double* cheb = new double [nr] ;
00300     cheb[0] = 1. ;
00301     cheb[1] = x ;
00302     for (i=2; i<nr; i++) {
00303     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00304     }
00305     
00306     // Sommation pour le premier phi, k=0
00307     for (j=0 ; j<nt ; j++) {
00308     *po = 0 ;
00309     // Sommation sur r
00310     for (i=0 ; i<nr ; i++) {
00311         *po += (*pi) * cheb[i] ;
00312         pi++ ;  // R suivant
00313     }
00314     po++ ;      // Theta suivant
00315     }
00316     
00317     if (np > 1) {   
00318 
00319     // On saute le deuxieme phi (sin(0)), k=1
00320     pi += nr*nt ;
00321     po += nt ;
00322     
00323     // Sommation sur les phi suivants (pour k=2,...,np)
00324     for (k=2 ; k<np+1 ; k++) {
00325     for (j=0 ; j<nt ; j++) {
00326         // Sommation sur r
00327         *po = 0 ;
00328         for (i=0 ; i<nr ; i++) {
00329         *po += (*pi) * cheb[i] ;
00330         pi++ ;  // R suivant
00331         }
00332         po++ ;  // Theta suivant
00333     }
00334     }
00335 
00336     }   // fin du cas np > 1 
00337     // Menage
00338     delete [] cheb ;
00339 }
00340 
00341             //----------------------
00342             //  Cas R_CHEBPIM_P ---
00343             //---------------------
00344 
00345 void som_r_chebpim_p
00346     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00347 
00348 // Variables diverses
00349 int i, j, k ;
00350 double* pi = ti ;       // pointeur courant sur l'entree
00351 double* po = trtp ;     // pointeur courant sur la sortie
00352     
00353     // Valeurs des polynomes de Chebyshev au point x demande
00354     double* cheb = new double [2*nr] ;
00355     cheb[0] = 1. ;
00356     cheb[1] = x ;
00357     for (i=2 ; i<2*nr ; i++) {
00358     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00359     }
00360     
00361     // Sommation pour le premier phi, k=0
00362     int m = 0;
00363     for (j=0 ; j<nt ; j++) {
00364     *po = 0 ;
00365     // Sommation sur r
00366     for (i=0 ; i<nr ; i++) {
00367         *po += (*pi) * cheb[2*i] ;
00368         pi++ ;  // R suivant
00369     }
00370     po++ ;      // Theta suivant
00371     }
00372     
00373     if (np > 1) {   
00374 
00375     // On saute le deuxieme phi (sin(0)), k=1
00376     pi += nr*nt ;
00377     po += nt ;
00378     
00379     // Sommation sur les phi suivants (pour k=2,...,np)
00380     for (k=2 ; k<np+1 ; k++) {
00381     m = (k/2) % 2 ;         // parite: 0 <-> 1
00382     for (j=0 ; j<nt ; j++) {
00383         // Sommation sur r
00384         *po = 0 ;
00385         for (i=0 ; i<nr ; i++) {
00386         *po += (*pi) * cheb[2*i + m] ;
00387         pi++ ;  // R suivant
00388         }
00389         po++ ;  // Theta suivant
00390     }
00391     }
00392     
00393     }   // fin du cas np > 1 
00394     // Menage
00395    delete [] cheb ;
00396     
00397 }
00398 
00399             //----------------------
00400             //- Cas R_CHEBPIM_I ----
00401             //----------------------
00402 
00403 void som_r_chebpim_i
00404     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00405 
00406 // Variables diverses
00407 int i, j, k ;
00408 double* pi = ti ;       // pointeur courant sur l'entree
00409 double* po = trtp ;     // pointeur courant sur la sortie
00410     
00411     // Valeurs des polynomes de Chebyshev au point x demande
00412     double* cheb = new double [2*nr] ;
00413     cheb[0] = 1. ;
00414     cheb[1] = x ;
00415     for (i=2 ; i<2*nr ; i++) {
00416     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00417     }
00418     
00419     // Sommation pour le premier phi, k=0
00420     int m = 0;
00421     for (j=0 ; j<nt ; j++) {
00422     *po = 0 ;
00423     // Sommation sur r
00424     for (i=0 ; i<nr ; i++) {
00425         *po += (*pi) * cheb[2*i+1] ;
00426         pi++ ;  // R suivant
00427     }
00428     po++ ;      // Theta suivant
00429     }
00430     
00431     if (np > 1) {   
00432 
00433     // On saute le deuxieme phi (sin(0)), k=1
00434     pi += nr*nt ;
00435     po += nt ;
00436     
00437     // Sommation sur les phi suivants (pour k=2,...,np)
00438     for (k=2 ; k<np+1 ; k++) {
00439     m = (k/2) % 2  ;            // parite: 0 <-> 1
00440     for (j=0 ; j<nt ; j++) {
00441         // Sommation sur r
00442         *po = 0 ;
00443         for (i=0 ; i<nr ; i++) {
00444         *po += (*pi) * cheb[2*i + 1 - m] ;
00445         pi++ ;  // R suivant
00446         }
00447         po++ ;  // Theta suivant
00448     }
00449     }
00450     
00451     }   // fin du cas np > 1 
00452     // Menage
00453     delete [] cheb ;
00454     
00455 }
00456 
00457             //----------------------
00458             //  Cas R_CHEBPI_P ---
00459             //---------------------
00460 
00461 void som_r_chebpi_p
00462     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00463 
00464 // Variables diverses
00465 int i, j, k ;
00466 double* pi = ti ;       // pointeur courant sur l'entree
00467 double* po = trtp ;     // pointeur courant sur la sortie
00468     
00469     // Valeurs des polynomes de Chebyshev au point x demande
00470     double* cheb = new double [2*nr] ;
00471     cheb[0] = 1. ;
00472     cheb[1] = x ;
00473     for (i=2 ; i<2*nr ; i++) {
00474     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00475     }
00476     
00477     // Sommation pour le premier phi, k=0
00478     for (j=0 ; j<nt ; j++) {
00479       int l = j%2;
00480       if(l==0){
00481     *po = 0 ;
00482     // Sommation sur r
00483     for (i=0 ; i<nr ; i++) {
00484       *po += (*pi) * cheb[2*i] ;
00485       pi++ ;  // R suivant
00486     }
00487     po++ ;      // Theta suivant
00488       } else {
00489     *po = 0 ;
00490     // Sommation sur r
00491     for (i=0 ; i<nr ; i++) {
00492         *po += (*pi) * cheb[2*i+1] ;
00493         pi++ ;  // R suivant
00494     }
00495     po++ ;      // Theta suivant
00496       } 
00497     }
00498     
00499     if (np > 1) {   
00500 
00501     // On saute le deuxieme phi (sin(0)), k=1
00502     pi += nr*nt ;
00503     po += nt ;
00504     
00505     // Sommation sur les phi suivants (pour k=2,...,np)
00506     for (k=2 ; k<np+1 ; k++) {
00507     for (j=0 ; j<nt ; j++) {
00508       int l = j% 2 ;            // parite: 0 <-> 1
00509         // Sommation sur r
00510         *po = 0 ;
00511         for (i=0 ; i<nr ; i++) {
00512         *po += (*pi) * cheb[2*i + l] ;
00513         pi++ ;  // R suivant
00514         }
00515         po++ ;  // Theta suivant
00516     }
00517     }
00518     
00519     }   // fin du cas np > 1 
00520     // Menage
00521    delete [] cheb ;
00522     
00523 }
00524 
00525             //----------------------
00526             //- Cas R_CHEBPI_I ----
00527             //----------------------
00528 
00529 void som_r_chebpi_i
00530     (double* ti, const int nr, const int nt, const int np, const double x, double* trtp) {
00531 
00532 // Variables diverses
00533 int i, j, k ;
00534 double* pi = ti ;       // pointeur courant sur l'entree
00535 double* po = trtp ;     // pointeur courant sur la sortie
00536     
00537     // Valeurs des polynomes de Chebyshev au point x demande
00538     double* cheb = new double [2*nr] ;
00539     cheb[0] = 1. ;
00540     cheb[1] = x ;
00541     for (i=2 ; i<2*nr ; i++) {
00542     cheb[i] = 2*x* cheb[i-1] - cheb[i-2] ;      
00543     }
00544     
00545     // Sommation pour le premier phi, k=0
00546     for (j=0 ; j<nt ; j++) {
00547       int l = j%2 ;
00548       if(l==1){
00549     *po = 0 ;
00550     // Sommation sur r
00551     for (i=0 ; i<nr ; i++) {
00552       *po += (*pi) * cheb[2*i] ;
00553       pi++ ;  // R suivant
00554     }
00555     po++ ;      // Theta suivant
00556       } else {
00557     *po = 0 ;
00558     // Sommation sur r
00559     for (i=0 ; i<nr ; i++) {
00560         *po += (*pi) * cheb[2*i+1] ;
00561         pi++ ;  // R suivant
00562     }
00563     po++ ;      // Theta suivant
00564       } 
00565     }
00566     
00567     if (np > 1) {   
00568 
00569     // On saute le deuxieme phi (sin(0)), k=1
00570     pi += nr*nt ;
00571     po += nt ;
00572     
00573     // Sommation sur les phi suivants (pour k=2,...,np)
00574     for (k=2 ; k<np+1 ; k++) {
00575       for (j=0 ; j<nt ; j++) {
00576       int l = j % 2  ;          // parite: 0 <-> 1
00577         // Sommation sur r
00578         *po = 0 ;
00579         for (i=0 ; i<nr ; i++) {
00580         *po += (*pi) * cheb[2*i + 1 - l] ;
00581         pi++ ;  // R suivant
00582         }
00583         po++ ;  // Theta suivant
00584     }
00585     }
00586     
00587     }   // fin du cas np > 1 
00588     // Menage
00589     delete [] cheb ;
00590     
00591 }
00592 
00593             //----------------
00594             //- Cas R_JACO02 -
00595             //----------------
00596 
00597 void som_r_jaco02
00598     (double* ti, const int nr, const int nt, const int np, const double x, 
00599     double* trtp) {
00600 
00601 // Variables diverses
00602 int i, j, k ;
00603 double* pi = ti ;       // pointeur courant sur l'entree
00604 double* po = trtp ;     // pointeur courant sur la sortie
00605     
00606     // Valeurs des polynomes de Jacobi(0,2) au point x demande
00607     double* jaco = jacobi(nr-1,x) ;
00608     
00609     // Sommation pour le premier phi, k=0
00610     for (j=0 ; j<nt ; j++) {
00611     *po = 0 ;
00612     // Sommation sur r
00613     for (i=0 ; i<nr ; i++) {
00614         *po += (*pi) * jaco[i] ;
00615         pi++ ;  // R suivant
00616     }
00617     po++ ;      // Theta suivant
00618     }
00619     
00620     if (np > 1) {   
00621 
00622     // On saute le deuxieme phi (sin(0)), k=1
00623     pi += nr*nt ;
00624     po += nt ;
00625     
00626     // Sommation sur les phi suivants (pour k=2,...,np)
00627     for (k=2 ; k<np+1 ; k++) {
00628     for (j=0 ; j<nt ; j++) {
00629         // Sommation sur r
00630         *po = 0 ;
00631         for (i=0 ; i<nr ; i++) {
00632         *po += (*pi) * jaco[i] ;
00633         pi++ ;  // R suivant
00634         }
00635         po++ ;  // Theta suivant
00636     }
00637     }
00638     
00639     }   // fin du cas np > 1 
00640 
00641     // Menage
00642     delete [] jaco ;
00643 
00644 }

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