| 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 |
char cheb_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/cheb_ini.C,v 1.6 2014/10/13 08:53:11 j_novak Exp $" ; |
| 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.6 2014/10/13 08:53:11 j_novak Exp $ |
| 38 |
* $Log: cheb_ini.C,v $ |
| 39 |
* Revision 1.6 2014/10/13 08:53:11 j_novak |
| 40 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 41 |
* |
| 42 |
* Revision 1.5 2014/10/06 15:16:01 j_novak |
| 43 |
* Modified #include directives to use c++ syntax. |
| 44 |
* |
| 45 |
* Revision 1.4 2005/02/18 13:14:12 j_novak |
| 46 |
* Changing of malloc/free to new/delete + suppression of some unused variables |
| 47 |
* (trying to avoid compilation warnings). |
| 48 |
* |
| 49 |
* Revision 1.3 2003/01/31 10:31:23 e_gourgoulhon |
| 50 |
* Suppressed the directive #include <malloc.h> for malloc is defined |
| 51 |
* in <stdlib.h> |
| 52 |
* |
| 53 |
* Revision 1.2 2002/10/16 14:36:53 j_novak |
| 54 |
* Reorganization of #include instructions of standard C++, in order to |
| 55 |
* use experimental version 3 of gcc. |
| 56 |
* |
| 57 |
* Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon |
| 58 |
* LORENE |
| 59 |
* |
| 60 |
* Revision 2.1 1999/11/24 16:16:25 eric |
| 61 |
* Modif affichage. |
| 62 |
* |
| 63 |
* Revision 2.0 1999/02/22 15:44:22 hyc |
| 64 |
* *** empty log message *** |
| 65 |
* |
| 66 |
* |
| 67 |
* $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/cheb_ini.C,v 1.6 2014/10/13 08:53:11 j_novak Exp $ |
| 68 |
* |
| 69 |
*/ |
| 70 |
|
| 71 |
// headers du C |
| 72 |
#include <cmath> |
| 73 |
#include <cstdlib> |
| 74 |
|
| 75 |
#include "headcpp.h" |
| 76 |
|
| 77 |
// Variables externes de loch |
| 78 |
//int loch_cheb_ini = 0 ; |
| 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 |
// Cette routine est entierement critique |
| 95 |
//#pragma critical (loch_cheb_ini) |
| 96 |
{ |
| 97 |
|
| 98 |
// Ce nombre de points a-t-il deja ete utilise ? |
| 99 |
indice = -1 ; |
| 100 |
int i ; |
| 101 |
for ( i=0 ; i < nwork ; i++ ) { |
| 102 |
if ( tbn[i] == n ) indice = i ; |
| 103 |
} |
| 104 |
|
| 105 |
// Initialisation |
| 106 |
if (indice == -1) { /* Il faut une nouvelle initialisation */ |
| 107 |
if ( nwork >= NMAX ) { |
| 108 |
cout << "cheb_ini : nwork >= NMAX !" << endl ; |
| 109 |
abort() ; |
| 110 |
} |
| 111 |
indice = nwork ; nwork++ ; tbn[indice] = n ; |
| 112 |
|
| 113 |
int nm1s2 = (n-1) / 2 ; |
| 114 |
table_sin[indice] = new double[nm1s2] ; |
| 115 |
|
| 116 |
double xx = M_PI / double(n-1); |
| 117 |
for ( i = 0; i < nm1s2 ; i++ ) { |
| 118 |
table_sin[indice][i] = sin( xx * i ); |
| 119 |
} |
| 120 |
} |
| 121 |
} // Fin de la region critique |
| 122 |
|
| 123 |
// Valeurs de retour |
| 124 |
return table_sin[indice] ; |
| 125 |
|
| 126 |
} |
| 127 |
} |