57 if (sz==0)
return NULL;
60 fprintf (stderr,
"%s, %i (%s):\n%s\n",
61 __FILE__, __LINE__, __func__,
71#define RALLOC(type,num) \
72 ((type *)util_malloc_((num)*sizeof(type)))
75 { if ((ptr) != 0) free (ptr); (ptr) = NULL; }
83#define SWAP(a,b,type) \
84 do { type tmp_=(a); (a)=(b); (b)=tmp_; } while(0)
93#define WA(x,i) wa[(i)+(x)*ido]
94#define CH(a,b,c) ch[(a)+ido*((b)+l1*(c))]
95#define CC(a,b,c) cc[(a)+ido*((b)+cdim*(c))]
96#define PM(a,b,c,d) { a=c+d; b=c-d; }
97#define PMC(a,b,c,d) { a.r=c.r+d.r; a.i=c.i+d.i; b.r=c.r-d.r; b.i=c.i-d.i; }
98#define ADDC(a,b,c) { a.r=b.r+c.r; a.i=b.i+c.i; }
99#define SCALEC(a,b) { a.r*=b; a.i*=b; }
100#define CONJFLIPC(a) { double tmp_=a.r; a.r=-a.i; a.i=tmp_; }
102#define MULPM(a,b,c,d,e,f) { a=c*e+d*f; b=c*f-d*e; }
104#define CONCAT(a,b) a ## b
106#define X(arg) CONCAT(passb,arg)
112#define X(arg) CONCAT(passf,arg)
118#define CC(a,b,c) cc[(a)+ido*((b)+l1*(c))]
119#define CH(a,b,c) ch[(a)+ido*((b)+cdim*(c))]
121 static void radf2 (
size_t ido,
size_t l1,
const double *cc,
double *ch,
129 PM (
CH(0,0,k),
CH(ido-1,1,k),
CC(0,k,0),
CC(0,k,1))
133 CH( 0,1,k) = -
CC(ido-1,k,1);
134 CH(ido-1,0,k) =
CC(ido-1,k,0);
138 for (i=2; i<ido; i+=2)
141 MULPM (tr2,ti2,
WA(0,i-2),
WA(0,i-1),
CC(i-1,k,1),
CC(i,k,1))
142 PM (
CH(i-1,0,k),
CH(ic-1,1,k),
CC(i-1,k,0),tr2)
143 PM (
CH(i ,0,k),
CH(ic ,1,k),ti2,
CC(i ,k,0))
147 static void radf3(
size_t ido,
size_t l1,
const double *cc,
double *ch,
151 static const double taur=-0.5, taui=0.86602540378443864676;
153 double ci2, di2, di3, cr2, dr2, dr3, ti2, ti3, tr2, tr3;
157 cr2=
CC(0,k,1)+
CC(0,k,2);
158 CH(0,0,k) =
CC(0,k,0)+cr2;
159 CH(0,2,k) = taui*(
CC(0,k,2)-
CC(0,k,1));
160 CH(ido-1,1,k) =
CC(0,k,0)+taur*cr2;
164 for (i=2; i<ido; i+=2)
167 MULPM (dr2,di2,
WA(0,i-2),
WA(0,i-1),
CC(i-1,k,1),
CC(i,k,1))
168 MULPM (dr3,di3,
WA(1,i-2),
WA(1,i-1),
CC(i-1,k,2),
CC(i,k,2))
171 CH(i-1,0,k) =
CC(i-1,k,0)+cr2;
172 CH(i ,0,k) =
CC(i ,k,0)+ci2;
173 tr2 =
CC(i-1,k,0)+taur*cr2;
174 ti2 =
CC(i ,k,0)+taur*ci2;
175 tr3 = taui*(di2-di3);
176 ti3 = taui*(dr3-dr2);
177 PM(
CH(i-1,2,k),
CH(ic-1,1,k),tr2,tr3)
178 PM(
CH(i ,2,k),
CH(ic ,1,k),ti3,ti2)
182 static
void radf4(
size_t ido,
size_t l1, const
double *cc,
double *ch,
186 static const double hsqt2=0.70710678118654752440;
188 double ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4;
192 PM (tr1,
CH(0,2,k),
CC(0,k,3),
CC(0,k,1))
193 PM (tr2,
CH(ido-1,1,k),
CC(0,k,0),
CC(0,k,2))
194 PM (
CH(0,0,k),
CH(ido-1,3,k),tr2,tr1)
199 ti1=-hsqt2*(
CC(ido-1,k,1)+
CC(ido-1,k,3));
200 tr1= hsqt2*(
CC(ido-1,k,1)-
CC(ido-1,k,3));
201 PM (
CH(ido-1,0,k),
CH(ido-1,2,k),
CC(ido-1,k,0),tr1)
202 PM (
CH( 0,3,k),
CH( 0,1,k),ti1,
CC(ido-1,k,2))
206 for (i=2; i<ido; i+=2)
209 MULPM(cr2,ci2,
WA(0,i-2),
WA(0,i-1),
CC(i-1,k,1),
CC(i,k,1))
210 MULPM(cr3,ci3,
WA(1,i-2),
WA(1,i-1),
CC(i-1,k,2),
CC(i,k,2))
211 MULPM(cr4,ci4,
WA(2,i-2),
WA(2,i-1),
CC(i-1,k,3),
CC(i,k,3))
214 PM(tr2,tr3,
CC(i-1,k,0),cr3)
215 PM(ti2,ti3,
CC(i ,k,0),ci3)
216 PM(
CH(i-1,0,k),
CH(ic-1,3,k),tr2,tr1)
217 PM(
CH(i ,0,k),
CH(ic ,3,k),ti1,ti2)
218 PM(
CH(i-1,2,k),
CH(ic-1,1,k),tr3,ti4)
219 PM(
CH(i ,2,k),
CH(ic ,1,k),tr4,ti3)
223 static
void radf5(
size_t ido,
size_t l1, const
double *cc,
double *ch,
227 static const double tr11= 0.3090169943749474241, ti11=0.95105651629515357212,
228 tr12=-0.8090169943749474241, ti12=0.58778525229247312917;
230 double ci2, di2, ci4, ci5, di3, di4, di5, ci3, cr2, cr3, dr2, dr3,
231 dr4, dr5, cr5, cr4, ti2, ti3, ti5, ti4, tr2, tr3, tr4, tr5;
235 PM (cr2,ci5,
CC(0,k,4),
CC(0,k,1))
236 PM (cr3,ci4,
CC(0,k,3),
CC(0,k,2))
237 CH(0,0,k)=
CC(0,k,0)+cr2+cr3;
238 CH(ido-1,1,k)=
CC(0,k,0)+tr11*cr2+tr12*cr3;
239 CH(0,2,k)=ti11*ci5+ti12*ci4;
240 CH(ido-1,3,k)=
CC(0,k,0)+tr12*cr2+tr11*cr3;
241 CH(0,4,k)=ti12*ci5-ti11*ci4;
245 for (i=2; i<ido; i+=2)
248 MULPM (dr2,di2,
WA(0,i-2),
WA(0,i-1),
CC(i-1,k,1),
CC(i,k,1))
249 MULPM (dr3,di3,
WA(1,i-2),
WA(1,i-1),
CC(i-1,k,2),
CC(i,k,2))
250 MULPM (dr4,di4,
WA(2,i-2),
WA(2,i-1),
CC(i-1,k,3),
CC(i,k,3))
251 MULPM (dr5,di5,
WA(3,i-2),
WA(3,i-1),
CC(i-1,k,4),
CC(i,k,4))
256 CH(i-1,0,k)=
CC(i-1,k,0)+cr2+cr3;
257 CH(i ,0,k)=
CC(i ,k,0)+ci2+ci3;
258 tr2=
CC(i-1,k,0)+tr11*cr2+tr12*cr3;
259 ti2=
CC(i ,k,0)+tr11*ci2+tr12*ci3;
260 tr3=
CC(i-1,k,0)+tr12*cr2+tr11*cr3;
261 ti3=
CC(i ,k,0)+tr12*ci2+tr11*ci3;
262 MULPM(tr5,tr4,cr5,cr4,ti11,ti12)
263 MULPM(ti5,ti4,ci5,ci4,ti11,ti12)
264 PM(
CH(i-1,2,k),
CH(ic-1,1,k),tr2,tr5)
265 PM(
CH(i ,2,k),
CH(ic ,1,k),ti5,ti2)
266 PM(
CH(i-1,4,k),
CH(ic-1,3,k),tr3,tr4)
267 PM(
CH(i ,4,k),
CH(ic ,3,k),ti4,ti3)
273#define CH(a,b,c) ch[(a)+ido*((b)+l1*(c))]
274#define CC(a,b,c) cc[(a)+ido*((b)+cdim*(c))]
275#define C1(a,b,c) cc[(a)+ido*((b)+l1*(c))]
276#define C2(a,b) cc[(a)+idl1*(b)]
277#define CH2(a,b) ch[(a)+idl1*(b)]
278 static void radfg(
size_t ido,
size_t ip,
size_t l1,
size_t idl1,
279 double *cc,
double *ch,
const double *wa)
281 const size_t cdim=ip;
282 static const double twopi=6.28318530717958647692;
283 size_t idij, ipph, i, j, k, l, j2, ic, jc, lc, ik;
284 double ai1, ai2, ar1, ar2,
arg;
291 memcpy(ch,cc,idl1*
sizeof(
double));
298 for(i=2; i<ido; i+=2,idij+=2)
299 MULPM(
CH(i-1,k,j),
CH(i,k,j),wa[idij-1],wa[idij],
C1(i-1,k,j),
C1(i,k,j))
302 for(j=1,jc=ip-1; j<ipph; j++,jc--)
304 for(i=2; i<ido; i+=2)
306 PM(
C1(i-1,k,j),
C1(i ,k,jc),
CH(i-1,k,jc),
CH(i-1,k,j ))
307 PM(
C1(i ,k,j),
C1(i-1,k,jc),
CH(i ,k,j ),
CH(i ,k,jc))
311 memcpy(cc,ch,idl1*
sizeof(
double));
313 for(j=1,jc=ip-1; j<ipph; j++,jc--)
315 PM(
C1(0,k,j),
C1(0,k,jc),
CH(0,k,jc),
CH(0,k,j))
317 csarr=
RALLOC(
double,2*ip);
321 csarr[2]=csarr[2*ip-2]=
cos(
arg);
322 csarr[3]=
sin(
arg); csarr[2*ip-1]=-csarr[3];
323 for (i=2; i<=ip/2; ++i)
325 csarr[2*i]=csarr[2*ip-2*i]=
cos(i*
arg);
327 csarr[2*ip-2*i+1]=-csarr[2*i+1];
329 for(l=1,lc=ip-1; l<ipph; l++,lc--)
333 for(ik=0; ik<idl1; ik++)
335 CH2(ik,l)=
C2(ik,0)+ar1*
C2(ik,1);
336 CH2(ik,lc)=ai1*
C2(ik,ip-1);
339 for(j=2,jc=ip-2; j<ipph; j++,jc--)
342 if (aidx>=2*ip) aidx-=2*ip;
345 for(ik=0; ik<idl1; ik++)
347 CH2(ik,l )+=ar2*
C2(ik,j );
348 CH2(ik,lc)+=ai2*
C2(ik,jc);
354 for(j=1; j<ipph; j++)
355 for(ik=0; ik<idl1; ik++)
359 memcpy(&
CC(0,0,k),&
CH(0,k,0),ido*
sizeof(
double));
360 for(j=1; j<ipph; j++)
366 CC(ido-1,j2-1,k) =
CH(0,k,j );
367 CC(0 ,j2 ,k) =
CH(0,k,jc);
372 for(j=1; j<ipph; j++)
377 for(i=2; i<ido; i+=2)
380 PM (
CC(i-1,j2,k),
CC(ic-1,j2-1,k),
CH(i-1,k,j ),
CH(i-1,k,jc))
381 PM (
CC(i ,j2,k),
CC(ic ,j2-1,k),
CH(i ,k,jc),
CH(i ,k,j ))
388#define CH(a,b,c) ch[(a)+ido*((b)+l1*(c))]
389#define CC(a,b,c) cc[(a)+ido*((b)+cdim*(c))]
391 static void radb2(
size_t ido,
size_t l1,
const double *cc,
double *ch,
399 PM (
CH(0,k,0),
CH(0,k,1),
CC(0,0,k),
CC(ido-1,1,k))
403 CH(ido-1,k,0) = 2*
CC(ido-1,0,k);
404 CH(ido-1,k,1) = -2*
CC(0 ,1,k);
408 for (i=2; i<ido; i+=2)
411 PM (
CH(i-1,k,0),tr2,
CC(i-1,0,k),
CC(ic-1,1,k))
412 PM (ti2,
CH(i ,k,0),
CC(i ,0,k),
CC(ic ,1,k))
413 MULPM (
CH(i,k,1),
CH(i-1,k,1),
WA(0,i-2),
WA(0,i-1),ti2,tr2)
417 static void radb3(
size_t ido,
size_t l1,
const double *cc,
double *ch,
421 static const double taur=-0.5, taui=0.86602540378443864676;
423 double ci2, ci3, di2, di3, cr2, cr3, dr2, dr3, ti2, tr2;
428 cr2=
CC(0,0,k)+taur*tr2;
429 CH(0,k,0)=
CC(0,0,k)+tr2;
430 ci3=2*taui*
CC(0,2,k);
431 PM (
CH(0,k,2),
CH(0,k,1),cr2,ci3);
435 for (i=2; i<ido; i+=2)
438 tr2=
CC(i-1,2,k)+
CC(ic-1,1,k);
439 ti2=
CC(i ,2,k)-
CC(ic ,1,k);
440 cr2=
CC(i-1,0,k)+taur*tr2;
441 ci2=
CC(i ,0,k)+taur*ti2;
442 CH(i-1,k,0)=
CC(i-1,0,k)+tr2;
443 CH(i ,k,0)=
CC(i ,0,k)+ti2;
444 cr3=taui*(
CC(i-1,2,k)-
CC(ic-1,1,k));
445 ci3=taui*(
CC(i ,2,k)+
CC(ic ,1,k));
448 MULPM(
CH(i,k,1),
CH(i-1,k,1),
WA(0,i-2),
WA(0,i-1),di2,dr2)
449 MULPM(
CH(i,k,2),
CH(i-1,k,2),
WA(1,i-2),
WA(1,i-1),di3,dr3)
453 static void radb4(
size_t ido,
size_t l1,
const double *cc,
double *ch,
457 static const double sqrt2=1.41421356237309504880;
459 double ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4;
463 PM (tr2,tr1,
CC(0,0,k),
CC(ido-1,3,k))
466 PM (
CH(0,k,0),
CH(0,k,2),tr2,tr3)
467 PM (
CH(0,k,3),
CH(0,k,1),tr1,tr4)
472 PM (ti1,ti2,
CC(0 ,3,k),
CC(0 ,1,k))
473 PM (tr2,tr1,
CC(ido-1,0,k),
CC(ido-1,2,k))
474 CH(ido-1,k,0)=tr2+tr2;
475 CH(ido-1,k,1)=sqrt2*(tr1-ti1);
476 CH(ido-1,k,2)=ti2+ti2;
477 CH(ido-1,k,3)=-sqrt2*(tr1+ti1);
481 for (i=2; i<ido; i+=2)
484 PM (tr2,tr1,
CC(i-1,0,k),
CC(ic-1,3,k))
485 PM (ti1,ti2,
CC(i ,0,k),
CC(ic ,3,k))
486 PM (tr4,ti3,
CC(i ,2,k),
CC(ic ,1,k))
487 PM (tr3,ti4,
CC(i-1,2,k),
CC(ic-1,1,k))
488 PM (
CH(i-1,k,0),cr3,tr2,tr3)
489 PM (
CH(i ,k,0),ci3,ti2,ti3)
492 MULPM (
CH(i,k,1),
CH(i-1,k,1),
WA(0,i-2),
WA(0,i-1),ci2,cr2)
493 MULPM (
CH(i,k,2),
CH(i-1,k,2),
WA(1,i-2),
WA(1,i-1),ci3,cr3)
494 MULPM (
CH(i,k,3),
CH(i-1,k,3),
WA(2,i-2),
WA(2,i-1),ci4,cr4)
498 static void radb5(
size_t ido,
size_t l1,
const double *cc,
double *ch,
502 static const double tr11= 0.3090169943749474241, ti11=0.95105651629515357212,
503 tr12=-0.8090169943749474241, ti12=0.58778525229247312917;
505 double ci2, ci3, ci4, ci5, di3, di4, di5, di2, cr2, cr3, cr5, cr4,
506 ti2, ti3, ti4, ti5, dr3, dr4, dr5, dr2, tr2, tr3, tr4, tr5;
514 CH(0,k,0)=
CC(0,0,k)+tr2+tr3;
515 cr2=
CC(0,0,k)+tr11*tr2+tr12*tr3;
516 cr3=
CC(0,0,k)+tr12*tr2+tr11*tr3;
517 MULPM(ci5,ci4,ti5,ti4,ti11,ti12)
518 PM(
CH(0,k,4),
CH(0,k,1),cr2,ci5)
519 PM(
CH(0,k,3),
CH(0,k,2),cr3,ci4)
523 for (i=2; i<ido; i+=2)
526 PM(tr2,tr5,
CC(i-1,2,k),
CC(ic-1,1,k))
527 PM(ti5,ti2,
CC(i ,2,k),
CC(ic ,1,k))
528 PM(tr3,tr4,
CC(i-1,4,k),
CC(ic-1,3,k))
529 PM(ti4,ti3,
CC(i ,4,k),
CC(ic ,3,k))
530 CH(i-1,k,0)=
CC(i-1,0,k)+tr2+tr3;
531 CH(i ,k,0)=
CC(i ,0,k)+ti2+ti3;
532 cr2=
CC(i-1,0,k)+tr11*tr2+tr12*tr3;
533 ci2=
CC(i ,0,k)+tr11*ti2+tr12*ti3;
534 cr3=
CC(i-1,0,k)+tr12*tr2+tr11*tr3;
535 ci3=
CC(i ,0,k)+tr12*ti2+tr11*ti3;
536 MULPM(cr5,cr4,tr5,tr4,ti11,ti12)
537 MULPM(ci5,ci4,ti5,ti4,ti11,ti12)
542 MULPM(
CH(i,k,1),
CH(i-1,k,1),
WA(0,i-2),
WA(0,i-1),di2,dr2)
543 MULPM(
CH(i,k,2),
CH(i-1,k,2),
WA(1,i-2),
WA(1,i-1),di3,dr3)
544 MULPM(
CH(i,k,3),
CH(i-1,k,3),
WA(2,i-2),
WA(2,i-1),di4,dr4)
545 MULPM(
CH(i,k,4),
CH(i-1,k,4),
WA(3,i-2),
WA(3,i-1),di5,dr5)
549 static void radbg(
size_t ido,
size_t ip,
size_t l1,
size_t idl1,
550 double *cc,
double *ch,
const double *wa)
552 const size_t cdim=ip;
553 static const double twopi=6.28318530717958647692;
554 size_t idij, ipph, i, j, k, l, j2, ic, jc, lc, ik;
555 double ai1, ai2, ar1, ar2,
arg;
561 memcpy(&
CH(0,k,0),&
CC(0,0,k),ido*
sizeof(double));
562 for(j=1; j<ipph; j++)
568 CH(0,k,j )=2*
CC(ido-1,j2-1,k);
569 CH(0,k,jc)=2*
CC(0 ,j2 ,k);
574 for(j=1,jc=ip-1; j<ipph; j++,jc--)
576 for(i=2; i<ido; i+=2)
579 PM (
CH(i-1,k,j ),
CH(i-1,k,jc),
CC(i-1,2*j,k),
CC(ic-1,2*j-1,k))
580 PM (
CH(i ,k,jc),
CH(i ,k,j ),
CC(i ,2*j,k),
CC(ic ,2*j-1,k))
583 csarr=
RALLOC(
double,2*ip);
587 csarr[2]=csarr[2*ip-2]=
cos(
arg);
588 csarr[3]=
sin(
arg); csarr[2*ip-1]=-csarr[3];
589 for (i=2; i<=ip/2; ++i)
591 csarr[2*i]=csarr[2*ip-2*i]=
cos(i*
arg);
593 csarr[2*ip-2*i+1]=-csarr[2*i+1];
595 for(l=1; l<ipph; l++)
600 for(ik=0; ik<idl1; ik++)
603 C2(ik,lc)=ai1*
CH2(ik,ip-1);
606 for(j=2; j<ipph; j++)
610 if (aidx>=2*ip) aidx-=2*ip;
613 for(ik=0; ik<idl1; ik++)
615 C2(ik,l )+=ar2*
CH2(ik,j );
616 C2(ik,lc)+=ai2*
CH2(ik,jc);
622 for(j=1; j<ipph; j++)
623 for(ik=0; ik<idl1; ik++)
626 for(j=1,jc=ip-1; j<ipph; j++,jc--)
628 PM (
CH(0,k,jc),
CH(0,k,j),
C1(0,k,j),
C1(0,k,jc))
632 for(j=1,jc=ip-1; j<ipph; j++,jc--)
634 for(i=2; i<ido; i+=2)
636 PM (
CH(i-1,k,jc),
CH(i-1,k,j ),
C1(i-1,k,j),
C1(i ,k,jc))
637 PM (
CH(i ,k,j ),
CH(i ,k,jc),
C1(i ,k,j),
C1(i-1,k,jc))
639 memcpy(cc,ch,idl1*
sizeof(
double));
646 for(i=2; i<ido; i+=2,idij+=2)
647 MULPM (
C1(i,k,j),
C1(i-1,k,j),wa[idij-1],wa[idij],
CH(i,k,j),
CH(i-1,k,j))
662 const size_t ifac[],
int isign)
664 size_t k1, l1=1, nf=ifac[1], iw=0;
667 for(k1=0; k1<nf; k1++)
669 size_t ip=ifac[k1+2];
673 (isign>0) ? passb4(ido, l1, p1, p2, wa+iw)
674 : passf4(ido, l1, p1, p2, wa+iw);
676 (isign>0) ? passb2(ido, l1, p1, p2, wa+iw)
677 : passf2(ido, l1, p1, p2, wa+iw);
679 (isign>0) ? passb3(ido, l1, p1, p2, wa+iw)
680 : passf3(ido, l1, p1, p2, wa+iw);
682 (isign>0) ? passb5(ido, l1, p1, p2, wa+iw)
683 : passf5(ido, l1, p1, p2, wa+iw);
685 (isign>0) ? passb6(ido, l1, p1, p2, wa+iw)
686 : passf6(ido, l1, p1, p2, wa+iw);
688 (isign>0) ? passbg(ido, ip, l1, p1, p2, wa+iw)
689 : passfg(ido, ip, l1, p1, p2, wa+iw);
698 void cfftf(
size_t n,
double c[],
double wsave[])
702 (
size_t*)(wsave+4*
n),-1);
705 void cfftb(
size_t n,
double c[],
double wsave[])
709 (
size_t*)(wsave+4*
n),+1);
712 static void factorize (
size_t n,
const size_t *pf,
size_t npf,
size_t *ifac)
714 size_t nl=
n, nf=0, ntry=0, j=0, i;
718 ntry = (j<=npf) ? pf[j-1] : ntry+2;
722 size_t nr=nl-ntry*nq;
728 if ((ntry==2) && (nf!=1))
730 for (i=nf+1; i>2; --i)
740 static void cffti1(
size_t n,
double wa[],
size_t ifac[])
742 static const size_t ntryh[5]={4,6,3,2,5};
743 static const double twopi=6.28318530717958647692;
748 factorize (
n,ntryh,5,ifac);
749 for(k=1; k<=ifac[1]; k++)
752 size_t ido=
n/(l1*ip);
756 double argld=j*l1*argh;
759 for(fi=1; fi<=ido; fi++)
777 {
if (
n!=1) cffti1(
n, wsave+2*
n,(
size_t*)(wsave+4*
n)); }
791 size_t k1, l1=
n, nf=ifac[1], iw=
n-1;
792 double *p1=ch, *p2=
c;
794 for(k1=1; k1<=nf;++k1)
796 size_t ip=ifac[nf-k1+2];
800 SWAP (p1,p2,
double *);
802 radf4(ido, l1, p1, p2, wa+iw);
804 radf2(ido, l1, p1, p2, wa+iw);
806 radf3(ido, l1, p1, p2, wa+iw);
808 radf5(ido, l1, p1, p2, wa+iw);
812 SWAP (p1,p2,
double *);
813 radfg(ido, ip, l1, ido*l1, p1, p2, wa+iw);
814 SWAP (p1,p2,
double *);
818 memcpy (
c,ch,
n*
sizeof(
double));
821 static void rfftb1(
size_t n,
double c[],
double ch[],
const double wa[],
824 size_t k1, l1=1, nf=ifac[1], iw=0;
825 double *p1=
c, *p2=ch;
827 for(k1=1; k1<=nf; k1++)
829 size_t ip = ifac[k1+1],
832 radb4(ido, l1, p1, p2, wa+iw);
834 radb2(ido, l1, p1, p2, wa+iw);
836 radb3(ido, l1, p1, p2, wa+iw);
838 radb5(ido, l1, p1, p2, wa+iw);
841 radbg(ido, ip, l1, ido*l1, p1, p2, wa+iw);
843 SWAP (p1,p2,
double *);
845 SWAP (p1,p2,
double *);
850 memcpy (
c,ch,
n*
sizeof(
double));
853 void rfftf(
size_t n,
double r[],
double wsave[])
854 {
if(
n!=1) rfftf1(
n, r, wsave, wsave+
n,(
size_t*)(wsave+2*
n)); }
856 void rfftb(
size_t n,
double r[],
double wsave[])
857 {
if(
n!=1) rfftb1(
n, r, wsave, wsave+
n,(
size_t*)(wsave+2*
n)); }
859 static void rffti1(
size_t n,
double wa[],
size_t ifac[])
861 static const size_t ntryh[4]={4,2,3,5};
862 static const double twopi=6.28318530717958647692;
867 factorize (
n,ntryh,4,ifac);
868 for (k=1; k<ifac[1]; k++)
874 double argld=j*l1*argh;
875 for(i=is,fi=1; i<=ido+is-3; i+=2,++fi)
890 rffti1(
n, wsave+
n,(
size_t*)(wsave+2*
n));
894 const double pi = 3.14159265358979;
899 double dt =
pi / double (
n+1);
900 for (
size_t k = 0; k < ns2; k++) {
901 wsave[k] = 2.0 *
sin ((k+1) * dt);
914 void sint1 (
size_t n,
double war[],
double was[],
double xh[],
double x[],
double xxifac[])
916 double sqrt3 = 1.73205080756888;
918 for (
size_t i = 0; i <
n; i++) {
926 double xhold = sqrt3*(xh[0]+xh[1]);
927 xh[1] = sqrt3*(xh[0]-xh[1]);
933 for (
size_t k = 0; k < ns2; k++) {
935 double t1 = xh[k] - xh[kc];
936 double t2 = was[k] * (xh[k] + xh[kc]);
942 x[ns2+2] = 4.0 * xh[ns2+1];
944 rfftf1 (np1, x, xh, war, (
size_t*)xxifac);
946 for (
size_t i = 2; i <
n; i += 2) {
948 xh[i] = xh[i-2] + x[i-1];
954 for (
size_t i = 0; i <
n; i++) {
960 void sint (
size_t n,
double x[],
double wsave[])
968 wsave +
n/2 + 2*
n + 2
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
void sinti(size_t n, double wsave[])
#define RALLOC(type, num)
void cffti(size_t n, double wsave[])
void cfftf(size_t n, double c[], double wsave[])
void sint(size_t n, double x[], double wsave[])
void sint1(size_t n, double war[], double was[], double xh[], double x[], double xxifac[])
void util_free_(void *ptr)
void rffti(size_t n, double wsave[])
void * util_malloc_(size_t sz)
void rfftf(size_t n, double r[], double wsave[])
void cfftb(size_t n, double c[], double wsave[])
#define MULPM(a, b, c, d, e, f)
void rfftb(size_t n, double r[], double wsave[])
constexpr double c
The velocity of light in m/s.