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 #include "cheetah/data/TimeFrequency.h"
25 #include "cheetah/data/FrequencyTime.h"
26 #include "panda/Copy.h"
27 #include <type_traits>
28 
29 namespace ska {
30 namespace cheetah {
31 namespace data {
32 
33 template <class Arch, typename NumericalT>
35  : BaseT( pss::astrotypes::DimensionSize<Frequency>(0)
36  , pss::astrotypes::DimensionSize<Time>(0))
37 {}
38 
39 template <class Arch, typename NumericalT>
40 TimeFrequency<Arch, NumericalT>::TimeFrequency(DimensionSize<Time> number_of_spectra, DimensionSize<Frequency> number_of_channels)
41  : BaseT( number_of_channels, number_of_spectra)
42 {
43 }
44 
45 template <class Arch, typename NumericalT>
46 TimeFrequency<Arch, NumericalT>::TimeFrequency(DimensionSize<Frequency> number_of_channels, DimensionSize<Time> number_of_spectra)
47  : BaseT( number_of_channels, number_of_spectra)
48 {
49 }
50 
51 template<class Arch, typename NumericalT>
52 template<class OtherArch, typename OtherNumericalT>
54  : BaseT(DimensionSize<Frequency>(tf.number_of_channels()), DimensionSize<Time>(tf.number_of_spectra()))
55  , CommonBaseT(tf)
56 {
57  panda::copy(tf.begin(), tf.end(), this->begin());
58 }
59 
60 template <class Arch, typename NumericalT>
61 template<typename OtherNumericalT>
63  : BaseT(ft)
64  , CommonBaseT(ft)
65 {
66 }
67 
68 template <class Arch, typename NumericalT>
69 template<typename OtherArch, typename OtherNumericalT>
70 TimeFrequency<Arch, NumericalT>::TimeFrequency(const FrequencyTime<OtherArch, OtherNumericalT>& ft)
71  : BaseT(DimensionSize<Frequency>(ft.number_of_channels()), DimensionSize<Time>(ft.number_of_spectra()))
72  , CommonBaseT(ft)
73 {
75  panda::copy(tf_copy.begin(), tf_copy.end(), this->begin());
76 }
77 
78 template <class Arch, typename NumericalT>
80 {
81  return this->template dimension<Frequency>();
82 }
83 
84 template <class Arch, typename NumericalT>
86 {
87  return this->template dimension<Time>();
88 }
89 
90 template<class Arch, typename NumericalT>
91 void TimeFrequency<Arch, NumericalT>::set_channel(unsigned channel_number, DataType const& data)
92 {
93  Channel channel = this->channel(channel_number);
94  std::fill(channel.begin(), channel.end(), data);
95 }
96 
97 template<class Arch, typename NumericalT>
99 {
100  return static_cast<BaseT const&>(*this) == static_cast<BaseT const&>(o);
101 }
102 
103 template<typename T>
105 {
106 };
107 
108 template<typename T>
110 {
111  typedef typename ExtractTimeFrequencyDataType<T>::type type;
112  inline static type& exctract(T& t) { return ExtractTimeFrequencyDataType<T>::extract(*t); }
113 };
114 
115 template<typename T>
116 struct ExtractTimeFrequencyDataType<std::unique_ptr<T>>
117 {
118  typedef typename ExtractTimeFrequencyDataType<T>::type type;
119  inline static type& exctract(T& t) { return ExtractTimeFrequencyDataType<T>::extract(*t); }
120 };
121 
122 template <class Arch, typename NumericalT>
124 {
126  inline static type& exctract(type& t) { return t; }
127 };
128 
129 } // namespace data
130 } // namespace cheetah
131 } // namespace ska
132 
extract the TimeFrequency data type from compound types
Some limits and constants for FLDO.
Definition: Brdz.h:35
uint8_t DataType
the underlying data storage type for the amplitude of the signal
Definition: TimeFrequency.h:96
std::size_t number_of_channels() const
std::size_t number_of_spectra() const