Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
TimeFrequency.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
25 #include "cheetah/data/cuda/CornerTurn.h"
26 #include "panda/Copy.h"
27 
28 namespace ska {
29 namespace cheetah {
30 namespace data {
31 
32 
33 template <typename NumericalT>
34 TimeFrequency<Cuda, NumericalT>::TimeFrequency(TimeFrequency<Cuda, NumericalT> const& tf)
35  : CommonBase(tf)
36  , _data(tf.number_of_channels()*tf.number_of_spectra())
37  , _number_of_channels(tf.number_of_channels())
38  , _number_of_spectra(tf.number_of_spectra())
39 {
40  panda::copy(tf.begin(), tf.end(), _data.begin());
41 }
42 
43 template <typename NumericalT>
44 template <typename OtherArch, typename OtherNumericalT>
45 TimeFrequency<Cuda, NumericalT>::TimeFrequency(TimeFrequency<OtherArch, OtherNumericalT> const& tf)
46  : CommonBase(tf)
47  , _data(tf.number_of_channels()*tf.number_of_spectra())
48  , _number_of_channels(tf.number_of_channels())
49  , _number_of_spectra(tf.number_of_spectra())
50 {
51  panda::copy(tf.begin(), tf.end(), _data.begin());
52 }
53 
54 
55 template <typename NumericalT>
56 template <typename OtherArch>
57 TimeFrequency<Cuda, NumericalT>::TimeFrequency(TimeFrequency<OtherArch, NumericalT> const& tf)
58  : CommonBase(tf)
59  , _data(tf.number_of_channels()*tf.number_of_spectra())
60  , _number_of_channels(tf.number_of_channels())
61  , _number_of_spectra(tf.number_of_spectra())
62 {
63  panda::copy(tf.begin(), tf.end(), _data.begin());
64 }
65 
66 template <typename NumericalT>
67 template <typename OtherNumericalT>
68 TimeFrequency<Cuda, NumericalT>::TimeFrequency(FrequencyTime<Cuda, OtherNumericalT> const& ft)
69  : CommonBase(ft)
70  , _data(ft.number_of_channels()*ft.number_of_spectra())
71  , _number_of_channels(ft.number_of_channels())
72  , _number_of_spectra(ft.number_of_spectra())
73 {
74  cuda::corner_turn(&(*ft.begin()), (&(*_data.begin())), ft.number_of_spectra(), ft.number_of_channels());
75 }
76 
77 
78 template <typename NumericalT>
79 template <typename OtherNumericalT>
80 TimeFrequency<Cuda, NumericalT>::TimeFrequency(FrequencyTime<Cpu, OtherNumericalT> const& ft)
81  : CommonBase(ft)
82  , _data(ft.number_of_channels()*ft.number_of_spectra())
83  , _number_of_channels(ft.number_of_channels())
84  , _number_of_spectra(ft.number_of_spectra())
85  //: TimeFrequency(FrequencyTime<Cuda, OtherNumericalT>(ft))
86 {
87  auto ft_copy = FrequencyTime<Cuda, OtherNumericalT>(ft);
88  //panda::copy(ft.begin(), ft.end(), ft_copy.begin());
89  cuda::corner_turn(&(*ft_copy.begin()), (&(*_data.begin())), ft.number_of_spectra(), ft.number_of_channels());
90 }
91 
92 template <typename NumericalT>
93 typename TimeFrequency<Cuda, NumericalT>::Iterator TimeFrequency<Cuda, NumericalT>::begin()
94 {
95  return _data.begin();
96 }
97 
98 template <typename NumericalT>
99 typename TimeFrequency<Cuda, NumericalT>::ConstIterator TimeFrequency<Cuda, NumericalT>::begin() const
100 {
101  return _data.begin();
102 }
103 
104 template <typename NumericalT>
105 typename TimeFrequency<Cuda, NumericalT>::ConstIterator TimeFrequency<Cuda, NumericalT>::cbegin() const
106 {
107  return _data.cbegin();
108 }
109 
110 template <typename NumericalT>
111 typename TimeFrequency<Cuda, NumericalT>::Iterator TimeFrequency<Cuda, NumericalT>::end()
112 {
113  return _data.end();
114 }
115 
116 template <typename NumericalT>
117 typename TimeFrequency<Cuda, NumericalT>::ConstIterator TimeFrequency<Cuda, NumericalT>::end() const
118 {
119  return _data.end();
120 }
121 
122 template <typename NumericalT>
123 typename TimeFrequency<Cuda, NumericalT>::ConstIterator TimeFrequency<Cuda, NumericalT>::cend() const
124 {
125  return _data.cend();
126 }
127 
128 template <typename NumericalT>
130 {
131  return _number_of_channels;
132 }
133 
134 template <typename NumericalT>
136 {
137  return _number_of_spectra;
138 }
139 
140 } //namespace ska
141 } //namespace cheetah
142 } //namespace data
Some limits and constants for FLDO.
Definition: Brdz.h:35
std::size_t number_of_channels() const
std::size_t number_of_spectra() const