LORENE
FFT991/admissible_fft.C
1 /*
2  * Determines whether a given number of points N is allowed by the
3  * Fast Fourier Transform algorithm, i.e. if
4  *
5  * N = 2^p 3^q 5^r and N >= 4, p>=1
6  *
7  */
8 
9 /*
10  * Copyright (c) 1999-2001 Eric Gourgoulhon
11  *
12  * This file is part of LORENE.
13  *
14  * LORENE is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * LORENE is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with LORENE; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29 
30 
31 
32 
33 /*
34  * $Id: admissible_fft.C,v 1.3 2016/12/05 16:18:03 j_novak Exp $
35  * $Log: admissible_fft.C,v $
36  * Revision 1.3 2016/12/05 16:18:03 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.2 2014/10/15 12:48:19 j_novak
40  * Corrected namespace declaration.
41  *
42  * Revision 1.1 2004/12/21 17:06:01 j_novak
43  * Added all files for using fftw3.
44  *
45  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
46  * LORENE
47  *
48  * Revision 1.1 1999/11/24 16:06:52 eric
49  * Initial revision
50  *
51  *
52  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/admissible_fft.C,v 1.3 2016/12/05 16:18:03 j_novak Exp $
53  *
54  */
55 
56 namespace Lorene {
57 
58 bool admissible_fft(int n) {
59 
60  if (n < 4) {
61  return false ;
62  }
63 
64  // Division by 2
65  //--------------
66 
67  int reste = n % 2 ;
68  if (reste != 0) {
69  return false ;
70  }
71 
72  int k = n/2 ;
73 
74  while ( k % 2 == 0 ) {
75  k = k / 2 ;
76  }
77 
78  if (k == 1) return true ; // n = 2^p
79 
80  // Division by 3
81  //--------------
82 
83  while ( k % 3 == 0 ) {
84  k = k / 3 ;
85  }
86 
87  if (k == 1) return true ; // n = 2^p * 3^q
88 
89  // Division by 5
90  //--------------
91 
92  while ( k % 5 == 0 ) {
93  k = k / 5 ;
94  }
95 
96  if (k == 1) return true ; // n = 2^p * 3^q * 5^r
97 
98  return false ;
99 
100  }
101 }
Lorene prototypes.
Definition: app_hor.h:67
bool admissible_fft(int)
Checks whether or not a given number of degrees of freedom is compatible with the FFT transform...