JayBeams  0.1
Another project to have fun coding.
cast.hpp
Go to the documentation of this file.
1 #ifndef jb_fftw_cast_hpp
2 #define jb_fftw_cast_hpp
3 
4 #include <jb/fftw/traits.hpp>
5 
6 #include <boost/multi_array.hpp>
7 
8 namespace jb {
9 namespace fftw {
10 
11 template <typename F>
12 typename traits<F>::fftw_complex_type* fftw_cast_array(std::complex<F>* ptr) {
13  return reinterpret_cast<typename traits<F>::fftw_complex_type*>(ptr);
14 }
15 
16 template <typename F>
17 typename traits<F>::fftw_complex_type const*
18 fftw_cast_array(std::complex<F> const* ptr) {
19  return reinterpret_cast<typename traits<F>::fftw_complex_type const*>(ptr);
20 }
21 
22 template <typename F>
23 F* fftw_cast_array(F* ptr) {
24  return ptr;
25 }
26 
27 template <typename F>
28 F const* fftw_cast_array(F const* ptr) {
29  return ptr;
30 }
31 
32 template <typename vector>
33 auto fftw_cast(vector& in) -> decltype(fftw_cast_array(&in[0])) {
34  return fftw_cast_array(&in[0]);
35 }
36 
37 template <typename vector>
38 auto fftw_cast(vector const& in) -> decltype(fftw_cast_array(&in[0])) {
39  return fftw_cast_array(&in[0]);
40 }
41 
42 template <typename T, std::size_t K, typename A>
43 auto fftw_cast(boost::multi_array<T, K, A> const& a)
44  -> decltype(fftw_cast_array(a.data())) {
45  return fftw_cast_array(a.data());
46 }
47 
48 template <typename T, std::size_t K, typename A>
49 auto fftw_cast(boost::multi_array<T, K, A>& a)
50  -> decltype(fftw_cast_array(a.data())) {
51  return fftw_cast_array(a.data());
52 }
53 
54 } // namespace fftw
55 } // namespace jb
56 
57 #endif // jb_fftw_cast_hpp
Wrap fftw_* types and operations to treat floating point values generically.
Definition: traits.hpp:22
traits< F >::fftw_complex_type * fftw_cast_array(std::complex< F > *ptr)
Definition: cast.hpp:12
auto fftw_cast(vector &in) -> decltype(fftw_cast_array(&in[0]))
Definition: cast.hpp:33
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7