ar.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 AR_H_
15 #define AR_H_
16 
17 #include "spectrumsolver.h"
18 
19 //! Base class for YuleWalker AR and Burg's MEM.
20 //! The object holds a list of \a Context in order to search for the minimum of the information criteria.
21 //! \sa YuleWalkerAR, BurgMEM
22 template <class Context>
24 public:
25  YuleWalkerCousin(tfuncIC ic);
26  virtual ~YuleWalkerCousin() {}
27 protected:
28  virtual void genSpectrum(const std::vector<std::complex<double> >& memin, std::vector<std::complex<double> >& memout,
29  int t0, double tol, FFT::twindowfunc windowfunc, double windowlength);
30 
31  //! Infomation Criterion for AR.
32  double arIC(double sigma2, int p, int t) {
33  return m_funcARIC(-0.5 * t * log(sigma2), p + 1, t);
34  }
35 
36  virtual void first(
37  const std::vector<std::complex<double> >& memin, const shared_ptr<Context> &context) = 0;
38  //! Steps Levinson recursion.
39  virtual void step(const shared_ptr<Context> &context) = 0;
40  std::deque<shared_ptr<Context> > m_contexts;
41 private:
42  const tfuncIC m_funcARIC;
43 };
44 
45 struct DECLSPEC_KAME ARContext {
46  ARContext() {}
47  ARContext(const ARContext &c) : a(c.a), sigma2(c.sigma2), p(c.p), t(c.t) {}
48  std::vector<std::complex<double> > a;
49  double sigma2;
50  unsigned int p;
51  unsigned int t;
52 };
53 struct DECLSPEC_KAME MEMBurgContext : public ARContext {
54  MEMBurgContext() : ARContext() {}
55  MEMBurgContext(const MEMBurgContext &c) : ARContext(c), eta(c.eta), epsilon(c.epsilon) {}
56  std::vector<std::complex<double> > eta, epsilon;
57 };
58 
59 //! Burg's MEM (Maximum Entropy Method).
60 //! \sa YuleWalkerAR
61 class DECLSPEC_KAME MEMBurg : public YuleWalkerCousin<MEMBurgContext> {
62 public:
63  MEMBurg(tfuncIC ic = &icAICc) : YuleWalkerCousin<MEMBurgContext>(ic) {}
64  virtual ~MEMBurg() {}
65 protected:
66  virtual void first(
67  const std::vector<std::complex<double> >& memin, const shared_ptr<MEMBurgContext> &context);
68  virtual void step(const shared_ptr<MEMBurgContext> &context);
69 private:
70 
71 };
72 
73 //! Yule-Walker AR (Auto-Regressive model) by Levinson-Durbin algorithm.
74 //! \sa MEMBurg
75 class DECLSPEC_KAME YuleWalkerAR : public YuleWalkerCousin<ARContext> {
76 public:
77  YuleWalkerAR(tfuncIC ic = &icAICc) : YuleWalkerCousin<ARContext>(ic) {}
78  virtual ~YuleWalkerAR() {}
79 protected:
80  virtual void first(
81  const std::vector<std::complex<double> >& memin, const shared_ptr<ARContext> &context);
82  virtual void step(const shared_ptr<ARContext> &context);
83 private:
84  //! Auto-regression.
85  std::vector<std::complex<double> > m_rx;
86 };
87 
88 #endif /*AR_H_*/

Generated for KAME4 by  doxygen 1.8.3