nmrspectrumsolver.h
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #ifndef NMRSPECTRUMSOLVER_H_
15 #define NMRSPECTRUMSOLVER_H_
16 //---------------------------------------------------------------------------
17 #include "support.h"
18 #include "spectrumsolver.h"
19 #include "xitemnode.h"
20 
21 #ifdef HAVE_LAPACK
22  #define USE_FREQ_ESTM
23 #endif
24 
25 class SpectrumSolverWrapper : public XNode {
26 public:
27  SpectrumSolverWrapper(const char *name, bool runtime,
28  const shared_ptr<XComboNode> selector, const shared_ptr<XComboNode> windowfunc,
29  const shared_ptr<XDoubleNode> windowlength, bool leastsqureonly = false);
30  virtual ~SpectrumSolverWrapper();
31 
32  struct Payload : public XNode::Payload {
33  Payload() : XNode::Payload() {}
34  Payload(const Payload &x) : XNode::Payload(x) {
35  if(x.m_wrapper)
36  m_wrapper.reset(x.m_wrapper->clone());
37  }
38  SpectrumSolver &solver() {return m_wrapper->solver();}
39  const SpectrumSolver &solver() const {return m_wrapper->solver();}
40  private:
41  friend class SpectrumSolverWrapper;
42  struct WrapperBase {
43  virtual ~WrapperBase() = default;
44  virtual WrapperBase *clone() = 0;
45  virtual SpectrumSolver &solver() = 0;
46  virtual const SpectrumSolver &solver() const = 0;
47  };
48  template <class T>
49  struct Wrapper : public WrapperBase {
50  Wrapper(T *p) : m_solver(p) {}
51  virtual Wrapper* clone() { return new Wrapper(new T( *m_solver)); }
52  virtual T &solver() {return *m_solver; }
53  virtual const T &solver() const {return *m_solver; }
54  private:
55  Wrapper();
56  unique_ptr<T> m_solver;
57  };
58  shared_ptr<WrapperBase> m_wrapper;
59  };
60 
61  static const char SPECTRUM_SOLVER_ZF_FFT[];
62  static const char SPECTRUM_SOLVER_MEM_STRICT[];
63  static const char SPECTRUM_SOLVER_MEM_STRICT_BURG[];
64  static const char SPECTRUM_SOLVER_MEM_BURG_AICc[];
65  static const char SPECTRUM_SOLVER_MEM_BURG_MDL[];
66  static const char SPECTRUM_SOLVER_AR_YW_AICc[];
67  static const char SPECTRUM_SOLVER_AR_YW_MDL[];
68 #ifdef USE_FREQ_ESTM
69  static const char SPECTRUM_SOLVER_MEM_STRICT_EV[];
70  static const char SPECTRUM_SOLVER_MUSIC_AIC[];
71  static const char SPECTRUM_SOLVER_MUSIC_MDL[];
72  static const char SPECTRUM_SOLVER_EV_AIC[];
73  static const char SPECTRUM_SOLVER_EV_MDL[];
74  static const char SPECTRUM_SOLVER_MVDL[];
75 #endif
76  static const char SPECTRUM_SOLVER_LS_HQ[];
77  static const char SPECTRUM_SOLVER_LS_AICc[];
78  static const char SPECTRUM_SOLVER_LS_MDL[];
79 
80  static const char WINDOW_FUNC_DEFAULT[];
81  static const char WINDOW_FUNC_HANNING[];
82  static const char WINDOW_FUNC_HAMMING[];
83  static const char WINDOW_FUNC_FLATTOP[];
84  static const char WINDOW_FUNC_BLACKMAN[];
85  static const char WINDOW_FUNC_BLACKMAN_HARRIS[];
86  static const char WINDOW_FUNC_KAISER_1[];
87  static const char WINDOW_FUNC_KAISER_2[];
88  static const char WINDOW_FUNC_KAISER_3[];
89 
90  FFT::twindowfunc windowFunc(const Snapshot &shot) const;
91  void windowFuncs(std::deque<FFT::twindowfunc> &funcs) const;
92 private:
93  const shared_ptr<XComboNode> m_selector, m_windowfunc;
94  const shared_ptr<XDoubleNode> m_windowlength;
95  shared_ptr<XListener> m_lsnOnChanged;
96  void onSolverChanged(const Snapshot &shot, XValueNodeBase *);
97 };
98 
99 #endif /*NMRSPECTRUMSOLVER_H_*/

Generated for KAME4 by  doxygen 1.8.3