My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interpolator.h
Go to the documentation of this file.
1 /*
2  * interpolator.h - interpolator class definitions
3  *
4  * Copyright (C) 2009 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id: interpolator.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __INTERPOLATOR_H__
26 #define __INTERPOLATOR_H__
27 
28 // Type of data and interpolators.
29 #define INTERPOL_LINEAR 1
30 #define INTERPOL_CUBIC 2
31 #define INTERPOL_HOLD 4
32 
33 #define REPEAT_NO 1
34 #define REPEAT_YES 2
35 
36 #define DATA_RECTANGULAR 0x0100
37 #define DATA_POLAR 0x0200
38 #define DATA_MASK_DOMAIN 0xFF00
39 #define DATA_COMPLEX 0x0001
40 #define DATA_REAL 0x0002
41 #define DATA_MASK_TYPE 0x00FF
42 
44 {
45  public:
46  interpolator ();
47  ~interpolator ();
48 
49  void vectors (nr_double_t *, nr_double_t *, int);
50  void vectors (nr_complex_t *, nr_double_t *, int);
51  void rvectors (vector *, vector *);
52  void cvectors (vector *, vector *);
53  void prepare (int, int, int domain = DATA_RECTANGULAR);
54  nr_double_t rinterpolate (nr_double_t);
55  nr_complex_t cinterpolate (nr_double_t);
56 
57 private:
58  int findIndex (nr_double_t);
59  int findIndex_old (nr_double_t);
60  nr_double_t linear (nr_double_t,
61  nr_double_t, nr_double_t, nr_double_t, nr_double_t);
62  nr_double_t rlinear (nr_double_t, int);
63  nr_complex_t clinear (nr_double_t, int);
64  void cleanup (void);
65 
66 private:
67  int dataType;
68  int interpolType;
69  int repeat;
70  int length;
71  nr_double_t * rx;
72  nr_double_t * ry;
73  nr_double_t duration;
74  spline * rsp, * isp;
75  nr_complex_t * cy;
76 };
77 
78 #endif /* __INTERPOLATOR_H__ */