admissible_fft.C

00001 /*
00002  * Determines whether a given number of points N is allowed by the
00003  *   Fast Fourier Transform algorithm, i.e. if
00004  *  
00005  *      N = 2^p 3^q 5^r  and N >= 4, p>=1
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char admissible_fft_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/admissible_fft.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $" ;
00032 
00033 /*
00034  * $Id: admissible_fft.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $
00035  * $Log: admissible_fft.C,v $
00036  * Revision 1.1  2004/12/21 17:06:01  j_novak
00037  * Added all files for using fftw3.
00038  *
00039  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00040  * LORENE
00041  *
00042  * Revision 1.1  1999/11/24  16:06:52  eric
00043  * Initial revision
00044  *
00045  *
00046  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/FFT991/admissible_fft.C,v 1.1 2004/12/21 17:06:01 j_novak Exp $
00047  *
00048  */
00049  
00050 bool admissible_fft(int n) {
00051      
00052     if (n < 4) {
00053     return false ; 
00054     }
00055 
00056      // Division by 2
00057      //--------------
00058      
00059     int reste = n % 2 ; 
00060     if (reste != 0) {
00061     return false ; 
00062     }
00063      
00064     int k = n/2 ; 
00065      
00066     while ( k % 2 == 0 ) {
00067     k = k / 2 ;  
00068     }
00069 
00070     if (k == 1) return true ;       // n = 2^p 
00071 
00072     // Division by 3
00073     //--------------
00074      
00075     while ( k % 3 == 0 ) {
00076     k = k / 3 ;  
00077     }
00078      
00079     if (k == 1) return true ;       // n = 2^p * 3^q 
00080      
00081     // Division by 5
00082     //--------------
00083      
00084     while ( k % 5 == 0 ) {
00085     k = k / 5 ;  
00086     }
00087      
00088     if (k == 1) return true ;       // n = 2^p * 3^q * 5^r 
00089 
00090     return false ; 
00091 
00092  }

Generated on Tue Feb 7 01:35:14 2012 for LORENE by  doxygen 1.4.6