Qucs-core  0.0.19
interpolator.h
Go to the documentation of this file.
00001 /*
00002  * interpolator.h - interpolator class definitions
00003  *
00004  * Copyright (C) 2009 Stefan Jahn <stefan@lkcc.org>
00005  *
00006  * This is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this package; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  * $Id$
00022  *
00023  */
00024 
00025 #ifndef __INTERPOLATOR_H__
00026 #define __INTERPOLATOR_H__
00027 
00028 // Type of data and interpolators.
00029 #define INTERPOL_LINEAR  1
00030 #define INTERPOL_CUBIC   2
00031 #define INTERPOL_HOLD    4
00032 
00033 #define REPEAT_NO        1
00034 #define REPEAT_YES       2
00035 
00036 #define DATA_RECTANGULAR 0x0100
00037 #define DATA_POLAR       0x0200
00038 #define DATA_MASK_DOMAIN 0xFF00
00039 #define DATA_COMPLEX     0x0001
00040 #define DATA_REAL        0x0002
00041 #define DATA_MASK_TYPE   0x00FF
00042 
00043 namespace qucs {
00044 
00045 class interpolator
00046 {
00047  public:
00048   interpolator ();
00049   ~interpolator ();
00050 
00051   void vectors (nr_double_t *, nr_double_t *, int);
00052   void vectors (nr_complex_t *, nr_double_t *, int);
00053   void rvectors (qucs::vector *, qucs::vector *);
00054   void cvectors (qucs::vector *, qucs::vector *);
00055   void prepare (int, int, int domain = DATA_RECTANGULAR);
00056   nr_double_t rinterpolate (nr_double_t);
00057   nr_complex_t cinterpolate (nr_double_t);
00058 
00059 private:
00060   int findIndex (nr_double_t);
00061   int findIndex_old (nr_double_t);
00062   nr_double_t linear (nr_double_t,
00063                       nr_double_t, nr_double_t, nr_double_t, nr_double_t);
00064   nr_double_t rlinear (nr_double_t, int);
00065   nr_complex_t clinear (nr_double_t, int);
00066   void cleanup (void);
00067 
00068 private:
00069   int dataType;
00070   int interpolType;
00071   int repeat;
00072   int length;
00073   nr_double_t * rx;
00074   nr_double_t * ry;
00075   nr_double_t duration;
00076   spline * rsp, * isp;
00077   nr_complex_t * cy;
00078 };
00079 
00080 } // namespace qucs
00081 
00082 #endif /* __INTERPOLATOR_H__ */