ndarray
NumPy-friendly multidimensional arrays in C++
Loading...
Searching...
No Matches
FourierTraits.h
Go to the documentation of this file.
1// -*- c++ -*-
2/*
3 * Copyright (c) 2010-2012, Jim Bosch
4 * All rights reserved.
5 *
6 * ndarray is distributed under a simple BSD-like license;
7 * see the LICENSE file that should be present in the root
8 * of the source distribution, or alternately available at:
9 * https://github.com/ndarray/ndarray
10 */
11#ifndef NDARRAY_FFT_FourierTraits_h_INCLUDED
12#define NDARRAY_FFT_FourierTraits_h_INCLUDED
13
20#include <complex>
21#include <boost/shared_ptr.hpp>
22
23#include "ndarray/fft_fwd.h"
24
25namespace ndarray {
27namespace detail {
28
33template <typename T, bool IsConst>
34struct FourierTraits {
35 BOOST_STATIC_ASSERT(sizeof(T) < 0);
36};
37
39
40template <typename T>
41struct FourierTraits<T,false> {
42 typedef T ElementX;
43 typedef T ValueX;
44 typedef std::complex<T> ElementK;
45 typedef std::complex<T> ValueK;
46
47 static inline Size computeLastDimensionSize(Size n) { return n/2 + 1; }
48};
49
50template <typename T>
51struct FourierTraits<T,true> {
52 typedef T ElementX;
53 typedef typename boost::remove_const<T>::type ValueX;
54 typedef std::complex<ValueX> ValueK;
55 typedef ValueK const ElementK;
56
57 static inline Size computeLastDimensionSize(Size n) { return n/2 + 1; }
58};
59
60template <typename U>
61struct FourierTraits<std::complex<U>,false> {
62 typedef std::complex<U> ElementX;
63 typedef std::complex<U> ElementK;
64 typedef std::complex<U> ValueX;
65 typedef std::complex<U> ValueK;
66
67 static inline Size computeLastDimensionSize(Size n) { return n; }
68};
69
70template <typename U>
71struct FourierTraits<std::complex<U> const,true> {
72 typedef std::complex<U> const ElementX;
73 typedef std::complex<U> const ElementK;
74 typedef std::complex<U> ValueX;
75 typedef std::complex<U> ValueK;
76
77 static inline Size computeLastDimensionSize(Size n) { return n; }
78};
79
81
82} // namespace detail
84} // namespace ndarray
85
86#endif // !NDARRAY_FFT_FourierTraits_h_INCLUDED
Forward declarations and default template parameters for ndarray/fft.