cheb_ini.C

00001 /*
00002  *   Copyright (c) 1999-2001 Eric Gourgoulhon
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 cheb_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/cheb_ini.C,v 1.4 2005/02/18 13:14:12 j_novak Exp $" ;
00024 
00025 /* 
00026  * Routine de calcul des sin(psi) pour les transformations de Tchebyshev
00027  *   (psi decrivant uniformement l'intervalle [0, pi]). 
00028  *
00029  * Entree:
00030  *   n      nombre de degres de liberte
00031  * Sortie:
00032  *   chebf_ini  pointeur double* sur la table des sinus
00033  *
00034  */
00035 
00036 /*
00037  * $Id: cheb_ini.C,v 1.4 2005/02/18 13:14:12 j_novak Exp $
00038  * $Log: cheb_ini.C,v $
00039  * Revision 1.4  2005/02/18 13:14:12  j_novak
00040  * Changing of malloc/free to new/delete + suppression of some unused variables
00041  * (trying to avoid compilation warnings).
00042  *
00043  * Revision 1.3  2003/01/31 10:31:23  e_gourgoulhon
00044  * Suppressed the directive #include <malloc.h> for malloc is defined
00045  * in <stdlib.h>
00046  *
00047  * Revision 1.2  2002/10/16 14:36:53  j_novak
00048  * Reorganization of #include instructions of standard C++, in order to
00049  * use experimental version 3 of gcc.
00050  *
00051  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00052  * LORENE
00053  *
00054  * Revision 2.1  1999/11/24  16:16:25  eric
00055  * Modif affichage.
00056  *
00057  * Revision 2.0  1999/02/22  15:44:22  hyc
00058  * *** empty log message ***
00059  *
00060  *
00061  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/cheb_ini.C,v 1.4 2005/02/18 13:14:12 j_novak Exp $
00062  *
00063  */
00064 
00065 // headers du C
00066 #include <math.h>
00067 #include <stdlib.h>
00068 
00069 #include "headcpp.h"
00070 
00071 // Variables externes de loch
00072 //int loch_cheb_ini = 0 ;
00073 
00074 //---------------------------------------------------------------------------------
00075 
00076 double* cheb_ini(const int n )
00077 {
00078 
00079 // Variables locales statiques
00080 // ---------------------------
00081 #define NMAX    30          /* Nombre maximun de dimensions differentes */
00082 static  double* table_sin[NMAX] ;   /* Tableau des pointeurs sur les tableaux */
00083 static  int nwork = 0 ;     /* Nombre de tableaux deja initialises */
00084 static  int tbn[NMAX] ;     /* Tableau des points deja initialises */
00085 int indice ;
00086 
00087 // Cette routine est entierement critique
00088 //#pragma critical (loch_cheb_ini)
00089 {
00090 
00091     // Ce nombre de points a-t-il deja ete utilise ?
00092     indice = -1 ;
00093     int i ;
00094     for ( i=0 ; i < nwork ; i++ ) {
00095     if ( tbn[i] == n ) indice = i ;
00096     }
00097 
00098     // Initialisation
00099     if (indice == -1) {         /* Il faut une nouvelle initialisation */
00100     if ( nwork >= NMAX ) {
00101         cout << "cheb_ini : nwork >= NMAX !" << endl ; 
00102         abort() ; 
00103     }
00104     indice = nwork ; nwork++ ; tbn[indice] = n ;
00105 
00106     int nm1s2 = (n-1) / 2 ;         
00107     table_sin[indice] = new double[nm1s2] ; 
00108 
00109     double xx = M_PI / double(n-1);
00110     for ( i = 0; i < nm1s2 ; i++ ) {
00111         table_sin[indice][i] = sin( xx * i );
00112         }
00113     }
00114     }   // Fin de la region critique
00115 
00116     // Valeurs de retour
00117     return table_sin[indice] ;
00118     
00119 }

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