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
31char admissible_fft_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/admissible_fft.C,v 1.2 2014/10/15 12:48:19 j_novak Exp $" ;
32
33/*
34 * $Id: admissible_fft.C,v 1.2 2014/10/15 12:48:19 j_novak Exp $
35 * $Log: admissible_fft.C,v $
36 * Revision 1.2 2014/10/15 12:48:19 j_novak
37 * Corrected namespace declaration.
38 *
39 * Revision 1.1 2004/12/21 17:06:01 j_novak
40 * Added all files for using fftw3.
41 *
42 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
43 * LORENE
44 *
45 * Revision 1.1 1999/11/24 16:06:52 eric
46 * Initial revision
47 *
48 *
49 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/admissible_fft.C,v 1.2 2014/10/15 12:48:19 j_novak Exp $
50 *
51 */
52
53namespace Lorene {
54
55bool admissible_fft(int n) {
56
57 if (n < 4) {
58 return false ;
59 }
60
61 // Division by 2
62 //--------------
63
64 int reste = n % 2 ;
65 if (reste != 0) {
66 return false ;
67 }
68
69 int k = n/2 ;
70
71 while ( k % 2 == 0 ) {
72 k = k / 2 ;
73 }
74
75 if (k == 1) return true ; // n = 2^p
76
77 // Division by 3
78 //--------------
79
80 while ( k % 3 == 0 ) {
81 k = k / 3 ;
82 }
83
84 if (k == 1) return true ; // n = 2^p * 3^q
85
86 // Division by 5
87 //--------------
88
89 while ( k % 5 == 0 ) {
90 k = k / 5 ;
91 }
92
93 if (k == 1) return true ; // n = 2^p * 3^q * 5^r
94
95 return false ;
96
97 }
98}
Lorene prototypes.
Definition app_hor.h:64