Qucs-core  0.0.19
spline.h
Go to the documentation of this file.
00001 /*
00002  * spline.h - spline class definitions
00003  *
00004  * Copyright (C) 2005, 2006, 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 __SPLINE_H__
00026 #define __SPLINE_H__
00027 
00028 #include <vector>
00029 #include "tvector.h"
00030 
00031 namespace qucs {
00032 
00033 // Types of boundary conditions.
00034 enum spline_boundary_type {
00035   SPLINE_BC_UNKNOWN = -1,
00036   SPLINE_BC_NATURAL,       // natural splines -- zero derivatives
00037   SPLINE_BC_CLAMPED,       // endpoint derivatives given
00038   SPLINE_BC_PERIODIC       // periodic splines
00039 };
00040 
00041 class vector;
00042 class poly;
00043 
00044 class spline
00045 {
00046  public:
00047   spline ();
00048   spline (int);
00049   spline (tvector<nr_double_t>, tvector<nr_double_t>);
00050   spline (qucs::vector, qucs::vector);
00051   spline (::std::vector<nr_double_t>, ::std::vector<nr_double_t>);
00052   ~spline ();
00053 
00054   void vectors (qucs::vector, qucs::vector);
00055   void vectors (tvector<nr_double_t>, tvector<nr_double_t>);
00056   void vectors (::std::vector<nr_double_t>, ::std::vector<nr_double_t>);
00057   void vectors (nr_double_t *, nr_double_t *, int);
00058   void construct (void);
00059   poly evaluate (nr_double_t);
00060   void setBoundary (int b) { boundary = b; }
00061   void setDerivatives (nr_double_t l, nr_double_t r) { d0 = l; dn = r; }
00062 
00063  private:
00064   nr_double_t * upper_bound (nr_double_t *, nr_double_t *, nr_double_t);
00065   void realloc (int);
00066 
00067  private:
00068   nr_double_t * x;
00069   nr_double_t * f0;
00070   nr_double_t * f1;
00071   nr_double_t * f2;
00072   nr_double_t * f3;
00073   nr_double_t d0, dn;
00074   int n;
00075   int boundary;
00076 };
00077 
00078 } // namespace qucs
00079 
00080 #endif /* __SPLINE_H__ */