1
subroutine fpgrpa(ifsu,ifsv,ifbu,ifbv,idim,ipar,u,mu,v,mv,z,mz,
2
* tu,nu,tv,nv,p,c,nc,fp,fpu,fpv,mm,mvnu,spu,spv,right,q,au,au1,
3
* av,av1,bu,bv,nru,nrv)
7
integer ifsu,ifsv,ifbu,ifbv,idim,mu,mv,mz,nu,nv,nc,mm,mvnu
9
real*8 u(mu),v(mv),z(mz*idim),tu(nu),tv(nv),c(nc*idim),fpu(nu),
10
* fpv(nv),spu(mu,4),spv(mv,4),right(mm*idim),q(mvnu),au(nu,5),
11
* au1(nu,4),av(nv,5),av1(nv,4),bu(nu,5),bv(nv,5)
12
integer ipar(2),nru(mu),nrv(mv)
14
real*8 arg,fac,term,one,half,value
15
integer i,id,ii,it,iz,i1,i2,j,jz,k,k1,k2,l,l1,l2,mvv,k0,muu,
16
* ncof,nroldu,nroldv,number,nmd,numu,numu1,numv,numv1,nuu,nvv,
17
* nu4,nu7,nu8,nv4,nv7,nv8
20
c ..subroutine references..
21
c fpback,fpbspl,fpdisc,fpbacp,fptrnp,fptrpe
25
c (au) = | ---------- | (av) = | ---------- |
26
c | (1/p) (bu) | | (1/p) (bv) |
32
c with c : the (nu-4) x (nv-4) matrix which contains the b-spline
34
c z : the mu x mv matrix which contains the function values.
35
c spu,spv: the mu x (nu-4), resp. mv x (nv-4) observation matrices
36
c according to the least-squares problems in the u-,resp.
38
c bu,bv : the (nu-7) x (nu-4),resp. (nv-7) x (nv-4) matrices
39
c containing the discontinuity jumps of the derivatives
40
c of the b-splines in the u-,resp.v-variable at the knots
41
c the b-spline coefficients of the smoothing spline are then calculated
42
c as the least-squares solution of the following over-determined linear
45
c (1) (av) c (au)' = q
47
c subject to the constraints
49
c (2) c(nu-3+i,j) = c(i,j), i=1,2,3 ; j=1,2,...,nv-4
52
c (3) c(i,nv-3+j) = c(i,j), j=1,2,3 ; i=1,2,...,nu-4
66
if(ipar(1).ne.0) muu = mu-1
68
if(ipar(2).ne.0) mvv = mv-1
69
c it depends on the value of the flags ifsu,ifsv,ifbu and ibvand
70
c on the value of p whether the matrices (spu), (spv), (bu) and (bv)
71
c still must be determined.
72
if(ifsu.ne.0) go to 50
73
c calculate the non-zero elements of the matrix (spu) which is the ob-
74
c servation matrix according to the least-squares spline approximation
75
c problem in the u-direction.
81
10 if(arg.lt.tu(l1) .or. l.eq.nu4) go to 20
86
20 call fpbspl(tu,nu,3,arg,l,h)
93
c calculate the non-zero elements of the matrix (spv) which is the ob-
94
c servation matrix according to the least-squares spline approximation
95
c problem in the v-direction.
96
50 if(ifsv.ne.0) go to 100
102
60 if(arg.lt.tv(l1) .or. l.eq.nv4) go to 70
107
70 call fpbspl(tv,nv,3,arg,l,h)
114
100 if(p.le.0.) go to 150
115
c calculate the non-zero elements of the matrix (bu).
116
if(ifbu.ne.0 .or. nu8.eq.0) go to 110
117
call fpdisc(tu,nu,5,bu,nu)
119
c calculate the non-zero elements of the matrix (bv).
120
110 if(ifbv.ne.0 .or. nv8.eq.0) go to 150
121
call fpdisc(tv,nv,5,bv,nv)
123
c substituting (2) and (3) into (1), we obtain the overdetermined
125
c (4) (avv) (cr) (auu)' = (qq)
126
c from which the nuu*nvv remaining coefficients
127
c c(i,j) , i=1,...,nu-4-3*ipar(1) ; j=1,...,nv-4-3*ipar(2) ,
128
c the elements of (cr), are then determined in the least-squares sense.
129
c we first determine the matrices (auu) and (qq). then we reduce the
130
c matrix (auu) to upper triangular form (ru) using givens rotations.
131
c we apply the same transformations to the rows of matrix qq to obtain
132
c the (mv) x nuu matrix g.
133
c we store matrix (ru) into au (and au1 if ipar(1)=1) and g into q.
134
150 if(ipar(1).ne.0) go to 160
136
call fptrnp(mu,mv,idim,nu,nru,spu,p,bu,z,au,q,right)
139
call fptrpe(mu,mv,idim,nu,nru,spu,p,bu,z,au,au1,q,right)
140
c we determine the matrix (avv) and then we reduce this matrix to
141
c upper triangular form (rv) using givens rotations.
142
c we apply the same transformations to the columns of matrix
143
c g to obtain the (nvv) x (nuu) matrix h.
144
c we store matrix (rv) into av (and av1 if ipar(2)=1) and h into c.
145
180 if(ipar(2).ne.0) go to 190
147
call fptrnp(mv,nuu,idim,nv,nrv,spv,p,bv,q,av,c,right)
150
call fptrpe(mv,nuu,idim,nv,nrv,spv,p,bv,q,av,av1,c,right)
151
c backward substitution to obtain the b-spline coefficients as the
152
c solution of the linear system (rv) (cr) (ru)' = h.
153
c first step: solve the system (rv) (c1) = h.
156
if(ipar(2).ne.0) go to 240
159
call fpback(av,c(k),nvv,5,c(k),nv)
165
call fpbacp(av,av1,c(k),nvv,4,c(k),5,nv)
168
c second step: solve the system (cr) (ru)' = (c1).
169
300 if(ipar(1).ne.0) go to 400
179
call fpback(au,right,nuu,5,right,nu)
196
call fpbacp(au,au1,right,nuu,4,right,5,nu)
203
c calculate from the conditions (2)-(3), the remaining b-spline
205
500 if(ipar(2).eq.0) go to 600
227
600 if(ipar(1).eq.0) go to 700
249
c calculate the quantities
250
c res(i,j) = (z(i,j) - s(u(i),v(j)))**2 , i=1,2,..,mu;j=1,2,..,mv
251
c fp = sumi=1,mu(sumj=1,mv(res(i,j)))
252
c fpu(r) = sum''i(sumj=1,mv(res(i,j))) , r=1,2,...,nu-7
253
c tu(r+3) <= u(i) <= tu(r+4)
254
c fpv(r) = sumi=1,mu(sum''j(res(i,j))) , r=1,2,...,nv-7
255
c tv(r+3) <= v(j) <= tv(r+4)
264
c main loop for the different grid points.
274
c evaluate s(u,v) at the current grid point by making the sum of the
275
c cross products of the non-zero b-splines at (u,v), multiplied with
276
c the appropiate b-spline coefficients.
288
value = value+fac*spv(i2,l2)*c(k2)
292
c calculate the squared residual at the current grid point.
293
term = term+(z(jz)-value)**2
297
c adjust the different parameters.
299
fpu(numu1) = fpu(numu1)+term
300
fpv(numv1) = fpv(numv1)+term
302
if(numv.eq.nroldv) go to 820
303
fpv(numv1) = fpv(numv1)-fac
304
fpv(numv) = fpv(numv)+fac
306
if(numu.eq.nroldu) go to 840
307
fpu(numu1) = fpu(numu1)-fac
308
fpu(numu) = fpu(numu)+fac