File: svdmitigater.h

package info (click to toggle)
aoflagger 3.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,004 kB
  • sloc: cpp: 67,891; python: 497; sh: 242; makefile: 22
file content (76 lines) | stat: -rw-r--r-- 1,864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef SVDMITIGATER_H
#define SVDMITIGATER_H

#include <iostream>

#include "../structures/image2d.h"
#include "../structures/timefrequencydata.h"

// Needs to be included LAST
#include "../util/f2c.h"

class XYPlot;

namespace algorithms {

class SVDMitigater final {
 public:
  SVDMitigater();
  ~SVDMitigater();

  void Initialize(const TimeFrequencyData& data) {
    Clear();
    _data = data;
    _iteration = 0;
  }
  void PerformFit() {
    _iteration++;
    RemoveSingularValues(_removeCount);
  }
  void PerformFit(unsigned) { PerformFit(); }

  void RemoveSingularValues(unsigned singularValueCount) {
    if (!IsDecomposed()) Decompose();
    for (unsigned i = 0; i < singularValueCount; ++i) SetSingularValue(i, 0.0);
    Compose();
  }

  TimeFrequencyData Background() const { return *_background; }

  enum TimeFrequencyData::ComplexRepresentation ComplexRepresentation() const {
    return TimeFrequencyData::ComplexParts;
  }

  bool IsDecomposed() const throw() { return _singularValues != nullptr; }
  double SingularValue(unsigned index) const throw() {
    return _singularValues[index];
  }
  void SetRemoveCount(unsigned removeCount) throw() {
    _removeCount = removeCount;
  }
  void SetVerbose(bool verbose) throw() { _verbose = verbose; }
  static void CreateSingularValueGraph(const TimeFrequencyData& data,
                                       class XYPlot& plot);

 private:
  void Clear();
  void Decompose();
  void Compose();
  void SetSingularValue(unsigned index, double newValue) throw() {
    _singularValues[index] = newValue;
  }

  TimeFrequencyData _data;
  TimeFrequencyData* _background;
  double* _singularValues;
  doublecomplex* _leftSingularVectors;
  doublecomplex* _rightSingularVectors;
  long int _m, _n;
  unsigned _iteration;
  unsigned _removeCount;
  bool _verbose;
};

}  // namespace algorithms

#endif