LORENE
trigo_ini.C
1 /*
2  * Copyright (c) 1999-2000 Jean-Alain Marck
3  * Copyright (c) 1999-2001 Eric Gourgoulhon
4  *
5  * This file is part of LORENE.
6  *
7  * LORENE is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * LORENE is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with LORENE; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 
24 char trigo_ini_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/trigo_ini.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $" ;
25 
26 /*
27  * Routine d'initialisation des tables trigo
28  * Version speciale FAX
29  *
30  * Entree:
31  * n nombre de degres de liberte
32  * Sortie:
33  * trigo_ini pointeur double* sur la table trigo
34  *
35  * Doit etre en zone critique
36  */
37 
38 /*
39  * $Id: trigo_ini.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $
40  * $Log: trigo_ini.C,v $
41  * Revision 1.4 2014/10/15 12:48:22 j_novak
42  * Corrected namespace declaration.
43  *
44  * Revision 1.3 2014/10/13 08:53:18 j_novak
45  * Lorene classes and functions now belong to the namespace Lorene.
46  *
47  * Revision 1.2 2014/10/06 15:18:47 j_novak
48  * Modified #include directives to use c++ syntax.
49  *
50  * Revision 1.1 2004/12/21 17:06:01 j_novak
51  * Added all files for using fftw3.
52  *
53  * Revision 1.5 2003/12/19 16:21:47 j_novak
54  * Shadow hunt
55  *
56  * Revision 1.4 2003/01/31 10:31:24 e_gourgoulhon
57  * Suppressed the directive #include <malloc.h> for malloc is defined
58  * in <stdlib.h>
59  *
60  * Revision 1.3 2002/10/16 14:36:57 j_novak
61  * Reorganization of #include instructions of standard C++, in order to
62  * use experimental version 3 of gcc.
63  *
64  * Revision 1.2 2002/09/09 13:00:40 e_gourgoulhon
65  * Modification of declaration of Fortran 77 prototypes for
66  * a better portability (in particular on IBM AIX systems):
67  * All Fortran subroutine names are now written F77_* and are
68  * defined in the new file C++/Include/proto_f77.h.
69  *
70  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
71  * LORENE
72  *
73  * Revision 2.1 1999/11/24 16:23:22 eric
74  * Modif affichage.
75  *
76  * Revision 2.0 1999/02/22 15:29:33 hyc
77  * *** empty log message ***
78  *
79  *
80  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/trigo_ini.C,v 1.4 2014/10/15 12:48:22 j_novak Exp $
81  *
82  */
83 
84 // headers du C
85 #include <cmath>
86 #include <cstdlib>
87 
88 // Prototypes of F77 subroutines
89 #include "headcpp.h"
90 #include "proto_f77.h"
91 
92 namespace Lorene {
93 double *trigo_ini( int n )
94 {
95 // Variables locales statiques
96 // ---------------------------
97 #define NMAX 30 /* Nombre maximun de dimensions differentes */
98 static double *table_trigo[NMAX] ; /* Tableau des pointeurs sur les tableaux */
99 static int nwork = 0 ; /* Nombre de tableaux deja initialises */
100 static int tbn[NMAX] ; /* Tableau des points deja initialises */
101 static int trois = 3 ;
102 int indice ;
103 
104 {
105  // Ce nombre de points a-t-il deja ete utilise ?
106  indice = -1 ;
107  int i ;
108  for ( i=0 ; i < nwork ; i++ ) {
109  if ( tbn[i] == n ) indice = i ;
110  }
111 
112  // Initialisation
113  if (indice == -1) { /* Il faut une nouvelle initialisation */
114  if ( nwork >= NMAX ) {
115  cout << "trigo_ini : nwork >= NMAX !" << endl ;
116  abort() ;
117  }
118  indice = nwork ; nwork++ ; tbn[indice] = n ;
119 
120 // table_trigo[indice] = new double[3*n/2 + 1] ;
121  table_trigo[indice] = (double *) malloc( sizeof(double) * (3*n/2 + 1) ) ;
122  if ( table_trigo[indice] == 0 ) {
123  cout << "trigo_ini : malloc error !" << endl ;
124  abort() ;
125  }
126 
127  F77_fftrig( table_trigo[indice], &n, &trois ) ;
128  }
129 
130  } // Fin de zone critique
131 
132  // Valeurs de retour
133  return table_trigo[indice] ;
134 }
135 }
Lorene
Lorene prototypes.
Definition: app_hor.h:64