LORENE
chebimp_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
23char chebimp_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chebimp_ini.C,v 1.6 2014/10/13 08:53:11 j_novak Exp $" ;
24
25
26/*
27 * Routine de calcul des points de collocations
28 *
29 * x_i = sin( pi/2 i/(n-1) ) 0 <= i <= n-1
30 *
31 * des echantillonnages de [0, 1] rarefies en 0.
32 * Ces valeurs sont notamment utilisees pour les transformations de Tchebyshev
33 * impaires.
34 *
35 *
36 * Entree:
37 * -------
38 * const int n : nombre de degres de liberte
39 *
40 * Sortie:
41 * -------
42 * double* chebimp_ini : pointeur sur la table des points de collocation
43 * L'espace memoire correspondant a ce pointeur
44 * est alloue par la routine.
45 */
46
47/*
48 * $Id: chebimp_ini.C,v 1.6 2014/10/13 08:53:11 j_novak Exp $
49 * $Log: chebimp_ini.C,v $
50 * Revision 1.6 2014/10/13 08:53:11 j_novak
51 * Lorene classes and functions now belong to the namespace Lorene.
52 *
53 * Revision 1.5 2014/10/06 15:16:01 j_novak
54 * Modified #include directives to use c++ syntax.
55 *
56 * Revision 1.4 2005/02/18 13:14:12 j_novak
57 * Changing of malloc/free to new/delete + suppression of some unused variables
58 * (trying to avoid compilation warnings).
59 *
60 * Revision 1.3 2003/01/31 10:31:23 e_gourgoulhon
61 * Suppressed the directive #include <malloc.h> for malloc is defined
62 * in <stdlib.h>
63 *
64 * Revision 1.2 2002/10/16 14:36:53 j_novak
65 * Reorganization of #include instructions of standard C++, in order to
66 * use experimental version 3 of gcc.
67 *
68 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
69 * LORENE
70 *
71 * Revision 2.1 1999/11/24 16:18:29 eric
72 * Modif affichage.
73 *
74 * Revision 2.0 1999/02/22 15:44:12 hyc
75 * *** empty log message ***
76 *
77 *
78 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chebimp_ini.C,v 1.6 2014/10/13 08:53:11 j_novak Exp $
79 *
80 */
81
82// headers du C
83#include <cassert>
84#include <cmath>
85#include <cstdlib>
86
87#include "headcpp.h"
88
89// Variable externe de loch
90//int loch_chebimp_ini = 0 ;
91
92namespace Lorene {
93//*****************************************************************************
94
95double* chebimp_ini(const int n )
96{
97
98// Variables locales statiques
99// ---------------------------
100#define NMAX 30 /* Nombre maximun de dimensions differentes */
101static double* table_x[NMAX] ; /* Tableau des pointeurs sur les tableaux */
102static int nwork = 0 ; /* Nombre de tableaux deja initialises */
103static int tbn[NMAX] ; /* Tableau des points deja initialises */
104int indice ;
105
106 // Mise en zone critique de toute la routine
107// #pragma critical (loch_chebimp_ini)
108 {
109 // Ce nombre de points a-t-il deja ete utilise ?
110 indice = -1 ;
111 int i ;
112 for ( i=0 ; i < nwork ; i++ ) {
113 if ( tbn[i] == n ) indice = i ;
114 }
115
116 // Initialisation
117 if (indice == -1) { /* Il faut une nouvelle initialisation */
118 if ( nwork >= NMAX ) {
119 cout << "chebimp_ini: nwork > NMAX : "
120 << nwork << " <-> " << NMAX << endl ;
121 abort () ;
122 }
123 indice = nwork ; nwork++ ; tbn[indice] = n ;
124
125 table_x[indice] = new double[n] ;
126
127 double xx = M_PI / double(2*(n-1));
128 for ( i = 0; i < n ; i++ ) {
129 table_x[indice][i] = sin( xx * i );
130 }
131 }
132
133 } // Fin de la zone critique
134
135 // Valeurs de retour
136 return table_x[indice] ;
137
138}
139}
Cmp sin(const Cmp &)
Sine.
Definition cmp_math.C:69
Lorene prototypes.
Definition app_hor.h:64