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

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