LORENE
cheb_ini.C
1 /*
2  * Copyright (c) 1999-2001 Eric Gourgoulhon
3  *
4  * This file is part of LORENE.
5  *
6  * LORENE is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * LORENE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with LORENE; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 
24 
25 /*
26  * Routine de calcul des sin(psi) pour les transformations de Tchebyshev
27  * (psi decrivant uniformement l'intervalle [0, pi]).
28  *
29  * Entree:
30  * n nombre de degres de liberte
31  * Sortie:
32  * chebf_ini pointeur double* sur la table des sinus
33  *
34  */
35 
36 /*
37  * $Id: cheb_ini.C,v 1.7 2016/12/05 16:18:01 j_novak Exp $
38  * $Log: cheb_ini.C,v $
39  * Revision 1.7 2016/12/05 16:18:01 j_novak
40  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
41  *
42  * Revision 1.6 2014/10/13 08:53:11 j_novak
43  * Lorene classes and functions now belong to the namespace Lorene.
44  *
45  * Revision 1.5 2014/10/06 15:16:01 j_novak
46  * Modified #include directives to use c++ syntax.
47  *
48  * Revision 1.4 2005/02/18 13:14:12 j_novak
49  * Changing of malloc/free to new/delete + suppression of some unused variables
50  * (trying to avoid compilation warnings).
51  *
52  * Revision 1.3 2003/01/31 10:31:23 e_gourgoulhon
53  * Suppressed the directive #include <malloc.h> for malloc is defined
54  * in <stdlib.h>
55  *
56  * Revision 1.2 2002/10/16 14:36:53 j_novak
57  * Reorganization of #include instructions of standard C++, in order to
58  * use experimental version 3 of gcc.
59  *
60  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
61  * LORENE
62  *
63  * Revision 2.1 1999/11/24 16:16:25 eric
64  * Modif affichage.
65  *
66  * Revision 2.0 1999/02/22 15:44:22 hyc
67  * *** empty log message ***
68  *
69  *
70  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/cheb_ini.C,v 1.7 2016/12/05 16:18:01 j_novak Exp $
71  *
72  */
73 
74 // headers du C
75 #include <cmath>
76 #include <cstdlib>
77 
78 #include "headcpp.h"
79 
80 //---------------------------------------------------------------------------------
81 
82 namespace Lorene {
83 double* cheb_ini(const int n )
84 {
85 
86 // Variables locales statiques
87 // ---------------------------
88 #define NMAX 30 /* Nombre maximun de dimensions differentes */
89 static double* table_sin[NMAX] ; /* Tableau des pointeurs sur les tableaux */
90 static int nwork = 0 ; /* Nombre de tableaux deja initialises */
91 static int tbn[NMAX] ; /* Tableau des points deja initialises */
92 int indice ;
93 
94 {
95  // Ce nombre de points a-t-il deja ete utilise ?
96  indice = -1 ;
97  int i ;
98  for ( i=0 ; i < nwork ; i++ ) {
99  if ( tbn[i] == n ) indice = i ;
100  }
101 
102  // Initialisation
103  if (indice == -1) { /* Il faut une nouvelle initialisation */
104  if ( nwork >= NMAX ) {
105  cout << "cheb_ini : nwork >= NMAX !" << endl ;
106  abort() ;
107  }
108  indice = nwork ; nwork++ ; tbn[indice] = n ;
109 
110  int nm1s2 = (n-1) / 2 ;
111  table_sin[indice] = new double[nm1s2] ;
112 
113  double xx = M_PI / double(n-1);
114  for ( i = 0; i < nm1s2 ; i++ ) {
115  table_sin[indice][i] = sin( xx * i );
116  }
117  }
118  } // Fin de la region critique
119 
120  // Valeurs de retour
121  return table_sin[indice] ;
122 
123 }
124 }
Lorene prototypes.
Definition: app_hor.h:67
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72