panwave
All Classes Functions
WaveletPacketTreeTemplateBase.h
1 //-------------------------------------------------------------------------------------------------------
2 // Copyright (C) Taylor Woll and panwave contributors. All rights reserved.
3 // Licensed under the MIT license. See LICENSE.txt file in the project root for
4 // full license information.
5 //-------------------------------------------------------------------------------------------------------
6 
7 #ifndef WAVELETPACKETTREETEMPLATEBASE_H
8 #define WAVELETPACKETTREETEMPLATEBASE_H
9 
10 #include <vector>
11 
12 #include "Tree.h"
13 #include "WaveletPacketTreeBase.h"
14 
15 namespace panwave {
21 template <size_t k>
23  : public Tree<WaveletPacketTreeBase::WaveletPacketTreeNodeData, k>,
24  public WaveletPacketTreeBase {
25  public:
26  WaveletPacketTreeTemplateBase(size_t height, const Wavelet* wavelet)
29  wavelet_(wavelet) {}
30 
31  void SetRootSignal(const std::vector<double>* signal) override {
32  assert(signal);
33 
34  auto& data = this->GetNodeData(0);
35  data.signal.assign(signal->cbegin(), signal->cend());
36  }
37 
38  const std::vector<double>* GetRootSignal() override {
39  return &this->GetNodeData(0).signal;
40  }
41 
42  size_t GetWaveletLevelCount() const override {
43  return static_cast<size_t>(std::pow(2, this->GetHeight() - 1));
44  }
45 
46  protected:
47  const Wavelet* wavelet_;
48 };
49 
50 } // namespace panwave
51 
52 #endif // WAVELETPACKETTREETEMPLATEBASE_H
panwave::Wavelet
Definition: Wavelet.h:21
panwave::WaveletPacketTreeBase
Definition: WaveletPacketTreeBase.h:21
panwave::Tree< WaveletPacketTreeBase::WaveletPacketTreeNodeData, k >::GetHeight
size_t GetHeight() const
Definition: Tree.h:143
panwave::WaveletPacketTreeTemplateBase::GetWaveletLevelCount
size_t GetWaveletLevelCount() const override
Definition: WaveletPacketTreeTemplateBase.h:42
panwave::WaveletPacketTreeTemplateBase::GetRootSignal
const std::vector< double > * GetRootSignal() override
Definition: WaveletPacketTreeTemplateBase.h:38
panwave::Tree
Definition: Tree.h:32
panwave::Tree< WaveletPacketTreeBase::WaveletPacketTreeNodeData, k >::GetNodeData
WaveletPacketTreeBase::WaveletPacketTreeNodeData & GetNodeData(size_t index)
Definition: Tree.h:106
panwave::WaveletPacketTreeTemplateBase::SetRootSignal
void SetRootSignal(const std::vector< double > *signal) override
Definition: WaveletPacketTreeTemplateBase.h:31
panwave::WaveletPacketTreeTemplateBase
Definition: WaveletPacketTreeTemplateBase.h:22