Generative Fast Fourier Transforms (GFFT)  0.3
metapow.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007-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 #ifndef __metapow_h
16 #define __metapow_h
17 
23 namespace MF {
24 
25 
26 template<int_t A, int_t P, class RetType = long double>
27 struct DPow {
28  static RetType value() {
29  return static_cast<RetType>(A) * DPow<A,P-1,RetType>::value();
30  }
31 };
32 
33 template<int_t A, class RetType>
34 struct DPow<A,1,RetType> {
35  static RetType value() { return A; }
36 };
37 
38 template<int_t A, class RetType>
39 struct DPow<A,0,RetType> {
40  static RetType value() { return 1; }
41 };
42 
43 
44 template<unsigned N, unsigned P>
45 struct IPow {
46  static const unsigned long value = IPow<N,P-1>::value * N;
47 };
48 
49 template<unsigned N>
50 struct IPow<N,1> {
51  static const unsigned long value = N;
52 };
53 
54 template<unsigned N>
55 struct IPow<N,0> {
56  static const unsigned long value = 1;
57 };
58 
59 
60 template<class N, int_t P>
61 struct IPowBig {
62  typedef typename Mult<N, typename IPowBig<N,P-1>::Result>::Result Result;
63 };
64 
65 template<class N>
66 struct IPowBig<N,1> {
67  typedef N Result;
68 };
69 
70 template<class N>
71 struct IPowBig<N,0> {
72  typedef SInt<1> Result;
73 };
74 
75 
76 
77 } // namespace MF
78 
79 #endif /*__metapow_h*/

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