Twiddle factors table
| 522 | |
| 523 | // Twiddle factors table |
| 524 | class TwiddleTable |
| 525 | { |
| 526 | size_t N; // length |
| 527 | double *wc, *ws; // cosine, sine arrays |
| 528 | |
| 529 | public: |
| 530 | TwiddleTable(size_t length) : N(length) |
| 531 | { |
| 532 | // Allocate memory for the tables |
| 533 | // We compute twiddle factors in double precision for both P_SINGLE and P_DOUBLE |
| 534 | wc = new double[N]; |
| 535 | ws = new double[N]; |
| 536 | } |
| 537 | |
| 538 | ~TwiddleTable() |
| 539 | { |
| 540 | // Free |
| 541 | delete[] wc; |
| 542 | delete[] ws; |
| 543 | } |
| 544 | |
| 545 | template <Precision PR> |
| 546 | void GenerateTwiddleTable(const std::vector<size_t> &radices, std::string &twStr) |
| 547 | { |
| 548 | const double TWO_PI = -6.283185307179586476925286766559; |
| 549 | |
| 550 | // Make sure the radices vector sums up to N |
| 551 | size_t sz = 1; |
| 552 | for(std::vector<size_t>::const_iterator i = radices.begin(); |
| 553 | i != radices.end(); i++) |
| 554 | { |
| 555 | sz *= (*i); |
| 556 | } |
| 557 | assert(sz == N); |
| 558 | |
| 559 | // Generate the table |
| 560 | size_t L = 1; |
| 561 | size_t nt = 0; |
| 562 | for(std::vector<size_t>::const_iterator i = radices.begin(); |
| 563 | i != radices.end(); i++) |
| 564 | { |
| 565 | size_t radix = *i; |
| 566 | |
| 567 | L *= radix; |
| 568 | |
| 569 | // Twiddle factors |
| 570 | for(size_t k=0; k<(L/radix); k++) |
| 571 | { |
| 572 | double theta = TWO_PI * ((double)k)/((double)L); |
| 573 | |
| 574 | for(size_t j=1; j<radix; j++) |
| 575 | { |
| 576 | double c = cos(((double)j) * theta); |
| 577 | double s = sin(((double)j) * theta); |
| 578 | |
| 579 | //if (fabs(c) < 1.0E-12) c = 0.0; |
| 580 | //if (fabs(s) < 1.0E-12) s = 0.0; |
| 581 |
nothing calls this directly
no outgoing calls
no test coverage detected