412 typedef plan<T> self_type;
415 typedef std::complex<T> SC;
418 typedef SC std_complex;
423 plan(
void): paux(0) {}
425 plan(
const self_type &other): paux(other.paux) { inc(); }
426 ~plan(
void) { dec(); }
427 void swap(self_type &other)
428 { aux *tmp = other.paux; other.paux = paux; paux = tmp; }
429 self_type& operator=(self_type other)
430 { swap(other);
return *
this; }
431 void clear(
void) { self_type t; *
this = t; }
432 bool empty(
void)
const {
return paux==0; }
439 void execute(
void)
const
442 static self_type plan_dft(
int rank,
const int *n,
443 C *in, C *out,
int sign,
unsigned flags)
445 static self_type plan_dft(
int rank,
const int *n,
446 SC *in, SC *out,
int sign,
unsigned flags)
449 static self_type plan_dft_1d(
int n,
450 C *in, C *out,
int sign,
unsigned flags)
452 static self_type plan_dft_1d(
int n,
453 SC *in, SC *out,
int sign,
unsigned flags)
455 static self_type plan_dft_2d(
int n0,
int n1,
456 C *in, C *out,
int sign,
unsigned flags)
458 static self_type plan_dft_2d(
int n0,
int n1,
459 SC *in, SC *out,
int sign,
unsigned flags)
461 static self_type plan_dft_3d(
int n0,
int n1,
int n2,
462 C *in, C *out,
int sign,
unsigned flags)
464 static self_type plan_dft_3d(
int n0,
int n1,
int n2,
465 SC *in, SC *out,
int sign,
unsigned flags)
468 static self_type plan_many_dft(
int rank,
const int *n,
int howmany,
469 C *in,
const int *inembed,
int istride,
int idist,
470 C *out,
const int *onembed,
int ostride,
int odist,
471 int sign,
unsigned flags)
473 in, inembed, istride, idist,
474 out, onembed, ostride, odist, sign, flags); }
475 static self_type plan_many_dft(
int rank,
const int *n,
int howmany,
476 SC *in,
const int *inembed,
int istride,
int idist,
477 SC *out,
const int *onembed,
int ostride,
int odist,
478 int sign,
unsigned flags)
480 (C*)in, inembed, istride, idist,
481 (C*)out, onembed, ostride, odist, sign, flags); }
483 static self_type plan_guru_dft(
int rank,
const iodim *dims,
484 int howmany_rank,
const iodim *howmany_dims,
485 C *in, C *out,
int sign,
unsigned flags)
487 howmany_rank, howmany_dims, in, out, sign, flags); }
488 static self_type plan_guru_dft(
int rank,
const iodim *dims,
489 int howmany_rank,
const iodim *howmany_dims,
490 SC *in, SC *out,
int sign,
unsigned flags)
492 howmany_rank, howmany_dims, (C*)in, (C*)out, sign, flags); }
493 static self_type plan_guru_split_dft(
int rank,
const iodim *dims,
494 int howmany_rank,
const iodim *howmany_dims,
495 R *ri, R *ii, R *ro, R *
io,
unsigned flags)
497 howmany_rank, howmany_dims, ri, ii, ro,
io, flags); }
499 static self_type plan_guru64_dft(
int rank,
const iodim64 *dims,
500 int howmany_rank,
const iodim64 *howmany_dims,
501 C *in, C *out,
int sign,
unsigned flags)
503 howmany_rank, howmany_dims, in, out, sign, flags); }
504 static self_type plan_guru64_dft(
int rank,
const iodim64 *dims,
505 int howmany_rank,
const iodim64 *howmany_dims,
506 SC *in, SC *out,
int sign,
unsigned flags)
508 howmany_rank, howmany_dims, (C*)in, (C*)out, sign, flags); }
509 static self_type plan_guru64_split_dft(
int rank,
const iodim64 *dims,
510 int howmany_rank,
const iodim64 *howmany_dims,
511 R *ri, R *ii, R *ro, R *
io,
unsigned flags)
513 howmany_rank, howmany_dims, ri, ii, ro,
io, flags); }
515 void execute_dft(C *in, C *out)
const
517 void execute_dft(SC *in, SC *out)
const
519 void execute_split_dft(R *ri, R *ii, R *ro, R *
io)
const
522 static self_type plan_many_dft_r2c(
int rank,
const int *n,
int howmany,
523 R *in,
const int *inembed,
int istride,
int idist,
524 C *out,
const int *onembed,
int ostride,
int odist,
527 in, inembed, istride, idist,
528 out, onembed, ostride, odist, flags); }
529 static self_type plan_many_dft_r2c(
int rank,
const int *n,
int howmany,
530 R *in,
const int *inembed,
int istride,
int idist,
531 SC *out,
const int *onembed,
int ostride,
int odist,
534 in, inembed, istride, idist,
535 (C*)out, onembed, ostride, odist, flags); }
537 static self_type plan_dft_r2c(
int rank,
const int *n,
538 R *in, C *out,
unsigned flags)
540 static self_type plan_dft_r2c(
int rank,
const int *n,
541 R *in, SC *out,
unsigned flags)
544 static self_type plan_dft_r2c_1d(
int n, R *in, C *out,
547 static self_type plan_dft_r2c_1d(
int n, R *in, SC *out,
550 static self_type plan_dft_r2c_2d(
int n0,
int n1,
551 R *in, C *out,
unsigned flags)
553 static self_type plan_dft_r2c_2d(
int n0,
int n1,
554 R *in, SC *out,
unsigned flags)
556 static self_type plan_dft_r2c_3d(
int n0,
int n1,
int n2,
557 R *in, C *out,
unsigned flags)
559 static self_type plan_dft_r2c_3d(
int n0,
int n1,
int n2,
560 R *in, SC *out,
unsigned flags)
563 static self_type plan_many_dft_c2r(
int rank,
const int *n,
int howmany,
564 C *in,
const int *inembed,
int istride,
int idist,
565 R *out,
const int *onembed,
int ostride,
int odist,
568 in, inembed, istride, idist,
569 out, onembed, ostride, odist, flags); }
570 static self_type plan_many_dft_c2r(
int rank,
const int *n,
int howmany,
571 SC *in,
const int *inembed,
int istride,
int idist,
572 R *out,
const int *onembed,
int ostride,
int odist,
575 (C*)in, inembed, istride, idist,
576 out, onembed, ostride, odist, flags); }
578 static self_type plan_dft_c2r(
int rank,
const int *n,
579 C *in, R *out,
unsigned flags)
581 static self_type plan_dft_c2r(
int rank,
const int *n,
582 SC *in, R *out,
unsigned flags)
585 static self_type plan_dft_c2r_1d(
int n, C *in, R *out,
unsigned flags)
587 static self_type plan_dft_c2r_1d(
int n, SC *in, R *out,
unsigned flags)
589 static self_type plan_dft_c2r_2d(
int n0,
int n1,
590 C *in, R *out,
unsigned flags)
592 static self_type plan_dft_c2r_2d(
int n0,
int n1,
593 SC *in, R *out,
unsigned flags)
595 static self_type plan_dft_c2r_3d(
int n0,
int n1,
int n2,
596 C *in, R *out,
unsigned flags)
598 static self_type plan_dft_c2r_3d(
int n0,
int n1,
int n2,
599 SC *in, R *out,
unsigned flags)
602 static self_type plan_guru_dft_r2c(
int rank,
const iodim *dims,
603 int howmany_rank,
const iodim *howmany_dims,
604 R *in, C *out,
unsigned flags)
606 howmany_rank, howmany_dims, in, out, flags); }
607 static self_type plan_guru_dft_r2c(
int rank,
const iodim *dims,
608 int howmany_rank,
const iodim *howmany_dims,
609 R *in, SC *out,
unsigned flags)
611 howmany_rank, howmany_dims, in, (C*)out, flags); }
612 static self_type plan_guru_dft_c2r(
int rank,
const iodim *dims,
613 int howmany_rank,
const iodim *howmany_dims,
614 C *in, R *out,
unsigned flags)
616 howmany_rank, howmany_dims, in, out, flags); }
617 static self_type plan_guru_dft_c2r(
int rank,
const iodim *dims,
618 int howmany_rank,
const iodim *howmany_dims,
619 SC *in, R *out,
unsigned flags)
621 howmany_rank, howmany_dims, (C*)in, out, flags); }
623 static self_type plan_guru_split_dft_r2c(
624 int rank,
const iodim *dims,
625 int howmany_rank,
const iodim *howmany_dims,
626 R *in, R *ro, R *
io,
unsigned flags)
628 howmany_rank, howmany_dims, in, ro,
io, flags); }
629 static self_type plan_guru_split_dft_c2r(
630 int rank,
const iodim *dims,
631 int howmany_rank,
const iodim *howmany_dims,
632 R *ri, R *ii, R *out,
unsigned flags)
634 howmany_rank, howmany_dims, ri, ii, out, flags); }
636 static self_type plan_guru64_dft_r2c(
int rank,
const iodim64 *dims,
637 int howmany_rank,
const iodim64 *howmany_dims,
638 R *in, C *out,
unsigned flags)
640 howmany_rank, howmany_dims, in, out, flags); }
641 static self_type plan_guru64_dft_r2c(
int rank,
const iodim64 *dims,
642 int howmany_rank,
const iodim64 *howmany_dims,
643 R *in, SC *out,
unsigned flags)
645 howmany_rank, howmany_dims, in, (C*)out, flags); }
646 static self_type plan_guru64_dft_c2r(
int rank,
const iodim64 *dims,
647 int howmany_rank,
const iodim64 *howmany_dims,
648 C *in, R *out,
unsigned flags)
650 howmany_rank, howmany_dims, in, out, flags); }
651 static self_type plan_guru64_dft_c2r(
int rank,
const iodim64 *dims,
652 int howmany_rank,
const iodim64 *howmany_dims,
653 SC *in, R *out,
unsigned flags)
655 howmany_rank, howmany_dims, (C*)in, out, flags); }
657 static self_type plan_guru64_split_dft_r2c(
658 int rank,
const iodim64 *dims,
659 int howmany_rank,
const iodim64 *howmany_dims,
660 R *in, R *ro, R *
io,
unsigned flags)
662 howmany_rank, howmany_dims, in, ro,
io, flags); }
663 static self_type plan_guru64_split_dft_c2r(
664 int rank,
const iodim64 *dims,
665 int howmany_rank,
const iodim64 *howmany_dims,
666 R *ri, R *ii, R *out,
unsigned flags)
668 howmany_rank, howmany_dims, ri, ii, out, flags); }
670 void execute_dft_r2c(R *in, C *out)
const
672 void execute_dft_r2c(R *in, SC *out)
const
674 void execute_dft_c2r(C *in, R *out)
const
676 void execute_dft_c2r(SC *in, R *out)
const
679 void execute_split_dft_r2c(R *in, R *ro, R *
io)
const
681 void execute_split_dft_c2r(R *ri, R *ii, R *out)
const
684 static self_type plan_many_r2r(
int rank,
const int *n,
int howmany,
685 R *in,
const int *inembed,
int istride,
int idist,
686 R *out,
const int *onembed,
int ostride,
int odist,
687 const r2r_kind *kind,
unsigned flags)
689 in, inembed, istride, idist, out, onembed, ostride, odist,
692 static self_type plan_r2r(
int rank,
const int *n, R *in, R *out,
693 const r2r_kind *kind,
unsigned flags)
696 static self_type plan_r2r_1d(
int n, R *in, R *out,
697 r2r_kind kind,
unsigned flags)
699 static self_type plan_r2r_2d(
int n0,
int n1, R *in, R *out,
700 r2r_kind kind0, r2r_kind kind1,
unsigned flags)
702 static self_type plan_r2r_3d(
int n0,
int n1,
int n2,
704 r2r_kind kind0, r2r_kind kind1, r2r_kind kind2,
unsigned flags)
706 kind0, kind1, kind2, flags); }
708 static self_type plan_guru_r2r(
int rank,
const iodim *dims,
709 int howmany_rank,
const iodim *howmany_dims,
710 R *in, R *out,
const r2r_kind *kind,
unsigned flags)
712 howmany_rank, howmany_dims, in, out, kind, flags); }
714 static self_type plan_guru64_r2r(
int rank,
const iodim64 *dims,
715 int howmany_rank,
const iodim64 *howmany_dims,
716 R *in, R *out,
const r2r_kind *kind,
unsigned flags)
718 howmany_rank, howmany_dims, in, out, kind, flags); }
720 void execute_r2r(R *in, R *out)
const
726 void fprint(FILE *output_file)
const
728 void print(
void)
const
730 char *sprint(
void)
const
732 void flops(
double *add,
double *mul,
double *fmas)
const
734 double estimate_cost(
void)
const
736 double cost(
void)
const
745 void inc(
void) { ++refcnt; }
746 unsigned dec(
void) {
return --refcnt; }
747 friend class plan<T>;
750 void inc(
void) {
if (paux) paux->inc(); }
751 void dec(
void) {
if (paux && !paux->dec()) {
delete paux; paux = 0; } }
753 if (!paux)
throw std::runtime_error(
"plan is not initialized");