My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
spline.h
Go to the documentation of this file.
1 /*
2  * spline.h - spline class definitions
3  *
4  * Copyright (C) 2005, 2006, 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: spline.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __SPLINE_H__
26 #define __SPLINE_H__
27 
28 #include "tvector.h"
29 
30 // Types of boundary conditions.
33  SPLINE_BC_NATURAL, // natural splines -- zero derivatives
34  SPLINE_BC_CLAMPED, // endpoint derivatives given
35  SPLINE_BC_PERIODIC // periodic splines
36 };
37 
38 class vector;
39 class poly;
40 
41 class spline
42 {
43  public:
44  spline ();
45  spline (int);
46  spline (vector, vector);
48  ~spline ();
49 
50  void vectors (vector, vector);
52  void vectors (nr_double_t *, nr_double_t *, int);
53  void construct (void);
54  poly evaluate (nr_double_t);
55  void setBoundary (int b) { boundary = b; }
56  void setDerivatives (nr_double_t l, nr_double_t r) { d0 = l; dn = r; }
57 
58  private:
59  nr_double_t * upper_bound (nr_double_t *, nr_double_t *, nr_double_t);
60  void realloc (int);
61 
62  private:
63  nr_double_t * x;
64  nr_double_t * f0;
65  nr_double_t * f1;
66  nr_double_t * f2;
67  nr_double_t * f3;
68  nr_double_t d0, dn;
69  int n;
70  int boundary;
71 };
72 
73 #endif /* __SPLINE_H__ */