Generative Fast Fourier Transforms (GFFT)  0.3
typelistgen.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2012-2014 by Vladimir Mirnyy *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  ***************************************************************************/
14 
15 
16 #ifndef __typelistgen_h
17 #define __typelistgen_h
18 
24 namespace GFFT {
25 
26 
47 template<class TList, class TLenList,
48  template<class,id_t> class DefTrans,
49  class WorkingList=Loki::NullType, id_t ID=0>
51 
52 // H is a simple type
53 template<class H, class Tail, id_t N, class NTail,
54  template<class,id_t> class DefTrans, class WorkingList, id_t ID>
55 struct ListGenerator<Loki::Typelist<H,Tail>,Loki::Typelist<s_uint<N>,NTail>,DefTrans,WorkingList,ID> {
56  typedef Loki::Typelist<H,WorkingList> WList;
58 };
59 
60 // Typelist is in the head
61 template<class H, class T, class Tail, id_t N, class NTail,
62  template<class,id_t> class DefTrans, class WorkingList, id_t ID>
63 struct ListGenerator<Loki::Typelist<Loki::Typelist<H,T>,Tail>,Loki::Typelist<s_uint<N>,NTail>,DefTrans,WorkingList,ID> {
64  typedef Loki::Typelist<H,WorkingList> WList;
65  typedef typename ListGenerator<Loki::Typelist<T,Tail>,Loki::Typelist<s_uint<N>,NTail>,DefTrans,WorkingList,ID>::Result L1;
67  typedef typename Loki::TL::Append<L1,L2>::Result Result;
68 };
69 
70 template<class H, class Tail, id_t N, class NTail,
71  template<class,id_t> class DefTrans, class WorkingList, id_t ID>
72 struct ListGenerator<Loki::Typelist<Loki::Typelist<H,Loki::NullType>,Tail>,
73  Loki::Typelist<s_uint<N>,NTail>,DefTrans,WorkingList,ID> {
74  typedef Loki::Typelist<H,WorkingList> WList;
75  typedef typename ListGenerator<Tail,NTail,DefTrans,WList,(ID*N)+H::ID>::Result Result;
76 };
77 
78 template<template<class,id_t> class DefTrans, class WorkingList, id_t ID>
79 struct ListGenerator<Loki::NullType,Loki::NullType,DefTrans,WorkingList,ID> {
80  typedef Loki::Typelist<typename DefTrans<WorkingList,ID>::Result,Loki::NullType> Result;
81 };
82 
83 
84 
86 template<int_t Begin, int_t End,
87 template<int_t> class Holder = SIntID>
88 struct GenNumList {
89  typedef Loki::Typelist<Holder<Begin>,
90  typename GenNumList<Begin+1,End,Holder>::Result> Result;
91 };
92 
93 template<int_t End,
94 template<int_t> class Holder>
95 struct GenNumList<End,End,Holder> {
96  typedef Loki::Typelist<Holder<End>,Loki::NullType> Result;
97 };
98 
99 
100 template<int_t M, int_t P>
101 struct PowerHolder {
102  static const int_t N = IPow<M,P>::value;
103  static const int_t ID = N-1;
104  static const int_t value = N;
105 };
106 
107 template<int_t P>
108 struct PowerHolder<2,P> {
109  static const int_t N = 1<<P;
110  static const int_t ID = N-1;
111  static const int_t value = N;
112 };
113 
114 template<int_t P>
115 struct Power2holder : public PowerHolder<2,P> {};
116 
117 template<int_t P>
118 struct Power3holder : public PowerHolder<3,P> {};
119 
120 
122 template<int_t PowerBegin, int_t PowerEnd, int_t M>
123 struct GenPowerList {
124  typedef Loki::Typelist<PowerHolder<M,PowerBegin>,
125  typename GenPowerList<PowerBegin+1,PowerEnd,M>::Result> Result;
126 };
127 
128 template<int_t PowerEnd, int_t M>
129 struct GenPowerList<PowerEnd,PowerEnd,M> {
130  typedef Loki::Typelist<PowerHolder<M,PowerEnd>,Loki::NullType> Result;
131 };
132 
133 } //namespace
134 
135 #endif

Generated on Mon Feb 10 2014 for Generative Fast Fourier Transforms (GFFT) by DoxyGen 1.8.3.1