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
23
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.7 2016/12/05 16:18:01 j_novak Exp $
49 * $Log: chebimp_ini.C,v $
50 * Revision 1.7 2016/12/05 16:18:01 j_novak
51 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
52 *
53 * Revision 1.6 2014/10/13 08:53:11 j_novak
54 * Lorene classes and functions now belong to the namespace Lorene.
55 *
56 * Revision 1.5 2014/10/06 15:16:01 j_novak
57 * Modified #include directives to use c++ syntax.
58 *
59 * Revision 1.4 2005/02/18 13:14:12 j_novak
60 * Changing of malloc/free to new/delete + suppression of some unused variables
61 * (trying to avoid compilation warnings).
62 *
63 * Revision 1.3 2003/01/31 10:31:23 e_gourgoulhon
64 * Suppressed the directive #include <malloc.h> for malloc is defined
65 * in <stdlib.h>
66 *
67 * Revision 1.2 2002/10/16 14:36:53 j_novak
68 * Reorganization of #include instructions of standard C++, in order to
69 * use experimental version 3 of gcc.
70 *
71 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
72 * LORENE
73 *
74 * Revision 2.1 1999/11/24 16:18:29 eric
75 * Modif affichage.
76 *
77 * Revision 2.0 1999/02/22 15:44:12 hyc
78 * *** empty log message ***
79 *
80 *
81 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chebimp_ini.C,v 1.7 2016/12/05 16:18:01 j_novak Exp $
82 *
83 */
84
85// headers du C
86#include <cassert>
87#include <cmath>
88#include <cstdlib>
89
90#include "headcpp.h"
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 {
108 // Ce nombre de points a-t-il deja ete utilise ?
109 indice = -1 ;
110 int i ;
111 for ( i=0 ; i < nwork ; i++ ) {
112 if ( tbn[i] == n ) indice = i ;
113 }
114
115 // Initialisation
116 if (indice == -1) { /* Il faut une nouvelle initialisation */
117 if ( nwork >= NMAX ) {
118 cout << "chebimp_ini: nwork > NMAX : "
119 << nwork << " <-> " << NMAX << endl ;
120 abort () ;
121 }
122 indice = nwork ; nwork++ ; tbn[indice] = n ;
123
124 table_x[indice] = new double[n] ;
125
126 double xx = M_PI / double(2*(n-1));
127 for ( i = 0; i < n ; i++ ) {
128 table_x[indice][i] = sin( xx * i );
129 }
130 }
131
132 } // Fin de la zone critique
133
134 // Valeurs de retour
135 return table_x[indice] ;
136
137}
138}
Cmp sin(const Cmp &)
Sine.
Definition cmp_math.C:72
Lorene prototypes.
Definition app_hor.h:67