Newer
Older
/* cspline
Cubic spline fitting and interpolation
Tim Behrens, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
/* CCOPYRIGHT */
#if !defined(__cspline_h)
#define __cspline_h
#include <string>
#include <iostream>
#include <fstream>
#include "newmatap.h"
#include "newmatio.h"
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#define WANT_STREAM
#define WANT_MATH
using namespace NEWMAT;
using namespace std;
///////////////////////////////////////////////////////
namespace MISCMATHS {
class Cspline{
public:
Cspline();
Cspline(ColumnVector& pnodes,ColumnVector& pvals):
nodes(pnodes),
vals(pvals),
n(nodes.Nrows())
{
fit();
fitted=true;
}
Cspline(ColumnVector& pnodes, Matrix& pcoefs) :
nodes(pnodes),
coefs(pcoefs),
n(nodes.Nrows())
{ fitted=true;}
~Cspline(){
fitted=false;
};
void set(ColumnVector& pnodes,ColumnVector& pvals);
void set(ColumnVector& pnodes, Matrix& pcoefs);
void fit();
float interpolate(float xx) const;
float interpolate(float xx,int ind) const;
ColumnVector interpolate(const ColumnVector& x) const;
ColumnVector interpolate(const ColumnVector& x, const ColumnVector& indvec) const;
protected:
bool fitted;
ColumnVector nodes;
ColumnVector vals;
Matrix coefs;
int n;
void diff(const ColumnVector& x, ColumnVector& dx );
};
}
#endif