alglib 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +253 -0
- data/README.txt +33 -0
- data/Rakefile +27 -0
- data/ext/Rakefile +24 -0
- data/ext/alglib.i +24 -0
- data/ext/alglib/Makefile +157 -0
- data/ext/alglib/airyf.cpp +372 -0
- data/ext/alglib/airyf.h +81 -0
- data/ext/alglib/alglib.cpp +8558 -0
- data/ext/alglib/alglib_util.cpp +19 -0
- data/ext/alglib/alglib_util.h +14 -0
- data/ext/alglib/ap.cpp +877 -0
- data/ext/alglib/ap.english.html +364 -0
- data/ext/alglib/ap.h +666 -0
- data/ext/alglib/ap.russian.html +442 -0
- data/ext/alglib/apvt.h +754 -0
- data/ext/alglib/bdss.cpp +1500 -0
- data/ext/alglib/bdss.h +251 -0
- data/ext/alglib/bdsvd.cpp +1339 -0
- data/ext/alglib/bdsvd.h +164 -0
- data/ext/alglib/bessel.cpp +1226 -0
- data/ext/alglib/bessel.h +331 -0
- data/ext/alglib/betaf.cpp +105 -0
- data/ext/alglib/betaf.h +74 -0
- data/ext/alglib/bidiagonal.cpp +1328 -0
- data/ext/alglib/bidiagonal.h +350 -0
- data/ext/alglib/binomialdistr.cpp +247 -0
- data/ext/alglib/binomialdistr.h +153 -0
- data/ext/alglib/blas.cpp +576 -0
- data/ext/alglib/blas.h +132 -0
- data/ext/alglib/cblas.cpp +226 -0
- data/ext/alglib/cblas.h +57 -0
- data/ext/alglib/cdet.cpp +138 -0
- data/ext/alglib/cdet.h +92 -0
- data/ext/alglib/chebyshev.cpp +216 -0
- data/ext/alglib/chebyshev.h +76 -0
- data/ext/alglib/chisquaredistr.cpp +157 -0
- data/ext/alglib/chisquaredistr.h +144 -0
- data/ext/alglib/cholesky.cpp +285 -0
- data/ext/alglib/cholesky.h +86 -0
- data/ext/alglib/cinverse.cpp +298 -0
- data/ext/alglib/cinverse.h +111 -0
- data/ext/alglib/clu.cpp +337 -0
- data/ext/alglib/clu.h +120 -0
- data/ext/alglib/correlation.cpp +280 -0
- data/ext/alglib/correlation.h +77 -0
- data/ext/alglib/correlationtests.cpp +726 -0
- data/ext/alglib/correlationtests.h +134 -0
- data/ext/alglib/crcond.cpp +826 -0
- data/ext/alglib/crcond.h +148 -0
- data/ext/alglib/creflections.cpp +310 -0
- data/ext/alglib/creflections.h +165 -0
- data/ext/alglib/csolve.cpp +312 -0
- data/ext/alglib/csolve.h +99 -0
- data/ext/alglib/ctrinverse.cpp +387 -0
- data/ext/alglib/ctrinverse.h +98 -0
- data/ext/alglib/ctrlinsolve.cpp +297 -0
- data/ext/alglib/ctrlinsolve.h +81 -0
- data/ext/alglib/dawson.cpp +234 -0
- data/ext/alglib/dawson.h +74 -0
- data/ext/alglib/descriptivestatistics.cpp +436 -0
- data/ext/alglib/descriptivestatistics.h +112 -0
- data/ext/alglib/det.cpp +140 -0
- data/ext/alglib/det.h +94 -0
- data/ext/alglib/dforest.cpp +1819 -0
- data/ext/alglib/dforest.h +316 -0
- data/ext/alglib/elliptic.cpp +497 -0
- data/ext/alglib/elliptic.h +217 -0
- data/ext/alglib/estnorm.cpp +429 -0
- data/ext/alglib/estnorm.h +107 -0
- data/ext/alglib/expintegrals.cpp +422 -0
- data/ext/alglib/expintegrals.h +108 -0
- data/ext/alglib/faq.english.html +258 -0
- data/ext/alglib/faq.russian.html +272 -0
- data/ext/alglib/fdistr.cpp +202 -0
- data/ext/alglib/fdistr.h +163 -0
- data/ext/alglib/fresnel.cpp +211 -0
- data/ext/alglib/fresnel.h +91 -0
- data/ext/alglib/gammaf.cpp +338 -0
- data/ext/alglib/gammaf.h +104 -0
- data/ext/alglib/gqgengauss.cpp +235 -0
- data/ext/alglib/gqgengauss.h +92 -0
- data/ext/alglib/gqgenhermite.cpp +268 -0
- data/ext/alglib/gqgenhermite.h +63 -0
- data/ext/alglib/gqgenjacobi.cpp +297 -0
- data/ext/alglib/gqgenjacobi.h +72 -0
- data/ext/alglib/gqgenlaguerre.cpp +265 -0
- data/ext/alglib/gqgenlaguerre.h +69 -0
- data/ext/alglib/gqgenlegendre.cpp +300 -0
- data/ext/alglib/gqgenlegendre.h +62 -0
- data/ext/alglib/gqgenlobatto.cpp +305 -0
- data/ext/alglib/gqgenlobatto.h +97 -0
- data/ext/alglib/gqgenradau.cpp +232 -0
- data/ext/alglib/gqgenradau.h +95 -0
- data/ext/alglib/hbisinv.cpp +480 -0
- data/ext/alglib/hbisinv.h +183 -0
- data/ext/alglib/hblas.cpp +228 -0
- data/ext/alglib/hblas.h +64 -0
- data/ext/alglib/hcholesky.cpp +339 -0
- data/ext/alglib/hcholesky.h +91 -0
- data/ext/alglib/hermite.cpp +114 -0
- data/ext/alglib/hermite.h +49 -0
- data/ext/alglib/hessenberg.cpp +370 -0
- data/ext/alglib/hessenberg.h +152 -0
- data/ext/alglib/hevd.cpp +247 -0
- data/ext/alglib/hevd.h +107 -0
- data/ext/alglib/hsschur.cpp +1316 -0
- data/ext/alglib/hsschur.h +108 -0
- data/ext/alglib/htridiagonal.cpp +734 -0
- data/ext/alglib/htridiagonal.h +180 -0
- data/ext/alglib/ialglib.cpp +6 -0
- data/ext/alglib/ialglib.h +9 -0
- data/ext/alglib/ibetaf.cpp +960 -0
- data/ext/alglib/ibetaf.h +125 -0
- data/ext/alglib/igammaf.cpp +430 -0
- data/ext/alglib/igammaf.h +157 -0
- data/ext/alglib/inv.cpp +274 -0
- data/ext/alglib/inv.h +115 -0
- data/ext/alglib/inverseupdate.cpp +480 -0
- data/ext/alglib/inverseupdate.h +185 -0
- data/ext/alglib/jacobianelliptic.cpp +164 -0
- data/ext/alglib/jacobianelliptic.h +94 -0
- data/ext/alglib/jarquebera.cpp +2271 -0
- data/ext/alglib/jarquebera.h +80 -0
- data/ext/alglib/kmeans.cpp +356 -0
- data/ext/alglib/kmeans.h +76 -0
- data/ext/alglib/laguerre.cpp +94 -0
- data/ext/alglib/laguerre.h +48 -0
- data/ext/alglib/lbfgs.cpp +1167 -0
- data/ext/alglib/lbfgs.h +218 -0
- data/ext/alglib/lda.cpp +434 -0
- data/ext/alglib/lda.h +133 -0
- data/ext/alglib/ldlt.cpp +1130 -0
- data/ext/alglib/ldlt.h +124 -0
- data/ext/alglib/leastsquares.cpp +1252 -0
- data/ext/alglib/leastsquares.h +290 -0
- data/ext/alglib/legendre.cpp +107 -0
- data/ext/alglib/legendre.h +49 -0
- data/ext/alglib/linreg.cpp +1185 -0
- data/ext/alglib/linreg.h +380 -0
- data/ext/alglib/logit.cpp +1523 -0
- data/ext/alglib/logit.h +333 -0
- data/ext/alglib/lq.cpp +399 -0
- data/ext/alglib/lq.h +160 -0
- data/ext/alglib/lu.cpp +462 -0
- data/ext/alglib/lu.h +119 -0
- data/ext/alglib/mannwhitneyu.cpp +4490 -0
- data/ext/alglib/mannwhitneyu.h +115 -0
- data/ext/alglib/minlm.cpp +918 -0
- data/ext/alglib/minlm.h +312 -0
- data/ext/alglib/mlpbase.cpp +3375 -0
- data/ext/alglib/mlpbase.h +589 -0
- data/ext/alglib/mlpe.cpp +1369 -0
- data/ext/alglib/mlpe.h +552 -0
- data/ext/alglib/mlptrain.cpp +1056 -0
- data/ext/alglib/mlptrain.h +283 -0
- data/ext/alglib/nearunityunit.cpp +91 -0
- data/ext/alglib/nearunityunit.h +17 -0
- data/ext/alglib/normaldistr.cpp +377 -0
- data/ext/alglib/normaldistr.h +175 -0
- data/ext/alglib/nsevd.cpp +1869 -0
- data/ext/alglib/nsevd.h +140 -0
- data/ext/alglib/pca.cpp +168 -0
- data/ext/alglib/pca.h +87 -0
- data/ext/alglib/poissondistr.cpp +143 -0
- data/ext/alglib/poissondistr.h +130 -0
- data/ext/alglib/polinterpolation.cpp +685 -0
- data/ext/alglib/polinterpolation.h +206 -0
- data/ext/alglib/psif.cpp +173 -0
- data/ext/alglib/psif.h +88 -0
- data/ext/alglib/qr.cpp +414 -0
- data/ext/alglib/qr.h +168 -0
- data/ext/alglib/ratinterpolation.cpp +134 -0
- data/ext/alglib/ratinterpolation.h +72 -0
- data/ext/alglib/rcond.cpp +705 -0
- data/ext/alglib/rcond.h +140 -0
- data/ext/alglib/reflections.cpp +504 -0
- data/ext/alglib/reflections.h +165 -0
- data/ext/alglib/rotations.cpp +473 -0
- data/ext/alglib/rotations.h +128 -0
- data/ext/alglib/rsolve.cpp +221 -0
- data/ext/alglib/rsolve.h +99 -0
- data/ext/alglib/sbisinv.cpp +217 -0
- data/ext/alglib/sbisinv.h +171 -0
- data/ext/alglib/sblas.cpp +185 -0
- data/ext/alglib/sblas.h +64 -0
- data/ext/alglib/schur.cpp +156 -0
- data/ext/alglib/schur.h +102 -0
- data/ext/alglib/sdet.cpp +193 -0
- data/ext/alglib/sdet.h +101 -0
- data/ext/alglib/sevd.cpp +116 -0
- data/ext/alglib/sevd.h +99 -0
- data/ext/alglib/sinverse.cpp +672 -0
- data/ext/alglib/sinverse.h +138 -0
- data/ext/alglib/spddet.cpp +138 -0
- data/ext/alglib/spddet.h +96 -0
- data/ext/alglib/spdgevd.cpp +842 -0
- data/ext/alglib/spdgevd.h +200 -0
- data/ext/alglib/spdinverse.cpp +509 -0
- data/ext/alglib/spdinverse.h +122 -0
- data/ext/alglib/spdrcond.cpp +421 -0
- data/ext/alglib/spdrcond.h +118 -0
- data/ext/alglib/spdsolve.cpp +275 -0
- data/ext/alglib/spdsolve.h +105 -0
- data/ext/alglib/spline2d.cpp +1192 -0
- data/ext/alglib/spline2d.h +301 -0
- data/ext/alglib/spline3.cpp +1264 -0
- data/ext/alglib/spline3.h +290 -0
- data/ext/alglib/srcond.cpp +595 -0
- data/ext/alglib/srcond.h +127 -0
- data/ext/alglib/ssolve.cpp +895 -0
- data/ext/alglib/ssolve.h +139 -0
- data/ext/alglib/stdafx.h +0 -0
- data/ext/alglib/stest.cpp +131 -0
- data/ext/alglib/stest.h +94 -0
- data/ext/alglib/studenttdistr.cpp +222 -0
- data/ext/alglib/studenttdistr.h +115 -0
- data/ext/alglib/studentttests.cpp +377 -0
- data/ext/alglib/studentttests.h +178 -0
- data/ext/alglib/svd.cpp +620 -0
- data/ext/alglib/svd.h +126 -0
- data/ext/alglib/tdbisinv.cpp +2608 -0
- data/ext/alglib/tdbisinv.h +228 -0
- data/ext/alglib/tdevd.cpp +1229 -0
- data/ext/alglib/tdevd.h +115 -0
- data/ext/alglib/tridiagonal.cpp +594 -0
- data/ext/alglib/tridiagonal.h +171 -0
- data/ext/alglib/trigintegrals.cpp +490 -0
- data/ext/alglib/trigintegrals.h +131 -0
- data/ext/alglib/trinverse.cpp +345 -0
- data/ext/alglib/trinverse.h +98 -0
- data/ext/alglib/trlinsolve.cpp +926 -0
- data/ext/alglib/trlinsolve.h +73 -0
- data/ext/alglib/tsort.cpp +405 -0
- data/ext/alglib/tsort.h +54 -0
- data/ext/alglib/variancetests.cpp +245 -0
- data/ext/alglib/variancetests.h +134 -0
- data/ext/alglib/wsr.cpp +6285 -0
- data/ext/alglib/wsr.h +96 -0
- data/ext/ap.i +97 -0
- data/ext/correlation.i +24 -0
- data/ext/extconf.rb +6 -0
- data/ext/logit.i +89 -0
- data/lib/alglib.rb +71 -0
- data/lib/alglib/correlation.rb +26 -0
- data/lib/alglib/linearregression.rb +63 -0
- data/lib/alglib/logit.rb +42 -0
- data/test/test_alglib.rb +52 -0
- data/test/test_correlation.rb +44 -0
- data/test/test_correlationtest.rb +45 -0
- data/test/test_linreg.rb +35 -0
- data/test/test_logit.rb +43 -0
- data/test/test_pca.rb +27 -0
- metadata +326 -0
@@ -0,0 +1,1192 @@
|
|
1
|
+
/*************************************************************************
|
2
|
+
Copyright (c) 2007, Sergey Bochkanov (ALGLIB project).
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are
|
6
|
+
met:
|
7
|
+
|
8
|
+
- Redistributions of source code must retain the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
- Redistributions in binary form must reproduce the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer listed
|
13
|
+
in this license in the documentation and/or other materials
|
14
|
+
provided with the distribution.
|
15
|
+
|
16
|
+
- Neither the name of the copyright holders nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*************************************************************************/
|
32
|
+
|
33
|
+
#include <stdafx.h>
|
34
|
+
#include "spline2d.h"
|
35
|
+
|
36
|
+
static void bicubiccalcderivatives(const ap::real_2d_array& a,
|
37
|
+
const ap::real_1d_array& x,
|
38
|
+
const ap::real_1d_array& y,
|
39
|
+
int m,
|
40
|
+
int n,
|
41
|
+
ap::real_2d_array& dx,
|
42
|
+
ap::real_2d_array& dy,
|
43
|
+
ap::real_2d_array& dxy);
|
44
|
+
|
45
|
+
/*************************************************************************
|
46
|
+
This subroutine builds bilinear spline coefficients table.
|
47
|
+
|
48
|
+
Input parameters:
|
49
|
+
X - spline abscissas, array[0..N-1]
|
50
|
+
Y - spline ordinates, array[0..M-1]
|
51
|
+
F - function values, array[0..M-1,0..N-1]
|
52
|
+
M,N - grid size, M>=2, N>=2
|
53
|
+
|
54
|
+
Output parameters:
|
55
|
+
C - coefficients table. Used by SplineInterpolation2D and other
|
56
|
+
subroutines from this file.
|
57
|
+
|
58
|
+
-- ALGLIB PROJECT --
|
59
|
+
Copyright 05.07.2007 by Bochkanov Sergey
|
60
|
+
*************************************************************************/
|
61
|
+
void buildbilinearspline(ap::real_1d_array x,
|
62
|
+
ap::real_1d_array y,
|
63
|
+
ap::real_2d_array f,
|
64
|
+
int m,
|
65
|
+
int n,
|
66
|
+
ap::real_1d_array& c)
|
67
|
+
{
|
68
|
+
int i;
|
69
|
+
int j;
|
70
|
+
int k;
|
71
|
+
int tblsize;
|
72
|
+
int shift;
|
73
|
+
double t;
|
74
|
+
ap::real_2d_array dx;
|
75
|
+
ap::real_2d_array dy;
|
76
|
+
ap::real_2d_array dxy;
|
77
|
+
|
78
|
+
ap::ap_error::make_assertion(n>=2&&m>=2, "BuildBilinearSpline: N<2 or M<2!");
|
79
|
+
|
80
|
+
//
|
81
|
+
// Sort points
|
82
|
+
//
|
83
|
+
for(j = 0; j <= n-1; j++)
|
84
|
+
{
|
85
|
+
k = j;
|
86
|
+
for(i = j+1; i <= n-1; i++)
|
87
|
+
{
|
88
|
+
if( x(i)<x(k) )
|
89
|
+
{
|
90
|
+
k = i;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
if( k!=j )
|
94
|
+
{
|
95
|
+
for(i = 0; i <= m-1; i++)
|
96
|
+
{
|
97
|
+
t = f(i,j);
|
98
|
+
f(i,j) = f(i,k);
|
99
|
+
f(i,k) = t;
|
100
|
+
}
|
101
|
+
t = x(j);
|
102
|
+
x(j) = x(k);
|
103
|
+
x(k) = t;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
for(i = 0; i <= m-1; i++)
|
107
|
+
{
|
108
|
+
k = i;
|
109
|
+
for(j = i+1; j <= m-1; j++)
|
110
|
+
{
|
111
|
+
if( y(j)<y(k) )
|
112
|
+
{
|
113
|
+
k = j;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
if( k!=i )
|
117
|
+
{
|
118
|
+
for(j = 0; j <= n-1; j++)
|
119
|
+
{
|
120
|
+
t = f(i,j);
|
121
|
+
f(i,j) = f(k,j);
|
122
|
+
f(k,j) = t;
|
123
|
+
}
|
124
|
+
t = y(i);
|
125
|
+
y(i) = y(k);
|
126
|
+
y(k) = t;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
//
|
131
|
+
// Fill C:
|
132
|
+
// C[0] - length(C)
|
133
|
+
// C[1] - type(C):
|
134
|
+
// -1 = bilinear interpolant
|
135
|
+
// -3 = general cubic spline
|
136
|
+
// (see BuildBicubicSpline)
|
137
|
+
// C[2]:
|
138
|
+
// N (x count)
|
139
|
+
// C[3]:
|
140
|
+
// M (y count)
|
141
|
+
// C[4]...C[4+N-1]:
|
142
|
+
// x[i], i = 0...N-1
|
143
|
+
// C[4+N]...C[4+N+M-1]:
|
144
|
+
// y[i], i = 0...M-1
|
145
|
+
// C[4+N+M]...C[4+N+M+(N*M-1)]:
|
146
|
+
// f(i,j) table. f(0,0), f(0, 1), f(0,2) and so on...
|
147
|
+
//
|
148
|
+
tblsize = 4+n+m+n*m;
|
149
|
+
c.setbounds(0, tblsize-1);
|
150
|
+
c(0) = tblsize;
|
151
|
+
c(1) = -1;
|
152
|
+
c(2) = n;
|
153
|
+
c(3) = m;
|
154
|
+
for(i = 0; i <= n-1; i++)
|
155
|
+
{
|
156
|
+
c(4+i) = x(i);
|
157
|
+
}
|
158
|
+
for(i = 0; i <= m-1; i++)
|
159
|
+
{
|
160
|
+
c(4+n+i) = y(i);
|
161
|
+
}
|
162
|
+
for(i = 0; i <= m-1; i++)
|
163
|
+
{
|
164
|
+
for(j = 0; j <= n-1; j++)
|
165
|
+
{
|
166
|
+
shift = i*n+j;
|
167
|
+
c(4+n+m+shift) = f(i,j);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
/*************************************************************************
|
174
|
+
This subroutine builds bicubic spline coefficients table.
|
175
|
+
|
176
|
+
Input parameters:
|
177
|
+
X - spline abscissas, array[0..N-1]
|
178
|
+
Y - spline ordinates, array[0..M-1]
|
179
|
+
F - function values, array[0..M-1,0..N-1]
|
180
|
+
M,N - grid size, M>=2, N>=2
|
181
|
+
|
182
|
+
Output parameters:
|
183
|
+
C - coefficients table. Used by SplineInterpolation2D and other
|
184
|
+
subroutines from this file.
|
185
|
+
|
186
|
+
-- ALGLIB PROJECT --
|
187
|
+
Copyright 05.07.2007 by Bochkanov Sergey
|
188
|
+
*************************************************************************/
|
189
|
+
void buildbicubicspline(ap::real_1d_array x,
|
190
|
+
ap::real_1d_array y,
|
191
|
+
ap::real_2d_array f,
|
192
|
+
int m,
|
193
|
+
int n,
|
194
|
+
ap::real_1d_array& c)
|
195
|
+
{
|
196
|
+
int i;
|
197
|
+
int j;
|
198
|
+
int k;
|
199
|
+
int tblsize;
|
200
|
+
int shift;
|
201
|
+
double t;
|
202
|
+
ap::real_2d_array dx;
|
203
|
+
ap::real_2d_array dy;
|
204
|
+
ap::real_2d_array dxy;
|
205
|
+
|
206
|
+
ap::ap_error::make_assertion(n>=2&&m>=2, "BuildBicubicSpline: N<2 or M<2!");
|
207
|
+
|
208
|
+
//
|
209
|
+
// Sort points
|
210
|
+
//
|
211
|
+
for(j = 0; j <= n-1; j++)
|
212
|
+
{
|
213
|
+
k = j;
|
214
|
+
for(i = j+1; i <= n-1; i++)
|
215
|
+
{
|
216
|
+
if( x(i)<x(k) )
|
217
|
+
{
|
218
|
+
k = i;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
if( k!=j )
|
222
|
+
{
|
223
|
+
for(i = 0; i <= m-1; i++)
|
224
|
+
{
|
225
|
+
t = f(i,j);
|
226
|
+
f(i,j) = f(i,k);
|
227
|
+
f(i,k) = t;
|
228
|
+
}
|
229
|
+
t = x(j);
|
230
|
+
x(j) = x(k);
|
231
|
+
x(k) = t;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
for(i = 0; i <= m-1; i++)
|
235
|
+
{
|
236
|
+
k = i;
|
237
|
+
for(j = i+1; j <= m-1; j++)
|
238
|
+
{
|
239
|
+
if( y(j)<y(k) )
|
240
|
+
{
|
241
|
+
k = j;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
if( k!=i )
|
245
|
+
{
|
246
|
+
for(j = 0; j <= n-1; j++)
|
247
|
+
{
|
248
|
+
t = f(i,j);
|
249
|
+
f(i,j) = f(k,j);
|
250
|
+
f(k,j) = t;
|
251
|
+
}
|
252
|
+
t = y(i);
|
253
|
+
y(i) = y(k);
|
254
|
+
y(k) = t;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
//
|
259
|
+
// Fill C:
|
260
|
+
// C[0] - length(C)
|
261
|
+
// C[1] - type(C):
|
262
|
+
// -1 = bilinear interpolant
|
263
|
+
// (see BuildBilinearInterpolant)
|
264
|
+
// -3 = general cubic spline
|
265
|
+
// C[2]:
|
266
|
+
// N (x count)
|
267
|
+
// C[3]:
|
268
|
+
// M (y count)
|
269
|
+
// C[4]...C[4+N-1]:
|
270
|
+
// x[i], i = 0...N-1
|
271
|
+
// C[4+N]...C[4+N+M-1]:
|
272
|
+
// y[i], i = 0...M-1
|
273
|
+
// C[4+N+M]...C[4+N+M+(N*M-1)]:
|
274
|
+
// f(i,j) table. f(0,0), f(0, 1), f(0,2) and so on...
|
275
|
+
// C[4+N+M+N*M]...C[4+N+M+(2*N*M-1)]:
|
276
|
+
// df(i,j)/dx table.
|
277
|
+
// C[4+N+M+2*N*M]...C[4+N+M+(3*N*M-1)]:
|
278
|
+
// df(i,j)/dy table.
|
279
|
+
// C[4+N+M+3*N*M]...C[4+N+M+(4*N*M-1)]:
|
280
|
+
// d2f(i,j)/dxdy table.
|
281
|
+
//
|
282
|
+
tblsize = 4+n+m+4*n*m;
|
283
|
+
c.setbounds(0, tblsize-1);
|
284
|
+
c(0) = tblsize;
|
285
|
+
c(1) = -3;
|
286
|
+
c(2) = n;
|
287
|
+
c(3) = m;
|
288
|
+
for(i = 0; i <= n-1; i++)
|
289
|
+
{
|
290
|
+
c(4+i) = x(i);
|
291
|
+
}
|
292
|
+
for(i = 0; i <= m-1; i++)
|
293
|
+
{
|
294
|
+
c(4+n+i) = y(i);
|
295
|
+
}
|
296
|
+
bicubiccalcderivatives(f, x, y, m, n, dx, dy, dxy);
|
297
|
+
for(i = 0; i <= m-1; i++)
|
298
|
+
{
|
299
|
+
for(j = 0; j <= n-1; j++)
|
300
|
+
{
|
301
|
+
shift = i*n+j;
|
302
|
+
c(4+n+m+shift) = f(i,j);
|
303
|
+
c(4+n+m+n*m+shift) = dx(i,j);
|
304
|
+
c(4+n+m+2*n*m+shift) = dy(i,j);
|
305
|
+
c(4+n+m+3*n*m+shift) = dxy(i,j);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
|
311
|
+
/*************************************************************************
|
312
|
+
This subroutine calculates the value of the bilinear or bicubic spline at
|
313
|
+
the given point X.
|
314
|
+
|
315
|
+
Input parameters:
|
316
|
+
C - coefficients table.
|
317
|
+
Built by BuildBilinearSpline or BuildBicubicSpline.
|
318
|
+
X, Y- point
|
319
|
+
|
320
|
+
Result:
|
321
|
+
S(x,y)
|
322
|
+
|
323
|
+
-- ALGLIB PROJECT --
|
324
|
+
Copyright 05.07.2007 by Bochkanov Sergey
|
325
|
+
*************************************************************************/
|
326
|
+
double splineinterpolation2d(const ap::real_1d_array& c, double x, double y)
|
327
|
+
{
|
328
|
+
double result;
|
329
|
+
double v;
|
330
|
+
double vx;
|
331
|
+
double vy;
|
332
|
+
double vxy;
|
333
|
+
|
334
|
+
splinedifferentiation2d(c, x, y, v, vx, vy, vxy);
|
335
|
+
result = v;
|
336
|
+
return result;
|
337
|
+
}
|
338
|
+
|
339
|
+
|
340
|
+
/*************************************************************************
|
341
|
+
This subroutine calculates the value of the bilinear or bicubic spline at
|
342
|
+
the given point X and its derivatives.
|
343
|
+
|
344
|
+
Input parameters:
|
345
|
+
C - coefficients table.
|
346
|
+
Built by BuildBilinearSpline or BuildBicubicSpline.
|
347
|
+
X, Y- point
|
348
|
+
|
349
|
+
Output parameters:
|
350
|
+
F - S(x,y)
|
351
|
+
FX - dS(x,y)/dX
|
352
|
+
FY - dS(x,y)/dY
|
353
|
+
FXY - d2S(x,y)/dXdY
|
354
|
+
|
355
|
+
-- ALGLIB PROJECT --
|
356
|
+
Copyright 05.07.2007 by Bochkanov Sergey
|
357
|
+
*************************************************************************/
|
358
|
+
void splinedifferentiation2d(const ap::real_1d_array& c,
|
359
|
+
double x,
|
360
|
+
double y,
|
361
|
+
double& f,
|
362
|
+
double& fx,
|
363
|
+
double& fy,
|
364
|
+
double& fxy)
|
365
|
+
{
|
366
|
+
int n;
|
367
|
+
int m;
|
368
|
+
double t;
|
369
|
+
double dt;
|
370
|
+
double u;
|
371
|
+
double du;
|
372
|
+
int i;
|
373
|
+
int j;
|
374
|
+
int ix;
|
375
|
+
int iy;
|
376
|
+
int l;
|
377
|
+
int r;
|
378
|
+
int h;
|
379
|
+
int shift1;
|
380
|
+
int s1;
|
381
|
+
int s2;
|
382
|
+
int s3;
|
383
|
+
int s4;
|
384
|
+
int sf;
|
385
|
+
int sfx;
|
386
|
+
int sfy;
|
387
|
+
int sfxy;
|
388
|
+
double y1;
|
389
|
+
double y2;
|
390
|
+
double y3;
|
391
|
+
double y4;
|
392
|
+
double v;
|
393
|
+
double t0;
|
394
|
+
double t1;
|
395
|
+
double t2;
|
396
|
+
double t3;
|
397
|
+
double u0;
|
398
|
+
double u1;
|
399
|
+
double u2;
|
400
|
+
double u3;
|
401
|
+
|
402
|
+
ap::ap_error::make_assertion(ap::round(c(1))==-1||ap::round(c(1))==-3, "TwoDimensionalInterpolation: incorrect C!");
|
403
|
+
n = ap::round(c(2));
|
404
|
+
m = ap::round(c(3));
|
405
|
+
|
406
|
+
//
|
407
|
+
// Binary search in the [ x[0], ..., x[n-2] ] (x[n-1] is not included)
|
408
|
+
//
|
409
|
+
l = 4;
|
410
|
+
r = 4+n-2+1;
|
411
|
+
while(l!=r-1)
|
412
|
+
{
|
413
|
+
h = (l+r)/2;
|
414
|
+
if( c(h)>=x )
|
415
|
+
{
|
416
|
+
r = h;
|
417
|
+
}
|
418
|
+
else
|
419
|
+
{
|
420
|
+
l = h;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
t = (x-c(l))/(c(l+1)-c(l));
|
424
|
+
dt = 1.0/(c(l+1)-c(l));
|
425
|
+
ix = l-4;
|
426
|
+
|
427
|
+
//
|
428
|
+
// Binary search in the [ y[0], ..., y[m-2] ] (y[m-1] is not included)
|
429
|
+
//
|
430
|
+
l = 4+n;
|
431
|
+
r = 4+n+(m-2)+1;
|
432
|
+
while(l!=r-1)
|
433
|
+
{
|
434
|
+
h = (l+r)/2;
|
435
|
+
if( c(h)>=y )
|
436
|
+
{
|
437
|
+
r = h;
|
438
|
+
}
|
439
|
+
else
|
440
|
+
{
|
441
|
+
l = h;
|
442
|
+
}
|
443
|
+
}
|
444
|
+
u = (y-c(l))/(c(l+1)-c(l));
|
445
|
+
du = 1.0/(c(l+1)-c(l));
|
446
|
+
iy = l-(4+n);
|
447
|
+
|
448
|
+
//
|
449
|
+
// Prepare F, dF/dX, dF/dY, d2F/dXdY
|
450
|
+
//
|
451
|
+
f = 0;
|
452
|
+
fx = 0;
|
453
|
+
fy = 0;
|
454
|
+
fxy = 0;
|
455
|
+
|
456
|
+
//
|
457
|
+
// Bilinear interpolation
|
458
|
+
//
|
459
|
+
if( ap::round(c(1))==-1 )
|
460
|
+
{
|
461
|
+
shift1 = 4+n+m;
|
462
|
+
y1 = c(shift1+n*iy+ix);
|
463
|
+
y2 = c(shift1+n*iy+(ix+1));
|
464
|
+
y3 = c(shift1+n*(iy+1)+(ix+1));
|
465
|
+
y4 = c(shift1+n*(iy+1)+ix);
|
466
|
+
f = (1-t)*(1-u)*y1+t*(1-u)*y2+t*u*y3+(1-t)*u*y4;
|
467
|
+
fx = (-(1-u)*y1+(1-u)*y2+u*y3-u*y4)*dt;
|
468
|
+
fy = (-(1-t)*y1-t*y2+t*y3+(1-t)*y4)*du;
|
469
|
+
fxy = (y1-y2+y3-y4)*du*dt;
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
|
473
|
+
//
|
474
|
+
// Bicubic interpolation
|
475
|
+
//
|
476
|
+
if( ap::round(c(1))==-3 )
|
477
|
+
{
|
478
|
+
|
479
|
+
//
|
480
|
+
// Prepare info
|
481
|
+
//
|
482
|
+
t0 = 1;
|
483
|
+
t1 = t;
|
484
|
+
t2 = ap::sqr(t);
|
485
|
+
t3 = t*t2;
|
486
|
+
u0 = 1;
|
487
|
+
u1 = u;
|
488
|
+
u2 = ap::sqr(u);
|
489
|
+
u3 = u*u2;
|
490
|
+
sf = 4+n+m;
|
491
|
+
sfx = 4+n+m+n*m;
|
492
|
+
sfy = 4+n+m+2*n*m;
|
493
|
+
sfxy = 4+n+m+3*n*m;
|
494
|
+
s1 = n*iy+ix;
|
495
|
+
s2 = n*iy+(ix+1);
|
496
|
+
s3 = n*(iy+1)+(ix+1);
|
497
|
+
s4 = n*(iy+1)+ix;
|
498
|
+
|
499
|
+
//
|
500
|
+
// Calculate
|
501
|
+
//
|
502
|
+
v = +1*c(sf+s1);
|
503
|
+
f = f+v*t0*u0;
|
504
|
+
v = +1*c(sfy+s1)/du;
|
505
|
+
f = f+v*t0*u1;
|
506
|
+
fy = fy+1*v*t0*u0*du;
|
507
|
+
v = -3*c(sf+s1)+3*c(sf+s4)-2*c(sfy+s1)/du-1*c(sfy+s4)/du;
|
508
|
+
f = f+v*t0*u2;
|
509
|
+
fy = fy+2*v*t0*u1*du;
|
510
|
+
v = +2*c(sf+s1)-2*c(sf+s4)+1*c(sfy+s1)/du+1*c(sfy+s4)/du;
|
511
|
+
f = f+v*t0*u3;
|
512
|
+
fy = fy+3*v*t0*u2*du;
|
513
|
+
v = +1*c(sfx+s1)/dt;
|
514
|
+
f = f+v*t1*u0;
|
515
|
+
fx = fx+1*v*t0*u0*dt;
|
516
|
+
v = +1*c(sfxy+s1)/(dt*du);
|
517
|
+
f = f+v*t1*u1;
|
518
|
+
fx = fx+1*v*t0*u1*dt;
|
519
|
+
fy = fy+1*v*t1*u0*du;
|
520
|
+
fxy = fxy+1*v*t0*u0*dt*du;
|
521
|
+
v = -3*c(sfx+s1)/dt+3*c(sfx+s4)/dt-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s4)/(dt*du);
|
522
|
+
f = f+v*t1*u2;
|
523
|
+
fx = fx+1*v*t0*u2*dt;
|
524
|
+
fy = fy+2*v*t1*u1*du;
|
525
|
+
fxy = fxy+2*v*t0*u1*dt*du;
|
526
|
+
v = +2*c(sfx+s1)/dt-2*c(sfx+s4)/dt+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s4)/(dt*du);
|
527
|
+
f = f+v*t1*u3;
|
528
|
+
fx = fx+1*v*t0*u3*dt;
|
529
|
+
fy = fy+3*v*t1*u2*du;
|
530
|
+
fxy = fxy+3*v*t0*u2*dt*du;
|
531
|
+
v = -3*c(sf+s1)+3*c(sf+s2)-2*c(sfx+s1)/dt-1*c(sfx+s2)/dt;
|
532
|
+
f = f+v*t2*u0;
|
533
|
+
fx = fx+2*v*t1*u0*dt;
|
534
|
+
v = -3*c(sfy+s1)/du+3*c(sfy+s2)/du-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s2)/(dt*du);
|
535
|
+
f = f+v*t2*u1;
|
536
|
+
fx = fx+2*v*t1*u1*dt;
|
537
|
+
fy = fy+1*v*t2*u0*du;
|
538
|
+
fxy = fxy+2*v*t1*u0*dt*du;
|
539
|
+
v = +9*c(sf+s1)-9*c(sf+s2)+9*c(sf+s3)-9*c(sf+s4)+6*c(sfx+s1)/dt+3*c(sfx+s2)/dt-3*c(sfx+s3)/dt-6*c(sfx+s4)/dt+6*c(sfy+s1)/du-6*c(sfy+s2)/du-3*c(sfy+s3)/du+3*c(sfy+s4)/du+4*c(sfxy+s1)/(dt*du)+2*c(sfxy+s2)/(dt*du)+1*c(sfxy+s3)/(dt*du)+2*c(sfxy+s4)/(dt*du);
|
540
|
+
f = f+v*t2*u2;
|
541
|
+
fx = fx+2*v*t1*u2*dt;
|
542
|
+
fy = fy+2*v*t2*u1*du;
|
543
|
+
fxy = fxy+4*v*t1*u1*dt*du;
|
544
|
+
v = -6*c(sf+s1)+6*c(sf+s2)-6*c(sf+s3)+6*c(sf+s4)-4*c(sfx+s1)/dt-2*c(sfx+s2)/dt+2*c(sfx+s3)/dt+4*c(sfx+s4)/dt-3*c(sfy+s1)/du+3*c(sfy+s2)/du+3*c(sfy+s3)/du-3*c(sfy+s4)/du-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s2)/(dt*du)-1*c(sfxy+s3)/(dt*du)-2*c(sfxy+s4)/(dt*du);
|
545
|
+
f = f+v*t2*u3;
|
546
|
+
fx = fx+2*v*t1*u3*dt;
|
547
|
+
fy = fy+3*v*t2*u2*du;
|
548
|
+
fxy = fxy+6*v*t1*u2*dt*du;
|
549
|
+
v = +2*c(sf+s1)-2*c(sf+s2)+1*c(sfx+s1)/dt+1*c(sfx+s2)/dt;
|
550
|
+
f = f+v*t3*u0;
|
551
|
+
fx = fx+3*v*t2*u0*dt;
|
552
|
+
v = +2*c(sfy+s1)/du-2*c(sfy+s2)/du+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s2)/(dt*du);
|
553
|
+
f = f+v*t3*u1;
|
554
|
+
fx = fx+3*v*t2*u1*dt;
|
555
|
+
fy = fy+1*v*t3*u0*du;
|
556
|
+
fxy = fxy+3*v*t2*u0*dt*du;
|
557
|
+
v = -6*c(sf+s1)+6*c(sf+s2)-6*c(sf+s3)+6*c(sf+s4)-3*c(sfx+s1)/dt-3*c(sfx+s2)/dt+3*c(sfx+s3)/dt+3*c(sfx+s4)/dt-4*c(sfy+s1)/du+4*c(sfy+s2)/du+2*c(sfy+s3)/du-2*c(sfy+s4)/du-2*c(sfxy+s1)/(dt*du)-2*c(sfxy+s2)/(dt*du)-1*c(sfxy+s3)/(dt*du)-1*c(sfxy+s4)/(dt*du);
|
558
|
+
f = f+v*t3*u2;
|
559
|
+
fx = fx+3*v*t2*u2*dt;
|
560
|
+
fy = fy+2*v*t3*u1*du;
|
561
|
+
fxy = fxy+6*v*t2*u1*dt*du;
|
562
|
+
v = +4*c(sf+s1)-4*c(sf+s2)+4*c(sf+s3)-4*c(sf+s4)+2*c(sfx+s1)/dt+2*c(sfx+s2)/dt-2*c(sfx+s3)/dt-2*c(sfx+s4)/dt+2*c(sfy+s1)/du-2*c(sfy+s2)/du-2*c(sfy+s3)/du+2*c(sfy+s4)/du+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s2)/(dt*du)+1*c(sfxy+s3)/(dt*du)+1*c(sfxy+s4)/(dt*du);
|
563
|
+
f = f+v*t3*u3;
|
564
|
+
fx = fx+3*v*t2*u3*dt;
|
565
|
+
fy = fy+3*v*t3*u2*du;
|
566
|
+
fxy = fxy+9*v*t2*u2*dt*du;
|
567
|
+
return;
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
571
|
+
|
572
|
+
/*************************************************************************
|
573
|
+
This subroutine unpacks two-dimensional spline into the coefficients table
|
574
|
+
|
575
|
+
Input parameters:
|
576
|
+
C - coefficients table.
|
577
|
+
|
578
|
+
Result:
|
579
|
+
M, N- grid size (x-axis and y-axis)
|
580
|
+
Tbl - coefficients table, unpacked format,
|
581
|
+
[0..(N-1)*(M-1)-1, 0..19].
|
582
|
+
For I = 0...M-2, J=0..N-2:
|
583
|
+
K = I*(N-1)+J
|
584
|
+
Tbl[K,0] = X[j]
|
585
|
+
Tbl[K,1] = X[j+1]
|
586
|
+
Tbl[K,2] = Y[i]
|
587
|
+
Tbl[K,3] = Y[i+1]
|
588
|
+
Tbl[K,4] = C00
|
589
|
+
Tbl[K,5] = C01
|
590
|
+
Tbl[K,6] = C02
|
591
|
+
Tbl[K,7] = C03
|
592
|
+
Tbl[K,8] = C10
|
593
|
+
Tbl[K,9] = C11
|
594
|
+
...
|
595
|
+
Tbl[K,19] = C33
|
596
|
+
On each grid square spline is equals to:
|
597
|
+
S(x) = SUM(c[i,j]*(x^i)*(y^j), i=0..3, j=0..3)
|
598
|
+
t = x-x[j]
|
599
|
+
u = y-y[i]
|
600
|
+
|
601
|
+
-- ALGLIB PROJECT --
|
602
|
+
Copyright 29.06.2007 by Bochkanov Sergey
|
603
|
+
*************************************************************************/
|
604
|
+
void splineunpack2d(const ap::real_1d_array& c,
|
605
|
+
int& m,
|
606
|
+
int& n,
|
607
|
+
ap::real_2d_array& tbl)
|
608
|
+
{
|
609
|
+
int i;
|
610
|
+
int j;
|
611
|
+
int ci;
|
612
|
+
int cj;
|
613
|
+
int k;
|
614
|
+
int p;
|
615
|
+
int shift;
|
616
|
+
int s1;
|
617
|
+
int s2;
|
618
|
+
int s3;
|
619
|
+
int s4;
|
620
|
+
int sf;
|
621
|
+
int sfx;
|
622
|
+
int sfy;
|
623
|
+
int sfxy;
|
624
|
+
double y1;
|
625
|
+
double y2;
|
626
|
+
double y3;
|
627
|
+
double y4;
|
628
|
+
double dt;
|
629
|
+
double du;
|
630
|
+
|
631
|
+
ap::ap_error::make_assertion(ap::round(c(1))==-3||ap::round(c(1))==-1, "SplineUnpack2D: incorrect C!");
|
632
|
+
n = ap::round(c(2));
|
633
|
+
m = ap::round(c(3));
|
634
|
+
tbl.setbounds(0, (n-1)*(m-1)-1, 0, 19);
|
635
|
+
|
636
|
+
//
|
637
|
+
// Fill
|
638
|
+
//
|
639
|
+
for(i = 0; i <= m-2; i++)
|
640
|
+
{
|
641
|
+
for(j = 0; j <= n-2; j++)
|
642
|
+
{
|
643
|
+
p = i*(n-1)+j;
|
644
|
+
tbl(p,0) = c(4+j);
|
645
|
+
tbl(p,1) = c(4+j+1);
|
646
|
+
tbl(p,2) = c(4+n+i);
|
647
|
+
tbl(p,3) = c(4+n+i+1);
|
648
|
+
dt = 1/(tbl(p,1)-tbl(p,0));
|
649
|
+
du = 1/(tbl(p,3)-tbl(p,2));
|
650
|
+
|
651
|
+
//
|
652
|
+
// Bilinear interpolation
|
653
|
+
//
|
654
|
+
if( ap::round(c(1))==-1 )
|
655
|
+
{
|
656
|
+
for(k = 4; k <= 19; k++)
|
657
|
+
{
|
658
|
+
tbl(p,k) = 0;
|
659
|
+
}
|
660
|
+
shift = 4+n+m;
|
661
|
+
y1 = c(shift+n*i+j);
|
662
|
+
y2 = c(shift+n*i+(j+1));
|
663
|
+
y3 = c(shift+n*(i+1)+(j+1));
|
664
|
+
y4 = c(shift+n*(i+1)+j);
|
665
|
+
tbl(p,4) = y1;
|
666
|
+
tbl(p,4+1*4+0) = y2-y1;
|
667
|
+
tbl(p,4+0*4+1) = y4-y1;
|
668
|
+
tbl(p,4+1*4+1) = y3-y2-y4+y1;
|
669
|
+
}
|
670
|
+
|
671
|
+
//
|
672
|
+
// Bicubic interpolation
|
673
|
+
//
|
674
|
+
if( ap::round(c(1))==-3 )
|
675
|
+
{
|
676
|
+
sf = 4+n+m;
|
677
|
+
sfx = 4+n+m+n*m;
|
678
|
+
sfy = 4+n+m+2*n*m;
|
679
|
+
sfxy = 4+n+m+3*n*m;
|
680
|
+
s1 = n*i+j;
|
681
|
+
s2 = n*i+(j+1);
|
682
|
+
s3 = n*(i+1)+(j+1);
|
683
|
+
s4 = n*(i+1)+j;
|
684
|
+
tbl(p,4+0*4+0) = +1*c(sf+s1);
|
685
|
+
tbl(p,4+0*4+1) = +1*c(sfy+s1)/du;
|
686
|
+
tbl(p,4+0*4+2) = -3*c(sf+s1)+3*c(sf+s4)-2*c(sfy+s1)/du-1*c(sfy+s4)/du;
|
687
|
+
tbl(p,4+0*4+3) = +2*c(sf+s1)-2*c(sf+s4)+1*c(sfy+s1)/du+1*c(sfy+s4)/du;
|
688
|
+
tbl(p,4+1*4+0) = +1*c(sfx+s1)/dt;
|
689
|
+
tbl(p,4+1*4+1) = +1*c(sfxy+s1)/(dt*du);
|
690
|
+
tbl(p,4+1*4+2) = -3*c(sfx+s1)/dt+3*c(sfx+s4)/dt-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s4)/(dt*du);
|
691
|
+
tbl(p,4+1*4+3) = +2*c(sfx+s1)/dt-2*c(sfx+s4)/dt+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s4)/(dt*du);
|
692
|
+
tbl(p,4+2*4+0) = -3*c(sf+s1)+3*c(sf+s2)-2*c(sfx+s1)/dt-1*c(sfx+s2)/dt;
|
693
|
+
tbl(p,4+2*4+1) = -3*c(sfy+s1)/du+3*c(sfy+s2)/du-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s2)/(dt*du);
|
694
|
+
tbl(p,4+2*4+2) = +9*c(sf+s1)-9*c(sf+s2)+9*c(sf+s3)-9*c(sf+s4)+6*c(sfx+s1)/dt+3*c(sfx+s2)/dt-3*c(sfx+s3)/dt-6*c(sfx+s4)/dt+6*c(sfy+s1)/du-6*c(sfy+s2)/du-3*c(sfy+s3)/du+3*c(sfy+s4)/du+4*c(sfxy+s1)/(dt*du)+2*c(sfxy+s2)/(dt*du)+1*c(sfxy+s3)/(dt*du)+2*c(sfxy+s4)/(dt*du);
|
695
|
+
tbl(p,4+2*4+3) = -6*c(sf+s1)+6*c(sf+s2)-6*c(sf+s3)+6*c(sf+s4)-4*c(sfx+s1)/dt-2*c(sfx+s2)/dt+2*c(sfx+s3)/dt+4*c(sfx+s4)/dt-3*c(sfy+s1)/du+3*c(sfy+s2)/du+3*c(sfy+s3)/du-3*c(sfy+s4)/du-2*c(sfxy+s1)/(dt*du)-1*c(sfxy+s2)/(dt*du)-1*c(sfxy+s3)/(dt*du)-2*c(sfxy+s4)/(dt*du);
|
696
|
+
tbl(p,4+3*4+0) = +2*c(sf+s1)-2*c(sf+s2)+1*c(sfx+s1)/dt+1*c(sfx+s2)/dt;
|
697
|
+
tbl(p,4+3*4+1) = +2*c(sfy+s1)/du-2*c(sfy+s2)/du+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s2)/(dt*du);
|
698
|
+
tbl(p,4+3*4+2) = -6*c(sf+s1)+6*c(sf+s2)-6*c(sf+s3)+6*c(sf+s4)-3*c(sfx+s1)/dt-3*c(sfx+s2)/dt+3*c(sfx+s3)/dt+3*c(sfx+s4)/dt-4*c(sfy+s1)/du+4*c(sfy+s2)/du+2*c(sfy+s3)/du-2*c(sfy+s4)/du-2*c(sfxy+s1)/(dt*du)-2*c(sfxy+s2)/(dt*du)-1*c(sfxy+s3)/(dt*du)-1*c(sfxy+s4)/(dt*du);
|
699
|
+
tbl(p,4+3*4+3) = +4*c(sf+s1)-4*c(sf+s2)+4*c(sf+s3)-4*c(sf+s4)+2*c(sfx+s1)/dt+2*c(sfx+s2)/dt-2*c(sfx+s3)/dt-2*c(sfx+s4)/dt+2*c(sfy+s1)/du-2*c(sfy+s2)/du-2*c(sfy+s3)/du+2*c(sfy+s4)/du+1*c(sfxy+s1)/(dt*du)+1*c(sfxy+s2)/(dt*du)+1*c(sfxy+s3)/(dt*du)+1*c(sfxy+s4)/(dt*du);
|
700
|
+
}
|
701
|
+
|
702
|
+
//
|
703
|
+
// Rescale Cij
|
704
|
+
//
|
705
|
+
for(ci = 0; ci <= 3; ci++)
|
706
|
+
{
|
707
|
+
for(cj = 0; cj <= 3; cj++)
|
708
|
+
{
|
709
|
+
tbl(p,4+ci*4+cj) = tbl(p,4+ci*4+cj)*pow(dt, double(ci))*pow(du, double(cj));
|
710
|
+
}
|
711
|
+
}
|
712
|
+
}
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
|
717
|
+
/*************************************************************************
|
718
|
+
This subroutine performs linear transformation of the spline argument.
|
719
|
+
|
720
|
+
Input parameters:
|
721
|
+
C - coefficients table.
|
722
|
+
AX, BX - transformation coefficients: x = A*t + B
|
723
|
+
AY, BY - transformation coefficients: y = A*u + B
|
724
|
+
Result:
|
725
|
+
C - transformed spline
|
726
|
+
|
727
|
+
-- ALGLIB PROJECT --
|
728
|
+
Copyright 30.06.2007 by Bochkanov Sergey
|
729
|
+
*************************************************************************/
|
730
|
+
void spline2dlintransxy(ap::real_1d_array& c,
|
731
|
+
double ax,
|
732
|
+
double bx,
|
733
|
+
double ay,
|
734
|
+
double by)
|
735
|
+
{
|
736
|
+
int i;
|
737
|
+
int j;
|
738
|
+
int n;
|
739
|
+
int m;
|
740
|
+
double v;
|
741
|
+
ap::real_1d_array x;
|
742
|
+
ap::real_1d_array y;
|
743
|
+
ap::real_2d_array f;
|
744
|
+
int typec;
|
745
|
+
|
746
|
+
typec = ap::round(c(1));
|
747
|
+
ap::ap_error::make_assertion(typec==-3||typec==-1, "Spline2DLinTransXY: incorrect C!");
|
748
|
+
n = ap::round(c(2));
|
749
|
+
m = ap::round(c(3));
|
750
|
+
x.setbounds(0, n-1);
|
751
|
+
y.setbounds(0, m-1);
|
752
|
+
f.setbounds(0, m-1, 0, n-1);
|
753
|
+
for(j = 0; j <= n-1; j++)
|
754
|
+
{
|
755
|
+
x(j) = c(4+j);
|
756
|
+
}
|
757
|
+
for(i = 0; i <= m-1; i++)
|
758
|
+
{
|
759
|
+
y(i) = c(4+n+i);
|
760
|
+
}
|
761
|
+
for(i = 0; i <= m-1; i++)
|
762
|
+
{
|
763
|
+
for(j = 0; j <= n-1; j++)
|
764
|
+
{
|
765
|
+
f(i,j) = c(4+n+m+i*n+j);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
//
|
770
|
+
// Special case: AX=0 or AY=0
|
771
|
+
//
|
772
|
+
if( ax==0 )
|
773
|
+
{
|
774
|
+
for(i = 0; i <= m-1; i++)
|
775
|
+
{
|
776
|
+
v = splineinterpolation2d(c, bx, y(i));
|
777
|
+
for(j = 0; j <= n-1; j++)
|
778
|
+
{
|
779
|
+
f(i,j) = v;
|
780
|
+
}
|
781
|
+
}
|
782
|
+
if( typec==-3 )
|
783
|
+
{
|
784
|
+
buildbicubicspline(x, y, f, m, n, c);
|
785
|
+
}
|
786
|
+
if( typec==-1 )
|
787
|
+
{
|
788
|
+
buildbilinearspline(x, y, f, m, n, c);
|
789
|
+
}
|
790
|
+
ax = 1;
|
791
|
+
bx = 0;
|
792
|
+
}
|
793
|
+
if( ay==0 )
|
794
|
+
{
|
795
|
+
for(j = 0; j <= n-1; j++)
|
796
|
+
{
|
797
|
+
v = splineinterpolation2d(c, x(j), by);
|
798
|
+
for(i = 0; i <= m-1; i++)
|
799
|
+
{
|
800
|
+
f(i,j) = v;
|
801
|
+
}
|
802
|
+
}
|
803
|
+
if( typec==-3 )
|
804
|
+
{
|
805
|
+
buildbicubicspline(x, y, f, m, n, c);
|
806
|
+
}
|
807
|
+
if( typec==-1 )
|
808
|
+
{
|
809
|
+
buildbilinearspline(x, y, f, m, n, c);
|
810
|
+
}
|
811
|
+
ay = 1;
|
812
|
+
by = 0;
|
813
|
+
}
|
814
|
+
|
815
|
+
//
|
816
|
+
// General case: AX<>0, AY<>0
|
817
|
+
// Unpack, scale and pack again.
|
818
|
+
//
|
819
|
+
for(j = 0; j <= n-1; j++)
|
820
|
+
{
|
821
|
+
x(j) = (x(j)-bx)/ax;
|
822
|
+
}
|
823
|
+
for(i = 0; i <= m-1; i++)
|
824
|
+
{
|
825
|
+
y(i) = (y(i)-by)/ay;
|
826
|
+
}
|
827
|
+
if( typec==-3 )
|
828
|
+
{
|
829
|
+
buildbicubicspline(x, y, f, m, n, c);
|
830
|
+
}
|
831
|
+
if( typec==-1 )
|
832
|
+
{
|
833
|
+
buildbilinearspline(x, y, f, m, n, c);
|
834
|
+
}
|
835
|
+
}
|
836
|
+
|
837
|
+
|
838
|
+
/*************************************************************************
|
839
|
+
This subroutine performs linear transformation of the spline.
|
840
|
+
|
841
|
+
Input parameters:
|
842
|
+
C - coefficients table. Built by BuildLinearSpline,
|
843
|
+
BuildHermiteSpline, BuildCubicSpline, BuildAkimaSpline.
|
844
|
+
A, B- transformation coefficients: S2(x,y) = A*S(x,y) + B
|
845
|
+
|
846
|
+
Output parameters:
|
847
|
+
C - transformed spline
|
848
|
+
|
849
|
+
-- ALGLIB PROJECT --
|
850
|
+
Copyright 30.06.2007 by Bochkanov Sergey
|
851
|
+
*************************************************************************/
|
852
|
+
void spline2dlintransf(ap::real_1d_array& c, double a, double b)
|
853
|
+
{
|
854
|
+
int i;
|
855
|
+
int j;
|
856
|
+
int n;
|
857
|
+
int m;
|
858
|
+
double v;
|
859
|
+
ap::real_1d_array x;
|
860
|
+
ap::real_1d_array y;
|
861
|
+
ap::real_2d_array f;
|
862
|
+
int typec;
|
863
|
+
|
864
|
+
typec = ap::round(c(1));
|
865
|
+
ap::ap_error::make_assertion(typec==-3||typec==-1, "Spline2DLinTransXY: incorrect C!");
|
866
|
+
n = ap::round(c(2));
|
867
|
+
m = ap::round(c(3));
|
868
|
+
x.setbounds(0, n-1);
|
869
|
+
y.setbounds(0, m-1);
|
870
|
+
f.setbounds(0, m-1, 0, n-1);
|
871
|
+
for(j = 0; j <= n-1; j++)
|
872
|
+
{
|
873
|
+
x(j) = c(4+j);
|
874
|
+
}
|
875
|
+
for(i = 0; i <= m-1; i++)
|
876
|
+
{
|
877
|
+
y(i) = c(4+n+i);
|
878
|
+
}
|
879
|
+
for(i = 0; i <= m-1; i++)
|
880
|
+
{
|
881
|
+
for(j = 0; j <= n-1; j++)
|
882
|
+
{
|
883
|
+
f(i,j) = a*c(4+n+m+i*n+j)+b;
|
884
|
+
}
|
885
|
+
}
|
886
|
+
if( typec==-3 )
|
887
|
+
{
|
888
|
+
buildbicubicspline(x, y, f, m, n, c);
|
889
|
+
}
|
890
|
+
if( typec==-1 )
|
891
|
+
{
|
892
|
+
buildbilinearspline(x, y, f, m, n, c);
|
893
|
+
}
|
894
|
+
}
|
895
|
+
|
896
|
+
|
897
|
+
/*************************************************************************
|
898
|
+
This subroutine makes the copy of the spline.
|
899
|
+
|
900
|
+
Input parameters:
|
901
|
+
C - coefficients table.
|
902
|
+
|
903
|
+
Output parameters:
|
904
|
+
CC - spline copy
|
905
|
+
|
906
|
+
-- ALGLIB PROJECT --
|
907
|
+
Copyright 29.06.2007 by Bochkanov Sergey
|
908
|
+
*************************************************************************/
|
909
|
+
void spline2dcopy(const ap::real_1d_array& c, ap::real_1d_array& cc)
|
910
|
+
{
|
911
|
+
|
912
|
+
splinecopy(c, cc);
|
913
|
+
}
|
914
|
+
|
915
|
+
|
916
|
+
/*************************************************************************
|
917
|
+
Bicubic spline resampling
|
918
|
+
|
919
|
+
Input parameters:
|
920
|
+
A - function values at the old grid,
|
921
|
+
array[0..OldHeight-1, 0..OldWidth-1]
|
922
|
+
OldHeight - old grid height, OldHeight>1
|
923
|
+
OldWidth - old grid width, OldWidth>1
|
924
|
+
NewHeight - new grid height, NewHeight>1
|
925
|
+
NewWidth - new grid width, NewWidth>1
|
926
|
+
|
927
|
+
Output parameters:
|
928
|
+
B - function values at the new grid,
|
929
|
+
array[0..NewHeight-1, 0..NewWidth-1]
|
930
|
+
|
931
|
+
-- ALGLIB routine --
|
932
|
+
15 May, 2007
|
933
|
+
Copyright by Bochkanov Sergey
|
934
|
+
*************************************************************************/
|
935
|
+
void bicubicresamplecartesian(const ap::real_2d_array& a,
|
936
|
+
int oldheight,
|
937
|
+
int oldwidth,
|
938
|
+
ap::real_2d_array& b,
|
939
|
+
int newheight,
|
940
|
+
int newwidth)
|
941
|
+
{
|
942
|
+
ap::real_2d_array buf;
|
943
|
+
ap::real_1d_array x;
|
944
|
+
ap::real_1d_array y;
|
945
|
+
ap::real_1d_array c;
|
946
|
+
int i;
|
947
|
+
int j;
|
948
|
+
int mw;
|
949
|
+
int mh;
|
950
|
+
|
951
|
+
ap::ap_error::make_assertion(oldwidth>1&&oldheight>1, "BicubicResampleCartesian: width/height less than 1");
|
952
|
+
ap::ap_error::make_assertion(newwidth>1&&newheight>1, "BicubicResampleCartesian: width/height less than 1");
|
953
|
+
|
954
|
+
//
|
955
|
+
// Prepare
|
956
|
+
//
|
957
|
+
mw = ap::maxint(oldwidth, newwidth);
|
958
|
+
mh = ap::maxint(oldheight, newheight);
|
959
|
+
b.setbounds(0, newheight-1, 0, newwidth-1);
|
960
|
+
buf.setbounds(0, oldheight-1, 0, newwidth-1);
|
961
|
+
x.setbounds(0, ap::maxint(mw, mh)-1);
|
962
|
+
y.setbounds(0, ap::maxint(mw, mh)-1);
|
963
|
+
|
964
|
+
//
|
965
|
+
// Horizontal interpolation
|
966
|
+
//
|
967
|
+
for(i = 0; i <= oldheight-1; i++)
|
968
|
+
{
|
969
|
+
|
970
|
+
//
|
971
|
+
// Fill X, Y
|
972
|
+
//
|
973
|
+
for(j = 0; j <= oldwidth-1; j++)
|
974
|
+
{
|
975
|
+
x(j) = double(j)/double(oldwidth-1);
|
976
|
+
y(j) = a(i,j);
|
977
|
+
}
|
978
|
+
|
979
|
+
//
|
980
|
+
// Interpolate and place result into temporary matrix
|
981
|
+
//
|
982
|
+
buildcubicspline(x, y, oldwidth, 0, 0.0, 0, 0.0, c);
|
983
|
+
for(j = 0; j <= newwidth-1; j++)
|
984
|
+
{
|
985
|
+
buf(i,j) = splineinterpolation(c, double(j)/double(newwidth-1));
|
986
|
+
}
|
987
|
+
}
|
988
|
+
|
989
|
+
//
|
990
|
+
// Vertical interpolation
|
991
|
+
//
|
992
|
+
for(j = 0; j <= newwidth-1; j++)
|
993
|
+
{
|
994
|
+
|
995
|
+
//
|
996
|
+
// Fill X, Y
|
997
|
+
//
|
998
|
+
for(i = 0; i <= oldheight-1; i++)
|
999
|
+
{
|
1000
|
+
x(i) = double(i)/double(oldheight-1);
|
1001
|
+
y(i) = buf(i,j);
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
//
|
1005
|
+
// Interpolate and place result into B
|
1006
|
+
//
|
1007
|
+
buildcubicspline(x, y, oldheight, 0, 0.0, 0, 0.0, c);
|
1008
|
+
for(i = 0; i <= newheight-1; i++)
|
1009
|
+
{
|
1010
|
+
b(i,j) = splineinterpolation(c, double(i)/double(newheight-1));
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
|
1016
|
+
/*************************************************************************
|
1017
|
+
Bilinear spline resampling
|
1018
|
+
|
1019
|
+
Input parameters:
|
1020
|
+
A - function values at the old grid,
|
1021
|
+
array[0..OldHeight-1, 0..OldWidth-1]
|
1022
|
+
OldHeight - old grid height, OldHeight>1
|
1023
|
+
OldWidth - old grid width, OldWidth>1
|
1024
|
+
NewHeight - new grid height, NewHeight>1
|
1025
|
+
NewWidth - new grid width, NewWidth>1
|
1026
|
+
|
1027
|
+
Output parameters:
|
1028
|
+
B - function values at the new grid,
|
1029
|
+
array[0..NewHeight-1, 0..NewWidth-1]
|
1030
|
+
|
1031
|
+
-- ALGLIB routine --
|
1032
|
+
09.07.2007
|
1033
|
+
Copyright by Bochkanov Sergey
|
1034
|
+
*************************************************************************/
|
1035
|
+
void bilinearresamplecartesian(const ap::real_2d_array& a,
|
1036
|
+
int oldheight,
|
1037
|
+
int oldwidth,
|
1038
|
+
ap::real_2d_array& b,
|
1039
|
+
int newheight,
|
1040
|
+
int newwidth)
|
1041
|
+
{
|
1042
|
+
int i;
|
1043
|
+
int j;
|
1044
|
+
int l;
|
1045
|
+
int c;
|
1046
|
+
double t;
|
1047
|
+
double u;
|
1048
|
+
|
1049
|
+
b.setbounds(0, newheight-1, 0, newwidth-1);
|
1050
|
+
for(i = 0; i <= newheight-1; i++)
|
1051
|
+
{
|
1052
|
+
for(j = 0; j <= newwidth-1; j++)
|
1053
|
+
{
|
1054
|
+
l = i*(oldheight-1)/(newheight-1);
|
1055
|
+
if( l==oldheight-1 )
|
1056
|
+
{
|
1057
|
+
l = oldheight-2;
|
1058
|
+
}
|
1059
|
+
u = double(i)/double(newheight-1)*(oldheight-1)-l;
|
1060
|
+
c = j*(oldwidth-1)/(newwidth-1);
|
1061
|
+
if( c==oldwidth-1 )
|
1062
|
+
{
|
1063
|
+
c = oldwidth-2;
|
1064
|
+
}
|
1065
|
+
t = double(j*(oldwidth-1))/double(newwidth-1)-c;
|
1066
|
+
b(i,j) = (1-t)*(1-u)*a(l,c)+t*(1-u)*a(l,c+1)+t*u*a(l+1,c+1)+(1-t)*u*a(l+1,c);
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
|
1072
|
+
/*************************************************************************
|
1073
|
+
Obsolete subroutine for backwards compatibility
|
1074
|
+
*************************************************************************/
|
1075
|
+
void bicubicresample(int oldwidth,
|
1076
|
+
int oldheight,
|
1077
|
+
int newwidth,
|
1078
|
+
int newheight,
|
1079
|
+
const ap::real_2d_array& a,
|
1080
|
+
ap::real_2d_array& b)
|
1081
|
+
{
|
1082
|
+
|
1083
|
+
bicubicresamplecartesian(a, oldheight, oldwidth, b, newheight, newwidth);
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
|
1087
|
+
/*************************************************************************
|
1088
|
+
Obsolete subroutine for backwards compatibility
|
1089
|
+
*************************************************************************/
|
1090
|
+
void bilinearresample(int oldwidth,
|
1091
|
+
int oldheight,
|
1092
|
+
int newwidth,
|
1093
|
+
int newheight,
|
1094
|
+
const ap::real_2d_array& a,
|
1095
|
+
ap::real_2d_array& b)
|
1096
|
+
{
|
1097
|
+
|
1098
|
+
bilinearresamplecartesian(a, oldheight, oldwidth, b, newheight, newwidth);
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
|
1102
|
+
/*************************************************************************
|
1103
|
+
Internal subroutine.
|
1104
|
+
Calculation of the first derivatives and the cross-derivative.
|
1105
|
+
*************************************************************************/
|
1106
|
+
static void bicubiccalcderivatives(const ap::real_2d_array& a,
|
1107
|
+
const ap::real_1d_array& x,
|
1108
|
+
const ap::real_1d_array& y,
|
1109
|
+
int m,
|
1110
|
+
int n,
|
1111
|
+
ap::real_2d_array& dx,
|
1112
|
+
ap::real_2d_array& dy,
|
1113
|
+
ap::real_2d_array& dxy)
|
1114
|
+
{
|
1115
|
+
int i;
|
1116
|
+
int j;
|
1117
|
+
int k;
|
1118
|
+
ap::real_1d_array xt;
|
1119
|
+
ap::real_1d_array ft;
|
1120
|
+
ap::real_1d_array c;
|
1121
|
+
double s;
|
1122
|
+
double ds;
|
1123
|
+
double d2s;
|
1124
|
+
double v;
|
1125
|
+
|
1126
|
+
dx.setbounds(0, m-1, 0, n-1);
|
1127
|
+
dy.setbounds(0, m-1, 0, n-1);
|
1128
|
+
dxy.setbounds(0, m-1, 0, n-1);
|
1129
|
+
|
1130
|
+
//
|
1131
|
+
// dF/dX
|
1132
|
+
//
|
1133
|
+
xt.setbounds(0, n-1);
|
1134
|
+
ft.setbounds(0, n-1);
|
1135
|
+
for(i = 0; i <= m-1; i++)
|
1136
|
+
{
|
1137
|
+
for(j = 0; j <= n-1; j++)
|
1138
|
+
{
|
1139
|
+
xt(j) = x(j);
|
1140
|
+
ft(j) = a(i,j);
|
1141
|
+
}
|
1142
|
+
buildcubicspline(xt, ft, n, 0, 0.0, 0, 0.0, c);
|
1143
|
+
for(j = 0; j <= n-1; j++)
|
1144
|
+
{
|
1145
|
+
splinedifferentiation(c, x(j), s, ds, d2s);
|
1146
|
+
dx(i,j) = ds;
|
1147
|
+
}
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
//
|
1151
|
+
// dF/dY
|
1152
|
+
//
|
1153
|
+
xt.setbounds(0, m-1);
|
1154
|
+
ft.setbounds(0, m-1);
|
1155
|
+
for(j = 0; j <= n-1; j++)
|
1156
|
+
{
|
1157
|
+
for(i = 0; i <= m-1; i++)
|
1158
|
+
{
|
1159
|
+
xt(i) = y(i);
|
1160
|
+
ft(i) = a(i,j);
|
1161
|
+
}
|
1162
|
+
buildcubicspline(xt, ft, m, 0, 0.0, 0, 0.0, c);
|
1163
|
+
for(i = 0; i <= m-1; i++)
|
1164
|
+
{
|
1165
|
+
splinedifferentiation(c, y(i), s, ds, d2s);
|
1166
|
+
dy(i,j) = ds;
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
//
|
1171
|
+
// d2F/dXdY
|
1172
|
+
//
|
1173
|
+
xt.setbounds(0, n-1);
|
1174
|
+
ft.setbounds(0, n-1);
|
1175
|
+
for(i = 0; i <= m-1; i++)
|
1176
|
+
{
|
1177
|
+
for(j = 0; j <= n-1; j++)
|
1178
|
+
{
|
1179
|
+
xt(j) = x(j);
|
1180
|
+
ft(j) = dy(i,j);
|
1181
|
+
}
|
1182
|
+
buildcubicspline(xt, ft, n, 0, 0.0, 0, 0.0, c);
|
1183
|
+
for(j = 0; j <= n-1; j++)
|
1184
|
+
{
|
1185
|
+
splinedifferentiation(c, x(j), s, ds, d2s);
|
1186
|
+
dxy(i,j) = ds;
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
|
1192
|
+
|