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)
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
21 *------------------------------------------------------------------
22 * piecewise polynomial interpolation
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.
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
38 #include "u_parameter.h"
39 /*--------------------------------------------------------------------------*/
41 /*--------------------------------------------------------------------------*/
42 class INTERFACE SPLINE
{
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
);
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
);
62 FPOLY1
at(double x
)const;
64 /*--------------------------------------------------------------------------*/
65 /*--------------------------------------------------------------------------*/
67 // vim:ts=8:sw=2:noet: