OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Static Public Member Functions | Static Public Attributes | List of all members
FFT_Controller Class Reference

#include <newmatap.h>

Static Public Member Functions

static bool ar_1d_ft (int PTS, Real *X, Real *Y)
 
static bool CanFactor (int PTS)
 

Static Public Attributes

static bool OnlyOldFFT
 

Detailed Description

Definition at line 106 of file newmatap.h.

Member Function Documentation

◆ ar_1d_ft()

bool FFT_Controller::ar_1d_ft ( int  PTS,
Real *  X,
Real *  Y 
)
static

Definition at line 146 of file newfft.cpp.

References REPORT, and square().

Referenced by FFT().

147 {
148 // ARBITRARY RADIX ONE DIMENSIONAL FOURIER TRANSFORM
149 
150  REPORT
151 
152  int F,J,N,NF,P,PMAX,P_SYM,P_TWO,Q,R,TWO_GRP;
153 
154  // NP is maximum number of squared factors allows PTS up to 2**32 at least
155  // NQ is number of not-squared factors - increase if we increase PMAX
156  const int NP = 16, NQ = 10;
157  SimpleIntArray PP(NP), QQ(NQ);
158 
159  TWO_GRP=16; PMAX=19;
160 
161  // PMAX is the maximum factor size
162  // TWO_GRP is the maximum power of 2 handled as a single factor
163  // Doesn't take advantage of combining powers of 2 when calculating
164  // number of factors
165 
166  if (PTS<=1) return true;
167  N=PTS; P_SYM=1; F=2; P=0; Q=0;
168 
169  // P counts the number of squared factors
170  // Q counts the number of the rest
171  // R = 0 for no non-squared factors; 1 otherwise
172 
173  // FACTOR holds all the factors - non-squared ones in the middle
174  // - length is 2*P+Q
175  // SYM also holds all the factors but with the non-squared ones
176  // multiplied together - length is 2*P+R
177  // PP holds the values of the squared factors - length is P
178  // QQ holds the values of the rest - length is Q
179 
180  // P_SYM holds the product of the squared factors
181 
182  // find the factors - load into PP and QQ
183  while (N > 1)
184  {
185  bool fail = true;
186  for (J=F; J<=PMAX; J++)
187  if (N % J == 0) { fail = false; F=J; break; }
188  if (fail || P >= NP || Q >= NQ) return false; // can't factor
189  N /= F;
190  if (N % F != 0) QQ[Q++] = F;
191  else { N /= F; PP[P++] = F; P_SYM *= F; }
192  }
193 
194  R = (Q == 0) ? 0 : 1; // R = 0 if no not-squared factors, 1 otherwise
195 
196  NF = 2*P + Q;
197  SimpleIntArray FACTOR(NF + 1), SYM(2*P + R);
198  FACTOR[NF] = 0; // we need this in the "combine powers of 2"
199 
200  // load into SYM and FACTOR
201  for (J=0; J<P; J++)
202  { SYM[J]=FACTOR[J]=PP[P-1-J]; FACTOR[P+Q+J]=SYM[P+R+J]=PP[J]; }
203 
204  if (Q>0)
205  {
206  REPORT
207  for (J=0; J<Q; J++) FACTOR[P+J]=QQ[J];
208  SYM[P]=PTS/square(P_SYM);
209  }
210 
211  // combine powers of 2
212  P_TWO = 1;
213  for (J=0; J < NF; J++)
214  {
215  if (FACTOR[J]!=2) continue;
216  P_TWO=P_TWO*2; FACTOR[J]=1;
217  if (P_TWO<TWO_GRP && FACTOR[J+1]==2) continue;
218  FACTOR[J]=P_TWO; P_TWO=1;
219  }
220 
221  if (P==0) R=0;
222  if (Q<=1) Q=0;
223 
224  // do the analysis
225  GR_1D_FT(PTS,NF,FACTOR,X,Y); // the transform
226  GR_1D_FS(PTS,2*P+R,Q,SYM,P_SYM,QQ,X,Y); // the reshuffling
227 
228  return true;
229 
230 }
Real square(Real x)
Definition: newfft.cpp:111
#define REPORT
Definition: newfft.cpp:108

◆ CanFactor()

bool FFT_Controller::CanFactor ( int  PTS)
static

Definition at line 988 of file newfft.cpp.

References REPORT.

Referenced by FFT().

989 {
990  REPORT
991  const int NP = 16, NQ = 10, PMAX=19;
992 
993  if (PTS<=1) { REPORT return true; }
994 
995  int N = PTS, F = 2, P = 0, Q = 0;
996 
997  while (N > 1)
998  {
999  bool fail = true;
1000  for (int J = F; J <= PMAX; J++)
1001  if (N % J == 0) { fail = false; F=J; break; }
1002  if (fail || P >= NP || Q >= NQ) { REPORT return false; }
1003  N /= F;
1004  if (N % F != 0) Q++; else { N /= F; P++; }
1005  }
1006 
1007  return true; // can factorise
1008 
1009 }
#define REPORT
Definition: newfft.cpp:108

Member Data Documentation

◆ OnlyOldFFT

bool FFT_Controller::OnlyOldFFT
static

Definition at line 109 of file newmatap.h.

Referenced by FFT().


The documentation for this class was generated from the following files: