bump to -rc12
[gnucap-felix.git] / src / m_spline.h
blobfa387a589eee1e1fe0ba30b0b2014700f42b8bf3
1 /*$Id: m_spline.h,v 1.1 2009-10-23 12:01:45 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * piecewise polynomial interpolation
23 * Constructor args:
24 * table : a vector of xy pairs, all of the data points.
25 * d0, dn: boundary conditions -- value of the first derivative at boundaries.
26 * order : order of interpolating polynomial, must be in {0, 1, 2, 3}.
28 * Outside the range, the result is linearly extrapolated with slope d0, dn.
29 * ("clamped" splines)
31 * If d0 or dn is set to NOT_INPUT, it is a "natural" spline, with the
32 * derivative being determined by the data.
33 * See any numerical analysis text for explanation.
35 //testing=trivial 2006.07.17
36 #ifndef M_SPLINE_H
37 #define M_SPLINE_H
38 #include "u_parameter.h"
39 /*--------------------------------------------------------------------------*/
40 struct FPOLY1;
41 /*--------------------------------------------------------------------------*/
42 class INTERFACE SPLINE {
43 private:
44 int _n;
45 double* _x;
46 double* _f0;
47 double* _f1;
48 double* _f2;
49 double* _f3;
50 int _order;
51 double _d0;
53 void construct_order_3(double* h, double d0, double dn);
54 void construct_order_2(double* h, double d0, double dn);
55 void construct_order_1(double* h, double d0, double dn);
56 public:
57 SPLINE(const std::vector<DPAIR>& table,
58 double d0, double dn, int order);
59 SPLINE(const std::vector<std::pair<PARAMETER<double>,PARAMETER<double> > >& table,
60 double d0, double dn, int order);
61 ~SPLINE();
62 FPOLY1 at(double x)const;
64 /*--------------------------------------------------------------------------*/
65 /*--------------------------------------------------------------------------*/
66 #endif
67 // vim:ts=8:sw=2:noet: