kwave  18.07.70
Interpolation.h
Go to the documentation of this file.
1 /***************************************************************************
2  Interpolation.h - Interpolation types
3  -------------------
4  begin : Sat Feb 03 2001
5  copyright : (C) 2001 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef INTERPOLATION_H
18 #define INTERPOLATION_H
19 
20 #include "config.h"
21 
22 #include <QtGlobal>
23 #include <QString>
24 #include <QStringList>
25 #include <QVector>
26 
27 #include "libkwave/TypesMap.h"
28 
29 namespace Kwave
30 {
31 
32  class Curve;
33 
34  typedef enum {
43 
47  class Q_DECL_EXPORT Interpolation
48  {
49  public:
52 
54  virtual ~Interpolation();
55 
56  bool prepareInterpolation(const Kwave::Curve &points);
57 
58  QVector<double> interpolation(const Kwave::Curve &points,
59  unsigned int len);
60 
61  QVector<double> limitedInterpolation(const Kwave::Curve &points,
62  unsigned int len);
63 
67  double singleInterpolation(double pos);
68 
76  double singleLimitedInterpolation(double pos);
77 
83  static Kwave::interpolation_t find(const QString &name)
84  {
85  return m_interpolation_map.findFromName(name);
86  }
87 
92  static QString name(Kwave::interpolation_t type);
93 
101  static QStringList descriptions(bool localized = false);
102 
104  inline void setType (Kwave::interpolation_t t) {
105  m_type = t;
106  }
107 
110  return m_type;
111  }
112 
114  static inline Kwave::interpolation_t findByIndex(int index) {
115  return m_interpolation_map.findFromData(index);
116  }
117 
124  public Kwave::TypesMap<Kwave::interpolation_t, int >
125  {
126  public:
127 
129  explicit InterpolationMap()
130  :TypesMap<Kwave::interpolation_t, int >()
131  {
132  fill();
133  }
134 
136  virtual void fill() Q_DECL_OVERRIDE;
137  };
138 
139  private:
140 
142  unsigned int count();
143 
150  void createFullPolynom(const Kwave::Curve &points,
151  QVector<double> &x,
152  QVector<double> &y);
153 
161  void get2Derivate(const QVector<double> &x,
162  const QVector<double> &y,
163  QVector<double> &ab, unsigned int n);
164 
173  void createPolynom (const Kwave::Curve &points,
174  QVector<double> &x,
175  QVector<double> &y,
176  int pos, unsigned int degree);
177 
178  private:
179 
182 
184  QVector<double> m_x;
185 
187  QVector<double> m_y;
188 
190  QVector<double> m_der;
191 
194 
197 
198  };
199 
200  //***********************************************************************
202  {
203  return (i = (i == INTPOL_SAH) ?
204  INTPOL_LINEAR :
205  Kwave::interpolation_t(i + 1) );
206  }
207 
208 }
209 
210 #endif /* INTERPOLATION_H */
211 
212 //***************************************************************************
213 //***************************************************************************
Kwave::interpolation_t type()
Definition: App.h:33
Kwave::interpolation_t m_type
interpolation_t
Definition: Interpolation.h:34
QVector< double > m_y
static InterpolationMap m_interpolation_map
const Kwave::Curve * m_curve
static Kwave::interpolation_t findByIndex(int index)
QVector< double > m_der
const char name[16]
Definition: memcpy.c:510
QVector< double > m_x
static FileProperty operator++(FileProperty &prop)
Definition: FileInfo.h:104
static Kwave::interpolation_t find(const QString &name)
Definition: Interpolation.h:83
void setType(Kwave::interpolation_t t)