MCPcopy Create free account
hub / github.com/numpy/numpy / cost_guess

Function cost_guess

numpy/fft/_pocketfft.c:237–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235 }
236
237NOINLINE static double cost_guess (size_t n)
238 {
239 const double lfp=1.1; // penalty for non-hardcoded larger factors
240 size_t ni=n;
241 double result=0.;
242 size_t tmp;
243 while (((tmp=(n>>1))<<1)==n)
244 { result+=2; n=tmp; }
245
246 size_t limit=(size_t)sqrt(n+0.01);
247 for (size_t x=3; x<=limit; x+=2)
248 while ((tmp=(n/x))*x==n)
249 {
250 result+= (x<=5) ? x : lfp*x; // penalize larger prime factors
251 n=tmp;
252 limit=(size_t)sqrt(n+0.01);
253 }
254 if (n>1) result+=(n<=5) ? n : lfp*n;
255
256 return result*ni;
257 }
258
259/* returns the smallest composite of 2, 3, 5, 7 and 11 which is >= n */
260NOINLINE static size_t good_size(size_t n)

Callers 2

make_cfft_planFunction · 0.85
make_rfft_planFunction · 0.85

Calls 1

sqrtFunction · 0.50

Tested by

no test coverage detected