51 class FactoryPolicy = Empty,
63 class Transform<N,VType,Type,Dim,Parall,
IN_PLACE,FactoryPolicy,IDN> :
public FactoryPolicy
65 typedef typename VType::ValueType T;
66 typedef typename Factorization<N, SInt>::Result NFact;
67 typedef typename Parall::template Swap<NFact::Head::first::value,NFact::Head::second::value,T>::Result Swap;
68 typedef typename Type::template Direction<N::value,T> Dir;
71 typedef typename GetFirstRoot<N::value,Dir::Sign,VType::Accuracy>::Result W1;
73 typedef typename IN_PLACE::template List<N::value,NFact,T,Swap,Dir,Parall::NParProc,W1>::Result TList;
74 typedef typename Type::template Algorithm<TList,Sep>::Result Alg;
80 typedef Type TransformType;
81 typedef Parall ParallType;
85 static const int_t Len = N::value;
87 static FactoryPolicy* Create() {
95 void fft(T* data) { run.apply(data); }
106 class Transform<N,VType,Type,Dim,Parall,OUT_OF_PLACE,FactoryPolicy,IDN> :
public FactoryPolicy
108 typedef typename VType::ValueType T;
109 typedef typename Type::template Direction<N::value,T> Dir;
110 typedef Separate<N::value,T,Dir::Sign> Sep;
111 typedef Caller<Loki::NullType> EmptySwap;
112 typedef typename Factorization<N, SInt>::Result NFact;
115 typedef typename GetFirstRoot<N::value,Dir::Sign,VType::Accuracy>::Result W1;
117 typedef typename OUT_OF_PLACE::template List<N::value,NFact,T,EmptySwap,Dir,Parall::NParProc,W1>::Result TList;
118 typedef typename Type::template Algorithm<TList,Sep>::Result Alg;
120 Caller<Loki::Typelist<Parall,Alg> > run;
124 typedef Type TransformType;
125 typedef Parall ParallType;
126 typedef OUT_OF_PLACE PlaceType;
128 enum { ID = IDN, Len = N::value };
130 static FactoryPolicy* Create() {
131 return new Transform<N,VType,Type,Dim,Parall,OUT_OF_PLACE,FactoryPolicy>();
143 void fft(
const T* src, T* dst) { run.apply(src, dst); }
156 template<
class TList,
id_t ID>
158 typedef typename TList::Tail::Head VType;
159 typedef typename TList::Tail::Tail::Head TransformType;
160 typedef typename TList::Tail::Tail::Tail::Tail::Tail::Head Place;
161 typedef typename Place::template Interface<typename VType::ValueType>::Result Abstract;
163 typedef Transform<
typename TList::Head, VType, TransformType,
164 typename TList::Tail::Tail::Tail::Head,
165 typename TList::Tail::Tail::Tail::Tail::Head,
166 Place,Abstract,ID>
Result;
171 template<
class NList>
174 template<
id_t N,
class T>
175 struct TranslateID<Loki::Typelist<s_uint<N>,T> > {
176 static unsigned int apply(
const int_t* n) {
177 return TranslateID<T>::apply(n+1)*N + *n;
182 struct TranslateID<Loki::Typelist<s_uint<N>,Loki::NullType> > {
183 static unsigned int apply(
const int_t* n) {
190 template <
typename IdentifierType,
class AbstractProduct>
191 struct TransformFactoryError
193 struct Exception :
public std::exception
195 const char* what()
const throw() {
196 return "Requested transform is not compiled! Check your instantiation of GenerateTransform class!";
199 static AbstractProduct* OnUnknownType(IdentifierType) {
246 template<
class NList,
248 class TransType = TransformTypeGroup::Default,
250 class Parall = ParallelizationGroup::Default,
251 class Place = PlaceGroup::Default>
254 enum { L1 = Loki::TL::Length<NList>::value };
255 enum { L2 = Loki::TL::Length<ValueTypeGroup::FullList>::value };
256 enum { L3 = Loki::TL::Length<TransformTypeGroup::FullList>::value };
258 enum { L5 = Loki::TL::Length<ParallelizationGroup::FullList>::value };
259 enum { L6 = Loki::TL::Length<DecimationGroup::FullList>::value };
260 typedef TYPELIST_6(s_uint<L1>,s_uint<L2>,s_uint<L3>,s_uint<L4>,s_uint<L5>,s_uint<L6>) LenList;
262 typedef typename Loki::TL::Reverse<LenList>::Result RevLenList;
264 typedef TYPELIST_6(
Place,Parall,Dim,TransType,T,NList) RevList;
266 typedef TranslateID<LenList> Translate;
270 typedef typename Place::template Interface<typename T::ValueType>::Result ObjectType;
272 Loki::Factory<ObjectType,int_t,ObjectType*(*)(),TransformFactoryError> factory;
275 FactoryInit<Result>::apply(factory);
278 ObjectType* CreateTransformObject(int_t n, int_t vtype_id,
279 int_t trans_id = TransformTypeGroup::Default::ID,
281 int_t parall_id = ParallelizationGroup::Default::ID,
282 int_t decim_id = DecimationGroup::Default::ID)
284 int_t narr[] = {n-1, vtype_id, trans_id, dim-1, parall_id, decim_id};
285 int_t obj_id = Translate::apply(narr);
286 return factory.CreateObject(obj_id);