NADCON5-ng
0.0.1
NADCON5 Next Generation
Home
Project Documentation
Code Documentation
Index
File List
File Members
cubterp.f
Go to the documentation of this file.
1
c> \ingroup core
2
c> This function fits a cubic function through four points
3
c>
4
c> This function fits a cubic function through
5
c> four *equally* spaced points along the x-axis
6
c> at indices 0, 1, 2 and 3. The spacing along the
7
c> x-axis is "dx"
8
c>
9
c> Thus:
10
c>
11
c> \f{eqnarray*}{
12
c> f0 = f_0 &= y(x_0) \\
13
c> f1 = f_1 &= y(x_1) \\
14
c> f2 = f_2 &= y(x_2) \\
15
c> f3 = f_3 &= y(x_3)
16
c> \f}
17
c>
18
c> Where:
19
c>
20
c> \f{eqnarray*}{
21
c> x_1 &= x_0 + dx \\
22
c> x_2 &= x_1 + dx \\
23
c> x_3 &= x_2 + dx
24
c> \f}
25
c>
26
c> The input value is some value of "x" that falls
27
c> between 0 and 3. The output value (cubterp) is
28
c> the cubic function at x.
29
c>
30
c>
31
c> \param[in] x Compute Interpolation at this positon, a value between 0 and 3
32
c> it is scaled relative to `x_0` `x_3` and `dx`. For example,
33
c> a value of 1.5 is `x_0 + 1.5*dx` which falls between `x1` and `x2`
34
c> \param[in] f0 `y` value at `x_0`
35
c> \param[in] f1 `y` value at `x_1 = x_0 + dx`
36
c> \param[in] f2 `y` value at `x_2 = x_0 + dx`
37
c> \param[in] f3 `y` value at `x_3 = x_0 + dx``
38
c>
39
c> This function uses Newton-Gregory forward polynomial
40
c>
41
c> \f{eqnarray*}{
42
c> \nabla f_0 &=& f_1 -f_0 \\
43
c> \nabla f_1 &=& f_2 -f_1 \\
44
c> \nabla^2 f_0 &=& \nabla f_1 - \nabla f_0 \\
45
c> cubterp(x, f_0, f_1, f_2, f_3) &=& f_0 + x \nabla f_0 + 0.5 x \left( x-1.0 \right) \nabla^2 f_0
46
c> \f}
47
real
function
cubterp
(x,f0,f1,f2,f3)
48
49
c - x = real*4
50
c - f0,f1,f2,f3 = real*4
51
52
c - This function fits a cubic function through
53
c - four points, *equally* spaced along the x-axis
54
c - at indices 0, 1, 2 and 3. The spacing along the
55
c - x-axis is "dx"
56
c - Thus:
57
c -
58
c - f0 = y(x(0))
59
c - f1 = y(x(1))
60
c - f2 = y(x(2))
61
c - f3 = y(x(3))
62
c - Where
63
c - x(1) = x(0) + dx
64
c - x(2) = x(1) + dx
65
c - x(3) = x(2) + dx
66
67
c - The input value is some value of "x" that falls
68
c - between 0 and 3. The output value (cubterp) is
69
c - the cubic function at x.
70
c -
71
c - This function uses Newton-Gregory forward polynomial
72
73
c df0 =f1 -f0
74
c df1 =f2 -f1
75
c d2f0=df1-df0
76
77
c qterp=f0 + x*df0 + 0.5*x*(x-1.0)*d2f0
78
79
df0 = f1 - f0
80
df1 = f2 - f1
81
df2 = f3 - f2
82
83
d2f0 = df1 - df0
84
d2f1 = df2 - df1
85
86
d3f0 = d2f1 - d2f0
87
88
cubterp
=f0 + x*df0 + 0.5*x*(x-1.0)*d2f0
89
* +(1.0/6.0)*d3f0*x*(x-1.0)*(x-2.0)
90
91
return
92
end
cubterp
real function cubterp(x, f0, f1, f2, f3)
This function fits a cubic function through four points.
Definition:
cubterp.f:48
src
Subs
cubterp.f
Generated on Mon Nov 20 2017 16:14:46 for NADCON5-ng by
1.8.11