Debian Codegraph @

skmisc/loess/src/loessf.f

raw symbols SCIP
1 C
2 C The authors of this software are Cleveland, Grosse, and Shyu.
3 C Copyright (c) 1989, 1992 by AT&T.
4 C Permission to use, copy, modify, and distribute this software for any
5 C purpose without fee is hereby granted, provided that this entire notice
6 C is included in all copies of any software which is or includes a copy
7 C or modification of this software and in all copies of the supporting
8 C documentation for such software.
9 C THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
10 C WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR AT&T MAKE ANY
11 C REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
12 C OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
13
14 C altered by B.D. Ripley to
15 C
16 C remove unused variables
17 C make phi in ehg139 double precision to match calling sequence
18 C pass integer not logical from C
19 C
20 C Note that ehg182(errormsg_code) is in ./loessc.c
21
22 subroutine ehg126(d,n,vc,x,v,nvmax)
23 integer d,execnt,i,j,k,n,nvmax,vc
24 DOUBLE PRECISION machin,alpha,beta,mu,t
25 DOUBLE PRECISION v(nvmax,d), x(n,d)
26
27 DOUBLE PRECISION D1MACH
28 external D1MACH
29 save machin,execnt
30 data execnt /0/
31 c MachInf -> machin
32 execnt=execnt+1
33 if(execnt.eq.1)then
34 c initialize d1mach(2) === DBL_MAX:
35 machin=D1MACH(2)
36 end if
37 c fill in vertices for bounding box of $x$
38 c lower left, upper right
39 do 3 k=1,d
40 alpha=machin
41 beta=-machin
42 do 4 i=1,n
43 t=x(i,k)
44 alpha=min(alpha,t)
45 beta=max(beta,t)
46 4 continue
47 c expand the box a little
48 mu=0.005D0*max(beta-alpha,1.d-10*max(DABS(alpha),DABS(beta))+
49 + 1.d-30)
50 alpha=alpha-mu
51 beta=beta+mu
52 v(1,k)=alpha
53 v(vc,k)=beta
54 3 continue
55 c remaining vertices
56 do 5 i=2,vc-1
57 j=i-1
58 do 6 k=1,d
59 v(i,k)=v(1+mod(j,2)*(vc-1),k)
60 c Integer division would do here
61 j=INT(DBLE(j)/2.D0)
62 6 continue
63 5 continue
64 return
65 end
66
67 subroutine ehg125(p,nv,v,vhit,nvmax,d,k,t,r,s,f,l,u)
68 logical i1,i2,match
69 integer d,h,i,i3,j,k,m,mm,nv,nvmax,p,r,s
70 integer f(r,0:1,s),l(r,0:1,s),u(r,0:1,s),vhit(nvmax)
71 DOUBLE PRECISION t
72 DOUBLE PRECISION v(nvmax,d)
73 external ehg182
74 h=nv
75 do 3 i=1,r
76 do 4 j=1,s
77 h=h+1
78 do 5 i3=1,d
79 v(h,i3)=v(f(i,0,j),i3)
80 5 continue
81 v(h,k)=t
82 c check for redundant vertex
83 match=.false.
84 m=1
85 c top of while loop
86 6 if(.not.match)then
87 i1=(m.le.nv)
88 else
89 i1=.false.
90 end if
91 if(.not.(i1))goto 7
92 match=(v(m,1).eq.v(h,1))
93 mm=2
94 c top of while loop
95 8 if(match)then
96 i2=(mm.le.d)
97 else
98 i2=.false.
99 end if
100 if(.not.(i2))goto 9
101 match=(v(m,mm).eq.v(h,mm))
102 mm=mm+1
103 goto 8
104 c bottom of while loop
105 9 m=m+1
106 goto 6
107 c bottom of while loop
108 7 m=m-1
109 if(match)then
110 h=h-1
111 else
112 m=h
113 if(vhit(1).ge.0)then
114 vhit(m)=p
115 end if
116 end if
117 l(i,0,j)=f(i,0,j)
118 l(i,1,j)=m
119 u(i,0,j)=m
120 u(i,1,j)=f(i,1,j)
121 4 continue
122 3 continue
123 nv=h
124 if(.not.(nv.le.nvmax))then
125 call ehg182(180)
126 end if
127 return
128 end
129
130 integer function ehg138(i,z,a,xi,lo,hi,ncmax)
131 logical i1
132 integer i,j,ncmax
133 integer a(ncmax),hi(ncmax),lo(ncmax)
134 DOUBLE PRECISION xi(ncmax),z(8)
135 c descend tree until leaf or ambiguous
136 j=i
137 c top of while loop
138 3 if(a(j).ne.0)then
139 i1=(z(a(j)).ne.xi(j))
140 else
141 i1=.false.
142 end if
143 if(.not.(i1))goto 4
144 if(z(a(j)).le.xi(j))then
145 j=lo(j)
146 else
147 j=hi(j)
148 end if
149 goto 3
150 c bottom of while loop
151 4 ehg138=j
152 return
153 end
154
155 subroutine ehg106(il,ir,k,nk,p,pi,n)
156
157 c Partial sorting of p(1, il:ir) returning the sort indices pi() only
158 c such that p(1, pi(k)) is correct
159
160 c implicit none
161 c Arguments
162 c Input:
163 integer il,ir,k,nk,n
164 DOUBLE PRECISION p(nk,n)
165 c using only p(1, pi(*))
166 c Output:
167 integer pi(n)
168
169 c Variables
170 DOUBLE PRECISION t
171 integer i,ii,j,l,r
172
173 c find the $k$-th smallest of $n$ elements
174 c Floyd+Rivest, CACM Mar '75, Algorithm 489
175 l=il
176 r=ir
177 c while (l < r )
178 3 if(.not.(l.lt.r))goto 4
179 c to avoid recursion, sophisticated partition deleted
180 c partition $x sub {l..r}$ about $t$
181 t=p(1,pi(k))
182 i=l
183 j=r
184 ii=pi(l)
185 pi(l)=pi(k)
186 pi(k)=ii
187 if(t.lt.p(1,pi(r)))then
188 ii=pi(l)
189 pi(l)=pi(r)
190 pi(r)=ii
191 end if
192 c top of while loop
193 5 if(.not.(i.lt.j))goto 6
194 ii=pi(i)
195 pi(i)=pi(j)
196 pi(j)=ii
197 i=i+1
198 j=j-1
199 c top of while loop
200 7 if(.not.(p(1,pi(i)).lt.t))goto 8
201 i=i+1
202 goto 7
203 c bottom of while loop
204 8 continue
205 c top of while loop
206 9 if(.not.(t.lt.p(1,pi(j))))goto 10
207 j=j-1
208 goto 9
209 c bottom of while loop
210 10 goto 5
211 c bottom of while loop
212 6 if(p(1,pi(l)).eq.t)then
213 ii=pi(l)
214 pi(l)=pi(j)
215 pi(j)=ii
216 else
217 j=j+1
218 ii=pi(r)
219 pi(r)=pi(j)
220 pi(j)=ii
221 end if
222 if(j.le.k)then
223 l=j+1
224 end if
225 if(k.le.j)then
226 r=j-1
227 end if
228 goto 3
229 c bottom of while loop
230 4 return
231 end
232
233
234 subroutine ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,
235 + rcond,sing,sigma,u,e,dgamma,qraux,work,tol,dd,tdeg,cdeg,s)
236 integer column,d,dd,execnt,i,i3,i9,info,inorm2,j,jj,jpvt,k,kernel,
237 + n,nf,od,sing,tdeg
238 integer cdeg(8),psi(n)
239 double precision machep,f,i1,i10,i2,i4,i5,i6,i7,i8,rcond,rho,scal,
240 + tol
241 double precision g(15),sigma(15),u(15,15),e(15,15),b(nf,k),
242 + colnor(15),dist(n),eta(nf),dgamma(15),q(d),qraux(15),rw(n),
243 + s(0:od),w(nf),work(15),x(n,d),y(n)
244
245 integer idamax
246 double precision d1mach, ddot
247
248 external ehg106,ehg182,ehg184,dqrdc,dqrsl,dsvdc
249 external idamax, d1mach, ddot
250
251 save machep,execnt
252 data execnt /0/
253 c colnorm -> colnor
254 c E -> g
255 c MachEps -> machep
256 c V -> e
257 c X -> b
258 execnt=execnt+1
259 if(execnt.eq.1)then
260 c initialize d1mach(4) === 1 / DBL_EPSILON === 2^52 :
261 machep=d1mach(4)
262 end if
263 c sort by distance
264 do 3 i3=1,n
265 dist(i3)=0
266 3 continue
267 do 4 j=1,dd
268 i4=q(j)
269 do 5 i3=1,n
270 dist(i3)=dist(i3)+(x(i3,j)-i4)**2
271 5 continue
272 4 continue
273 call ehg106(1,n,nf,1,dist,psi,n)
274 rho=dist(psi(nf))*max(1.d0,f)
275 if(rho .le. 0)then
276 call ehg182(120)
277 end if
278 c compute neighborhood weights
279 if(kernel.eq.2)then
280 do 6 i=1,nf
281 if(dist(psi(i)).lt.rho)then
282 i1=dsqrt(rw(psi(i)))
283 else
284 i1=0
285 end if
286 w(i)=i1
287 6 continue
288 else
289 do 7 i3=1,nf
290 w(i3)=dsqrt(dist(psi(i3))/rho)
291 7 continue
292 do 8 i3=1,nf
293 w(i3)=dsqrt(rw(psi(i3))*(1-w(i3)**3)**3)
294 8 continue
295 end if
296 if(dabs(w(idamax(nf,w,1))).eq.0)then
297 call ehg184('at ',q(1),dd,1)
298 call ehg184('radius ',rho,1,1)
299 if(.not..false.)then
300 call ehg182(121)
301 end if
302 end if
303 c fill design matrix
304 column=1
305 do 9 i3=1,nf
306 b(i3,column)=w(i3)
307 9 continue
308 if(tdeg.ge.1)then
309 do 10 j=1,d
310 if(cdeg(j).ge.1)then
311 column=column+1
312 i5=q(j)
313 do 11 i3=1,nf
314 b(i3,column)=w(i3)*(x(psi(i3),j)-i5)
315 11 continue
316 end if
317 10 continue
318 end if
319 if(tdeg.ge.2)then
320 do 12 j=1,d
321 if(cdeg(j).ge.1)then
322 if(cdeg(j).ge.2)then
323 column=column+1
324 i6=q(j)
325 do 13 i3=1,nf
326 b(i3,column)=w(i3)*(x(psi(i3),j)-i6)**2
327 13 continue
328 end if
329 do 14 jj=j+1,d
330 if(cdeg(jj).ge.1)then
331 column=column+1
332 i7=q(j)
333 i8=q(jj)
334 do 15 i3=1,nf
335 b(i3,column)=w(i3)*(x(psi(i3),j)-i7)*(x(psi(i3),
336 +jj)-i8)
337 15 continue
338 end if
339 14 continue
340 end if
341 12 continue
342 k=column
343 end if
344 do 16 i3=1,nf
345 eta(i3)=w(i3)*y(psi(i3))
346 16 continue
347 c equilibrate columns
348 do 17 j=1,k
349 scal=0
350 do 18 inorm2=1,nf
351 scal=scal+b(inorm2,j)**2
352 18 continue
353 scal=dsqrt(scal)
354 if(0.lt.scal)then
355 do 19 i3=1,nf
356 b(i3,j)=b(i3,j)/scal
357 19 continue
358 colnor(j)=scal
359 else
360 colnor(j)=1
361 end if
362 17 continue
363 c singular value decomposition
364 call dqrdc(b,nf,nf,k,qraux,jpvt,work,0)
365 call dqrsl(b,nf,nf,k,qraux,eta,work,eta,eta,work,work,1000,info)
366 do 20 i9=1,k
367 do 21 i3=1,k
368 u(i3,i9)=0
369 21 continue
370 20 continue
371 do 22 i=1,k
372 do 23 j=i,k
373 c FIXME: this has i = 3 vs bound 2 in a ggplot2 test
374 u(i,j)=b(i,j)
375 23 continue
376 22 continue
377 call dsvdc(u,15,k,k,sigma,g,u,15,e,15,work,21,info)
378 if(.not.(info.eq.0))then
379 call ehg182(182)
380 end if
381 tol=sigma(1)*(100*machep)
382 rcond=min(rcond,sigma(k)/sigma(1))
383 if(sigma(k).le.tol)then
384 sing=sing+1
385 if(sing.eq.1)then
386 call ehg184('pseudoinverse used at',q(1),d,1)
387 call ehg184('neighborhood radius',dsqrt(rho),1,1)
388 call ehg184('reciprocal condition number ',rcond,1,1)
389 else
390 if(sing.eq.2)then
391 call ehg184('There are other near singularities as well.'
392 +,rho,1,1)
393 end if
394 end if
395 end if
396 c compensate for equilibration
397 do 24 j=1,k
398 i10=colnor(j)
399 do 25 i3=1,k
400 e(j,i3)=e(j,i3)/i10
401 25 continue
402 24 continue
403 c solve least squares problem
404 do 26 j=1,k
405 if(tol.lt.sigma(j))then
406 i2=ddot(k,u(1,j),1,eta,1)/sigma(j)
407 else
408 i2=0.d0
409 end if
410 dgamma(j)=i2
411 26 continue
412 do 27 j=0,od
413 c bug fix 2006-07-04 for k=1, od>1. (thanks [email protected])
414 if(j.lt.k)then
415 s(j)=ddot(k,e(j+1,1),15,dgamma,1)
416 else
417 s(j)=0.d0
418 end if
419 27 continue
420 return
421 end
422
423 subroutine ehg131(x,y,rw,trl,diagl,kernel,k,n,d,nc,ncmax,vc,nv,
424 + nvmax,nf,f,a,c,hi,lo,pi,psi,v,vhit,vval,xi,dist,eta,b,ntol,
425 + fd,w,vval2,rcond,sing,dd,tdeg,cdeg,lq,lf,setlf)
426 logical setlf
427 integer identi,d,dd,i1,i2,j,k,kernel,n,nc,ncmax,nf,ntol,nv,
428 + nvmax,sing,tdeg,vc
429 integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),
430 + lo(ncmax),pi(n),psi(n),vhit(nvmax)
431 double precision f,fd,rcond,trl
432 double precision lf(0:d,nvmax,nf),b(*),delta(8),diagl(n),dist(n),
433 + eta(nf),rw(n),v(nvmax,d),vval(0:d,nvmax),vval2(0:d,nvmax),
434 + w(nf),x(n,d),xi(ncmax),y(n)
435 external ehg126,ehg182,ehg139,ehg124
436 double precision dnrm2
437 external dnrm2
438 c Identity -> identi
439 c X -> b
440 if(.not.(d.le.8))then
441 call ehg182(101)
442 end if
443 c build $k$-d tree
444 call ehg126(d,n,vc,x,v,nvmax)
445 nv=vc
446 nc=1
447 do 3 j=1,vc
448 c(j,nc)=j
449 vhit(j)=0
450 3 continue
451 do 4 i1=1,d
452 delta(i1)=v(vc,i1)-v(1,i1)
453 4 continue
454 fd=fd*dnrm2(d,delta,1)
455 do 5 identi=1,n
456 pi(identi)=identi
457 5 continue
458 call ehg124(1,n,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,vhit,nvmax,
459 +ntol,fd,dd)
460 c smooth
461 if(trl.ne.0)then
462 do 6 i2=1,nv
463 do 7 i1=0,d
464 vval2(i1,i2)=0
465 7 continue
466 6 continue
467 end if
468 call ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,dist,
469 + dist,eta,b,d,w,diagl,vval2,nc,vc,a,xi,lo,hi,c,rcond,
470 + sing,dd,tdeg,cdeg,lq,lf,setlf,vval)
471 return
472 end
473
474 c called from lowese() only :
475 subroutine ehg133(d,vc,nvmax,ncmax, a,c,hi,lo, v,vval,xi,m,z,s)
476 integer d,vc,nvmax,ncmax, m
477 integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax)
478 double precision v(nvmax,d),vval(0:d,nvmax),xi(ncmax),z(m,d),s(m)
479 c Var
480 double precision delta(8)
481 integer i,i1
482
483 double precision ehg128
484 external ehg128
485
486 do 3 i=1,m
487 do 4 i1=1,d
488 delta(i1)=z(i,i1)
489 4 continue
490 s(i)=ehg128(delta,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval)
491 3 continue
492 return
493 end
494
495 subroutine ehg140(iw,i,j)
496 integer i,j
497 integer iw(i)
498 iw(i)=j
499 return
500 end
501
502 subroutine ehg141(trl,n,deg,k,d,nsing,dk,delta1,delta2)
503 double precision trl,delta1,delta2
504 integer n,deg,k,d,nsing,dk
505
506 double precision c(48), c1, c2, c3, c4, corx,z,zz(1)
507 integer i
508
509 external ehg176
510 double precision ehg176
511
512 c coef, d, deg, del
513 data c / .2971620d0,.3802660d0,.5886043d0,.4263766d0,.3346498d0,
514 +.6271053d0,.5241198d0,.3484836d0,.6687687d0,.6338795d0,.4076457d0,
515 +.7207693d0,.1611761d0,.3091323d0,.4401023d0,.2939609d0,.3580278d0,
516 +.5555741d0,.3972390d0,.4171278d0,.6293196d0,.4675173d0,.4699070d0,
517 +.6674802d0,.2848308d0,.2254512d0,.2914126d0,.5393624d0,.2517230d0,
518 +.3898970d0,.7603231d0,.2969113d0,.4740130d0,.9664956d0,.3629838d0,
519 +.5348889d0,.2075670d0,.2822574d0,.2369957d0,.3911566d0,.2981154d0,
520 +.3623232d0,.5508869d0,.3501989d0,.4371032d0,.7002667d0,.4291632d0,
521 +.4930370d0 /
522
523 if(deg.eq.0) dk=1
524 if(deg.eq.1) dk=d+1
525 if(deg.eq.2) dk=int(dble((d+2)*(d+1))/2.d0)
526 corx=dsqrt(k/dble(n))
527 z=(dsqrt(k/trl)-corx)/(1-corx)
528 if(nsing .eq. 0 .and. 1 .lt. z) then
529 call ehg184('Chernobyl! trL<k',trl,1,1)
530 else if(z .lt. 0) then
531 call ehg184('Chernobyl! trL>n',trl,1,1)
532 endif
533 z=min(1.0d0,max(0.0d0,z))
534 c R fix
535 zz(1)=z
536 c4=dexp(ehg176(zz))
537 i=1+3*(min(d,4)-1+4*(deg-1))
538 if(d.le.4)then
539 c1=c(i)
540 c2=c(i+1)
541 c3=c(i+2)
542 else
543 c1=c(i)+(d-4)*(c(i)-c(i-3))
544 c2=c(i+1)+(d-4)*(c(i+1)-c(i-2))
545 c3=c(i+2)+(d-4)*(c(i+2)-c(i-1))
546 endif
547 delta1=n-trl*dexp(c1*z**c2*(1-z)**c3*c4)
548 i=i+24
549 if(d.le.4)then
550 c1=c(i)
551 c2=c(i+1)
552 c3=c(i+2)
553 else
554 c1=c(i)+(d-4)*(c(i)-c(i-3))
555 c2=c(i+1)+(d-4)*(c(i+1)-c(i-2))
556 c3=c(i+2)+(d-4)*(c(i+2)-c(i-1))
557 endif
558 delta2=n-trl*dexp(c1*z**c2*(1-z)**c3*c4)
559 return
560 end
561
562 subroutine lowesc(n,l,ll,trl,delta1,delta2)
563 integer i,j,n
564 double precision delta1,delta2,trl
565 double precision l(n,n),ll(n,n)
566 double precision ddot
567 external ddot
568 c compute $LL~=~(I-L)(I-L)'$
569 do 3 i=1,n
570 l(i,i)=l(i,i)-1
571 3 continue
572 do 4 i=1,n
573 do 5 j=1,i
574 ll(i,j)=ddot(n,l(i,1),n,l(j,1),n)
575 5 continue
576 4 continue
577 do 6 i=1,n
578 do 7 j=i+1,n
579 ll(i,j)=ll(j,i)
580 7 continue
581 6 continue
582 do 8 i=1,n
583 l(i,i)=l(i,i)+1
584 8 continue
585 c accumulate first two traces
586 trl=0
587 delta1=0
588 do 9 i=1,n
589 trl=trl+l(i,i)
590 delta1=delta1+ll(i,i)
591 9 continue
592 c $delta sub 2 = "tr" LL sup 2$
593 delta2=0
594 do 10 i=1,n
595 delta2=delta2+ddot(n,ll(i,1),n,ll(1,i),1)
596 10 continue
597 return
598 end
599
600 subroutine ehg169(d,vc,nc,ncmax,nv,nvmax,v,a,xi,c,hi,lo)
601 integer d,vc,nc,ncmax,nv,nvmax
602 integer a(ncmax), c(vc,ncmax), hi(ncmax), lo(ncmax)
603 DOUBLE PRECISION v(nvmax,d),xi(ncmax)
604
605 integer novhit(1),i,j,k,mc,mv,p
606 external ehg125,ehg182
607 integer ifloor
608 external ifloor
609
610 c as in bbox
611 c remaining vertices
612 do 3 i=2,vc-1
613 j=i-1
614 do 4 k=1,d
615 v(i,k)=v(1+mod(j,2)*(vc-1),k)
616 j=ifloor(DBLE(j)/2.D0)
617 4 continue
618 3 continue
619 c as in ehg131
620 mc=1
621 mv=vc
622 novhit(1)=-1
623 do 5 j=1,vc
624 c(j,mc)=j
625 5 continue
626 c as in rbuild
627 p=1
628 c top of while loop
629 6 if(.not.(p.le.nc))goto 7
630 if(a(p).ne.0)then
631 k=a(p)
632 c left son
633 mc=mc+1
634 lo(p)=mc
635 c right son
636 mc=mc+1
637 hi(p)=mc
638 call ehg125(p,mv,v,novhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k),
639 + c(1,p),c(1,lo(p)),c(1,hi(p)))
640 end if
641 p=p+1
642 goto 6
643 c bottom of while loop
644 7 if(.not.(mc.eq.nc))then
645 call ehg182(193)
646 end if
647 if(.not.(mv.eq.nv))then
648 call ehg182(193)
649 end if
650 return
651 end
652
653 DOUBLE PRECISION function ehg176(z)
654 c
655 DOUBLE PRECISION z(*)
656 c
657 integer d,vc,nv,nc
658 integer a(17), c(2,17)
659 integer hi(17), lo(17)
660 DOUBLE PRECISION v(10,1)
661 DOUBLE PRECISION vval(0:1,10)
662 DOUBLE PRECISION xi(17)
663 double precision ehg128
664 external ehg128
665
666 data d,vc,nv,nc /1,2,10,17/
667 data a(1) /1/
668 data hi(1),lo(1),xi(1) /3,2,0.3705D0/
669 data c(1,1) /1/
670 data c(2,1) /2/
671 data a(2) /1/
672 data hi(2),lo(2),xi(2) /5,4,0.2017D0/
673 data c(1,2) /1/
674 data c(2,2) /3/
675 data a(3) /1/
676 data hi(3),lo(3),xi(3) /7,6,0.5591D0/
677 data c(1,3) /3/
678 data c(2,3) /2/
679 data a(4) /1/
680 data hi(4),lo(4),xi(4) /9,8,0.1204D0/
681 data c(1,4) /1/
682 data c(2,4) /4/
683 data a(5) /1/
684 data hi(5),lo(5),xi(5) /11,10,0.2815D0/
685 data c(1,5) /4/
686 data c(2,5) /3/
687 data a(6) /1/
688 data hi(6),lo(6),xi(6) /13,12,0.4536D0/
689 data c(1,6) /3/
690 data c(2,6) /5/
691 data a(7) /1/
692 data hi(7),lo(7),xi(7) /15,14,0.7132D0/
693 data c(1,7) /5/
694 data c(2,7) /2/
695 data a(8) /0/
696 data c(1,8) /1/
697 data c(2,8) /6/
698 data a(9) /0/
699 data c(1,9) /6/
700 data c(2,9) /4/
701 data a(10) /0/
702 data c(1,10) /4/
703 data c(2,10) /7/
704 data a(11) /0/
705 data c(1,11) /7/
706 data c(2,11) /3/
707 data a(12) /0/
708 data c(1,12) /3/
709 data c(2,12) /8/
710 data a(13) /0/
711 data c(1,13) /8/
712 data c(2,13) /5/
713 data a(14) /0/
714 data c(1,14) /5/
715 data c(2,14) /9/
716 data a(15) /1/
717 data hi(15),lo(15),xi(15) /17,16,0.8751D0/
718 data c(1,15) /9/
719 data c(2,15) /2/
720 data a(16) /0/
721 data c(1,16) /9/
722 data c(2,16) /10/
723 data a(17) /0/
724 data c(1,17) /10/
725 data c(2,17) /2/
726 data vval(0,1) /-9.0572D-2/
727 data v(1,1) /-5.D-3/
728 data vval(1,1) /4.4844D0/
729 data vval(0,2) /-1.0856D-2/
730 data v(2,1) /1.005D0/
731 data vval(1,2) /-0.7736D0/
732 data vval(0,3) /-5.3718D-2/
733 data v(3,1) /0.3705D0/
734 data vval(1,3) /-0.3495D0/
735 data vval(0,4) /2.6152D-2/
736 data v(4,1) /0.2017D0/
737 data vval(1,4) /-0.7286D0/
738 data vval(0,5) /-5.8387D-2/
739 data v(5,1) /0.5591D0/
740 data vval(1,5) /0.1611D0/
741 data vval(0,6) /9.5807D-2/
742 data v(6,1) /0.1204D0/
743 data vval(1,6) /-0.7978D0/
744 data vval(0,7) /-3.1926D-2/
745 data v(7,1) /0.2815D0/
746 data vval(1,7) /-0.4457D0/
747 data vval(0,8) /-6.4170D-2/
748 data v(8,1) /0.4536D0/
749 data vval(1,8) /3.2813D-2/
750 data vval(0,9) /-2.0636D-2/
751 data v(9,1) /0.7132D0/
752 data vval(1,9) /0.3350D0/
753 data vval(0,10) /4.0172D-2/
754 data v(10,1) /0.8751D0/
755 data vval(1,10) /-4.1032D-2/
756 ehg176=ehg128(z,d,nc,vc,a,xi,lo,hi,c,v,nv,vval)
757 end
758
759 subroutine lowesa(trl,n,d,tau,nsing,delta1,delta2)
760 integer n,d,tau,nsing
761 double precision trl, delta1,delta2
762
763 integer dka,dkb
764 double precision alpha,d1a,d1b,d2a,d2b
765 external ehg141
766
767 call ehg141(trl,n,1,tau,d,nsing,dka,d1a,d2a)
768 call ehg141(trl,n,2,tau,d,nsing,dkb,d1b,d2b)
769 alpha=dble(tau-dka)/dble(dkb-dka)
770 delta1=(1-alpha)*d1a+alpha*d1b
771 delta2=(1-alpha)*d2a+alpha*d2b
772 return
773 end
774
775 subroutine ehg191(m,z,l,d,n,nf,nv,ncmax,vc,a,xi,lo,hi,c,v,nvmax,
776 + vval2,lf,lq)
777 c Args
778 integer m,d,n,nf,nv,ncmax,nvmax,vc
779 double precision z(m,d), l(m,n), xi(ncmax), v(nvmax,d),
780 + vval2(0:d,nvmax), lf(0:d,nvmax,nf)
781 integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),lo(ncmax),hi(ncmax)
782 c Var
783 integer lq1,i,i1,i2,j,p
784 double precision zi(8)
785 double precision ehg128
786 external ehg128
787
788 do 3 j=1,n
789 do 4 i2=1,nv
790 do 5 i1=0,d
791 vval2(i1,i2)=0
792 5 continue
793 4 continue
794 do 6 i=1,nv
795 c linear search for i in Lq
796 lq1=lq(i,1)
797 lq(i,1)=j
798 p=nf
799 c top of while loop
800 7 if(.not.(lq(i,p).ne.j))goto 8
801 p=p-1
802 goto 7
803 c bottom of while loop
804 8 lq(i,1)=lq1
805 if(lq(i,p).eq.j)then
806 do 9 i1=0,d
807 vval2(i1,i)=lf(i1,i,p)
808 9 continue
809 end if
810 6 continue
811 do 10 i=1,m
812 do 11 i1=1,d
813 zi(i1)=z(i,i1)
814 11 continue
815 l(i,j)=ehg128(zi,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2)
816 10 continue
817 3 continue
818 return
819 end
820
821 subroutine ehg196(tau,d,f,trl)
822 integer d,dka,dkb,tau
823 double precision alpha,f,trl,trla,trlb
824 external ehg197
825 call ehg197(1,d,f,dka,trla)
826 call ehg197(2,d,f,dkb,trlb)
827 alpha=dble(tau-dka)/dble(dkb-dka)
828 trl=(1-alpha)*trla+alpha*trlb
829 return
830 end
831
832 subroutine ehg197(deg,d,f,dk,trl)
833 integer deg,d,dk
834 double precision f, trl
835
836 double precision g1
837 dk = 0
838 if(deg.eq.1) dk=d+1
839 if(deg.eq.2) dk=int(dble((d+2)*(d+1))/2.d0)
840 g1 = (-0.08125d0*d+0.13d0)*d+1.05d0
841 trl = dk*(1+max(0.d0,(g1-f)/f))
842 return
843 end
844
845 subroutine ehg192(y,d,n,nf,nv,nvmax,vval,lf,lq)
846 integer d,i,i1,i2,j,n,nf,nv,nvmax
847 integer lq(nvmax,nf)
848 DOUBLE PRECISION i3
849 DOUBLE PRECISION lf(0:d,nvmax,nf),vval(0:d,nvmax),y(n)
850
851 do 3 i2=1,nv
852 do 4 i1=0,d
853 vval(i1,i2)=0
854 4 continue
855 3 continue
856 do 5 i=1,nv
857 do 6 j=1,nf
858 i3=y(lq(i,j))
859 do 7 i1=0,d
860 vval(i1,i)=vval(i1,i)+i3*lf(i1,i,j)
861 7 continue
862 6 continue
863 5 continue
864 return
865 end
866
867 DOUBLE PRECISION function ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,
868 + nvmax,vval)
869
870 c implicit none
871 c Args
872 integer d,ncmax,nvmax,vc
873 integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax)
874 DOUBLE PRECISION z(d),xi(ncmax),v(nvmax,d), vval(0:d,nvmax)
875 c Vars
876 logical i2,i3,i4,i5,i6,i7,i8,i9,i10
877 integer i,i1,i11,i12,ig,ii,j,lg,ll,m,nt,ur
878 integer t(20)
879 DOUBLE PRECISION ge,gn,gs,gw,gpe,gpn,gps,gpw,h,phi0,phi1,
880 + psi0,psi1,s,sew,sns,v0,v1,xibar
881 DOUBLE PRECISION g(0:8,256),g0(0:8),g1(0:8)
882
883 external ehg182,ehg184
884 c locate enclosing cell
885 nt=1
886 t(nt)=1
887 j=1
888 c top of while loop
889 3 if(.not.(a(j).ne.0))goto 4
890 nt=nt+1
891 if(z(a(j)).le.xi(j))then
892 i1=lo(j)
893 else
894 i1=hi(j)
895 end if
896 t(nt)=i1
897 if(.not.(nt.lt.20))then
898 call ehg182(181)
899 end if
900 j=t(nt)
901 goto 3
902 c bottom of while loop
903 4 continue
904 c tensor
905 do 5 i12=1,vc
906 do 6 i11=0,d
907 g(i11,i12)=vval(i11,c(i12,j))
908 6 continue
909 5 continue
910 lg=vc
911 ll=c(1,j)
912 ur=c(vc,j)
913 do 7 i=d,1,-1
914 h=(z(i)-v(ll,i))/(v(ur,i)-v(ll,i))
915 if(h.lt.-.001D0)then
916 call ehg184('eval ',z(1),d,1)
917 call ehg184('lowerlimit ',v(ll,1),d,nvmax)
918 else
919 if(1.001D0.lt.h)then
920 call ehg184('eval ',z(1),d,1)
921 call ehg184('upperlimit ',v(ur,1),d,nvmax)
922 end if
923 end if
924 if(-.001D0.le.h)then
925 i2=(h.le.1.001D0)
926 else
927 i2=.false.
928 end if
929 if(.not.i2)then
930 call ehg182(122)
931 end if
932 lg=int(DBLE(lg)/2.D0)
933 do 8 ig=1,lg
934 c Hermite basis
935 phi0=(1-h)**2*(1+2*h)
936 phi1=h**2*(3-2*h)
937 psi0=h*(1-h)**2
938 psi1=h**2*(h-1)
939 g(0,ig)=phi0*g(0,ig) + phi1*g(0,ig+lg) +
940 + (psi0*g(i,ig)+psi1*g(i,ig+lg)) * (v(ur,i)-v(ll,i))
941 do 9 ii=1,i-1
942 g(ii,ig)=phi0*g(ii,ig)+phi1*g(ii,ig+lg)
943 9 continue
944 8 continue
945 7 continue
946 s=g(0,1)
947 c blending
948 if(d.eq.2)then
949 c ----- North -----
950 v0=v(ll,1)
951 v1=v(ur,1)
952 do 10 i11=0,d
953 g0(i11)=vval(i11,c(3,j))
954 10 continue
955 do 11 i11=0,d
956 g1(i11)=vval(i11,c(4,j))
957 11 continue
958 xibar=v(ur,2)
959 m=nt-1
960 c top of while loop
961 12 if(m.eq.0)then
962 i4=.true.
963 else
964 if(a(t(m)).eq.2)then
965 i3=(xi(t(m)).eq.xibar)
966 else
967 i3=.false.
968 end if
969 i4=i3
970 end if
971 if(.not.(.not.i4))goto 13
972 m=m-1
973 c voidp junk
974 goto 12
975 c bottom of while loop
976 13 if(m.ge.1)then
977 m=hi(t(m))
978 c top of while loop
979 14 if(.not.(a(m).ne.0))goto 15
980 if(z(a(m)).le.xi(m))then
981 m=lo(m)
982 else
983 m=hi(m)
984 end if
985 goto 14
986 c bottom of while loop
987 15 if(v0.lt.v(c(1,m),1))then
988 v0=v(c(1,m),1)
989 do 16 i11=0,d
990 g0(i11)=vval(i11,c(1,m))
991 16 continue
992 end if
993 if(v(c(2,m),1).lt.v1)then
994 v1=v(c(2,m),1)
995 do 17 i11=0,d
996 g1(i11)=vval(i11,c(2,m))
997 17 continue
998 end if
999 end if
1000 h=(z(1)-v0)/(v1-v0)
1001 c Hermite basis
1002 phi0=(1-h)**2*(1+2*h)
1003 phi1=h**2*(3-2*h)
1004 psi0=h*(1-h)**2
1005 psi1=h**2*(h-1)
1006 gn=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0)
1007 gpn=phi0*g0(2)+phi1*g1(2)
1008 c ----- South -----
1009 v0=v(ll,1)
1010 v1=v(ur,1)
1011 do 18 i11=0,d
1012 g0(i11)=vval(i11,c(1,j))
1013 18 continue
1014 do 19 i11=0,d
1015 g1(i11)=vval(i11,c(2,j))
1016 19 continue
1017 xibar=v(ll,2)
1018 m=nt-1
1019 c top of while loop
1020 20 if(m.eq.0)then
1021 i6=.true.
1022 else
1023 if(a(t(m)).eq.2)then
1024 i5=(xi(t(m)).eq.xibar)
1025 else
1026 i5=.false.
1027 end if
1028 i6=i5
1029 end if
1030 if(.not.(.not.i6))goto 21
1031 m=m-1
1032 c voidp junk
1033 goto 20
1034 c bottom of while loop
1035 21 if(m.ge.1)then
1036 m=lo(t(m))
1037 c top of while loop
1038 22 if(.not.(a(m).ne.0))goto 23
1039 if(z(a(m)).le.xi(m))then
1040 m=lo(m)
1041 else
1042 m=hi(m)
1043 end if
1044 goto 22
1045 c bottom of while loop
1046 23 if(v0.lt.v(c(3,m),1))then
1047 v0=v(c(3,m),1)
1048 do 24 i11=0,d
1049 g0(i11)=vval(i11,c(3,m))
1050 24 continue
1051 end if
1052 if(v(c(4,m),1).lt.v1)then
1053 v1=v(c(4,m),1)
1054 do 25 i11=0,d
1055 g1(i11)=vval(i11,c(4,m))
1056 25 continue
1057 end if
1058 end if
1059 h=(z(1)-v0)/(v1-v0)
1060 c Hermite basis
1061 phi0=(1-h)**2*(1+2*h)
1062 phi1=h**2*(3-2*h)
1063 psi0=h*(1-h)**2
1064 psi1=h**2*(h-1)
1065 gs=phi0*g0(0)+phi1*g1(0)+(psi0*g0(1)+psi1*g1(1))*(v1-v0)
1066 gps=phi0*g0(2)+phi1*g1(2)
1067 c ----- East -----
1068 v0=v(ll,2)
1069 v1=v(ur,2)
1070 do 26 i11=0,d
1071 g0(i11)=vval(i11,c(2,j))
1072 26 continue
1073 do 27 i11=0,d
1074 g1(i11)=vval(i11,c(4,j))
1075 27 continue
1076 xibar=v(ur,1)
1077 m=nt-1
1078 c top of while loop
1079 28 if(m.eq.0)then
1080 i8=.true.
1081 else
1082 if(a(t(m)).eq.1)then
1083 i7=(xi(t(m)).eq.xibar)
1084 else
1085 i7=.false.
1086 end if
1087 i8=i7
1088 end if
1089 if(.not.(.not.i8))goto 29
1090 m=m-1
1091 c voidp junk
1092 goto 28
1093 c bottom of while loop
1094 29 if(m.ge.1)then
1095 m=hi(t(m))
1096 c top of while loop
1097 30 if(.not.(a(m).ne.0))goto 31
1098 if(z(a(m)).le.xi(m))then
1099 m=lo(m)
1100 else
1101 m=hi(m)
1102 end if
1103 goto 30
1104 c bottom of while loop
1105 31 if(v0.lt.v(c(1,m),2))then
1106 v0=v(c(1,m),2)
1107 do 32 i11=0,d
1108 g0(i11)=vval(i11,c(1,m))
1109 32 continue
1110 end if
1111 if(v(c(3,m),2).lt.v1)then
1112 v1=v(c(3,m),2)
1113 do 33 i11=0,d
1114 g1(i11)=vval(i11,c(3,m))
1115 33 continue
1116 end if
1117 end if
1118 h=(z(2)-v0)/(v1-v0)
1119 c Hermite basis
1120 phi0=(1-h)**2*(1+2*h)
1121 phi1=h**2*(3-2*h)
1122 psi0=h*(1-h)**2
1123 psi1=h**2*(h-1)
1124 ge=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0)
1125 gpe=phi0*g0(1)+phi1*g1(1)
1126 c ----- West -----
1127 v0=v(ll,2)
1128 v1=v(ur,2)
1129 do 34 i11=0,d
1130 g0(i11)=vval(i11,c(1,j))
1131 34 continue
1132 do 35 i11=0,d
1133 g1(i11)=vval(i11,c(3,j))
1134 35 continue
1135 xibar=v(ll,1)
1136 m=nt-1
1137 c top of while loop
1138 36 if(m.eq.0)then
1139 i10=.true.
1140 else
1141 if(a(t(m)).eq.1)then
1142 i9=(xi(t(m)).eq.xibar)
1143 else
1144 i9=.false.
1145 end if
1146 i10=i9
1147 end if
1148 if(.not.(.not.i10))goto 37
1149 m=m-1
1150 c voidp junk
1151 goto 36
1152 c bottom of while loop
1153 37 if(m.ge.1)then
1154 m=lo(t(m))
1155 c top of while loop
1156 38 if(.not.(a(m).ne.0))goto 39
1157 if(z(a(m)).le.xi(m))then
1158 m=lo(m)
1159 else
1160 m=hi(m)
1161 end if
1162 goto 38
1163 c bottom of while loop
1164 39 if(v0.lt.v(c(2,m),2))then
1165 v0=v(c(2,m),2)
1166 do 40 i11=0,d
1167 g0(i11)=vval(i11,c(2,m))
1168 40 continue
1169 end if
1170 if(v(c(4,m),2).lt.v1)then
1171 v1=v(c(4,m),2)
1172 do 41 i11=0,d
1173 g1(i11)=vval(i11,c(4,m))
1174 41 continue
1175 end if
1176 end if
1177 h=(z(2)-v0)/(v1-v0)
1178 c Hermite basis
1179 phi0=(1-h)**2*(1+2*h)
1180 phi1=h**2*(3-2*h)
1181 psi0=h*(1-h)**2
1182 psi1=h**2*(h-1)
1183 gw=phi0*g0(0)+phi1*g1(0)+(psi0*g0(2)+psi1*g1(2))*(v1-v0)
1184 gpw=phi0*g0(1)+phi1*g1(1)
1185 c NS
1186 h=(z(2)-v(ll,2))/(v(ur,2)-v(ll,2))
1187 c Hermite basis
1188 phi0=(1-h)**2*(1+2*h)
1189 phi1=h**2*(3-2*h)
1190 psi0=h*(1-h)**2
1191 psi1=h**2*(h-1)
1192 sns=phi0*gs+phi1*gn+(psi0*gps+psi1*gpn)*(v(ur,2)-v(ll,2))
1193 c EW
1194 h=(z(1)-v(ll,1))/(v(ur,1)-v(ll,1))
1195 c Hermite basis
1196 phi0=(1-h)**2*(1+2*h)
1197 phi1=h**2*(3-2*h)
1198 psi0=h*(1-h)**2
1199 psi1=h**2*(h-1)
1200 sew=phi0*gw+phi1*ge+(psi0*gpw+psi1*gpe)*(v(ur,1)-v(ll,1))
1201 s=(sns+sew)-s
1202 end if
1203 ehg128=s
1204 return
1205 end
1206
1207 integer function ifloor(x)
1208 DOUBLE PRECISION x
1209 ifloor=int(x)
1210 if(ifloor.gt.x) ifloor=ifloor-1
1211 end
1212
1213 c DSIGN is unused, causes conflicts on some platforms
1214 c DOUBLE PRECISION function DSIGN(a1,a2)
1215 c DOUBLE PRECISION a1, a2
1216 c DSIGN=DABS(a1)
1217 c if(a2.ge.0)DSIGN=-DSIGN
1218 c end
1219
1220
1221 c ehg136() is the workhorse of lowesf(.)
1222 c n = number of observations
1223 c m = number of x values at which to evaluate
1224 c f = span
1225 c nf = min(n, floor(f * n))
1226 subroutine ehg136(u,lm,m,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,
1227 + od,o,ihat,w,rcond,sing,dd,tdeg,cdeg,s)
1228 integer identi,d,dd,i,i1,ihat,info,j,k,kernel,l,lm,m,n,nf,
1229 + od,sing,tdeg
1230 integer cdeg(8),psi(n)
1231 double precision f,i2,rcond,scale,tol
1232 double precision o(m,n),sigma(15),e(15,15),g(15,15),b(nf,k),
1233 $ dist(n),eta(nf),dgamma(15),q(8),qraux(15),rw(n),s(0:od,m),
1234 $ u(lm,d),w(nf),work(15),x(n,d),y(n)
1235
1236 external ehg127,ehg182,dqrsl
1237 double precision ddot
1238 external ddot
1239
1240 c V -> g
1241 c U -> e
1242 c Identity -> identi
1243 c L -> o
1244 c X -> b
1245 if(k .gt. nf-1) call ehg182(104)
1246 if(k .gt. 15) call ehg182(105)
1247 do 3 identi=1,n
1248 psi(identi)=identi
1249 3 continue
1250 do 4 l=1,m
1251 do 5 i1=1,d
1252 q(i1)=u(l,i1)
1253 5 continue
1254 call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,
1255 + rcond,sing,sigma,e,g,dgamma,qraux,work,tol,dd,tdeg,cdeg,
1256 + s(0,l))
1257 if(ihat.eq.1)then
1258 c $L sub {l,l} =
1259 c V sub {1,:} SIGMA sup {+} U sup T
1260 c (Q sup T W e sub i )$
1261 if(.not.(m.eq.n))then
1262 call ehg182(123)
1263 end if
1264 c find $i$ such that $l = psi sub i$
1265 i=1
1266 c top of while loop
1267 6 if(.not.(l.ne.psi(i)))goto 7
1268 i=i+1
1269 if(.not.(i.lt.nf))then
1270 call ehg182(123)
1271 c next line is not in current dloess
1272 goto 7
1273 end if
1274 goto 6
1275 c bottom of while loop
1276 7 do 8 i1=1,nf
1277 eta(i1)=0
1278 8 continue
1279 eta(i)=w(i)
1280 c $eta = Q sup T W e sub i$
1281 call dqrsl(b,nf,nf,k,qraux,eta,eta,eta,eta,eta,eta,1000,
1282 + info)
1283 c $gamma = U sup T eta sub {1:k}$
1284 do 9 i1=1,k
1285 dgamma(i1)=0
1286 9 continue
1287 do 10 j=1,k
1288 i2=eta(j)
1289 do 11 i1=1,k
1290 dgamma(i1)=dgamma(i1)+i2*e(j,i1)
1291 11 continue
1292 10 continue
1293 c $gamma = SIGMA sup {+} gamma$
1294 do 12 j=1,k
1295 if(tol.lt.sigma(j))then
1296 dgamma(j)=dgamma(j)/sigma(j)
1297 else
1298 dgamma(j)=0.d0
1299 end if
1300 12 continue
1301 c voidp junk
1302 c voidp junk
1303 o(l,1)=ddot(k,g(1,1),15,dgamma,1)
1304 else
1305 if(ihat.eq.2)then
1306 c $L sub {l,:} =
1307 c V sub {1,:} SIGMA sup {+}
1308 c ( U sup T Q sup T ) W $
1309 do 13 i1=1,n
1310 o(l,i1)=0
1311 13 continue
1312 do 14 j=1,k
1313 do 15 i1=1,nf
1314 eta(i1)=0
1315 15 continue
1316 do 16 i1=1,k
1317 eta(i1)=e(i1,j)
1318 16 continue
1319 call dqrsl(b,nf,nf,k,qraux,eta,eta,work,work,work,work
1320 + ,10000,info)
1321 if(tol.lt.sigma(j))then
1322 scale=1.d0/sigma(j)
1323 else
1324 scale=0.d0
1325 end if
1326 do 17 i1=1,nf
1327 eta(i1)=eta(i1)*(scale*w(i1))
1328 17 continue
1329 do 18 i=1,nf
1330 o(l,psi(i))=o(l,psi(i))+g(1,j)*eta(i)
1331 18 continue
1332 14 continue
1333 end if
1334 end if
1335 4 continue
1336 return
1337 end
1338
1339 c called from lowesb() ... compute fit ..?..?...
1340 c somewhat similar to ehg136
1341 subroutine ehg139(v,nvmax,nv,n,d,nf,f,x,pi,psi,y,rw,trl,kernel,k,
1342 + dist,phi,eta,b,od,w,diagl,vval2,ncmax,vc,a,xi,lo,hi,c,
1343 + rcond,sing,dd,tdeg,cdeg,lq,lf,setlf,s)
1344 logical setlf
1345 integer identi,d,dd,i,i2,i3,i5,i6,ii,ileaf,info,j,k,kernel,
1346 + l,n,ncmax,nf,nleaf,nv,nvmax,od,sing,tdeg,vc
1347 integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),cdeg(8),hi(ncmax),
1348 + leaf(256),lo(ncmax),pi(n),psi(n)
1349 DOUBLE PRECISION f,i1,i4,i7,rcond,scale,term,tol,trl
1350 DOUBLE PRECISION lf(0:d,nvmax,nf),sigma(15),u(15,15),e(15,15),
1351 + b(nf,k),diagl(n),dist(n),eta(nf),DGAMMA(15),q(8),qraux(15),
1352 + rw(n),s(0:od,nv),v(nvmax,d),vval2(0:d,nv),w(nf),work(15),
1353 + x(n,d),xi(ncmax),y(n),z(8)
1354 DOUBLE PRECISION phi(n)
1355
1356 external ehg127,ehg182,DQRSL,ehg137
1357 DOUBLE PRECISION ehg128
1358 external ehg128
1359 DOUBLE PRECISION DDOT
1360 external DDOT
1361
1362 c V -> e
1363 c Identity -> identi
1364 c X -> b
1365 c l2fit with trace(L)
1366 if(k .gt. nf-1) call ehg182(104)
1367 if(k .gt. 15) call ehg182(105)
1368 if(trl.ne.0)then
1369 do 3 i5=1,n
1370 diagl(i5)=0
1371 3 continue
1372 do 4 i6=1,nv
1373 do 5 i5=0,d
1374 vval2(i5,i6)=0
1375 5 continue
1376 4 continue
1377 end if
1378 do 6 identi=1,n
1379 psi(identi)=identi
1380 6 continue
1381 do 7 l=1,nv
1382 do 8 i5=1,d
1383 q(i5)=v(l,i5)
1384 8 continue
1385 call ehg127(q,n,d,nf,f,x,psi,y,rw,kernel,k,dist,eta,b,od,w,
1386 + rcond,sing,sigma,u,e,DGAMMA,qraux,work,tol,dd,tdeg,cdeg,
1387 + s(0,l))
1388 if(trl.ne.0)then
1389 c invert $psi$
1390 do 9 i5=1,n
1391 phi(i5)=0
1392 9 continue
1393 do 10 i=1,nf
1394 phi(psi(i))=i
1395 10 continue
1396 do 11 i5=1,d
1397 z(i5)=v(l,i5)
1398 11 continue
1399 call ehg137(z,leaf,nleaf,d,ncmax,a,xi,
1400 + lo,hi)
1401 do 12 ileaf=1,nleaf
1402 do 13 ii=lo(leaf(ileaf)),hi(leaf(ileaf))
1403 i=int(phi(pi(ii)))
1404 if(i.ne.0)then
1405 if(.not.(psi(i).eq.pi(ii)))then
1406 call ehg182(194)
1407 end if
1408 do 14 i5=1,nf
1409 eta(i5)=0
1410 14 continue
1411 eta(i)=w(i)
1412 c $eta = Q sup T W e sub i$
1413 call DQRSL(b,nf,nf,k,qraux,eta,work,eta,eta,work,
1414 + work,1000,info)
1415 do 15 j=1,k
1416 if(tol.lt.sigma(j))then
1417 i4=DDOT(k,u(1,j),1,eta,1)/sigma(j)
1418 else
1419 i4=0.D0
1420 end if
1421 DGAMMA(j)=i4
1422 15 continue
1423 do 16 j=1,d+1
1424 c bug fix 2006-07-15 for k=1, od>1. (thanks [email protected])
1425 if(j.le.k)then
1426 vval2(j-1,l)=DDOT(k,e(j,1),15,DGAMMA,1)
1427 else
1428 vval2(j-1,l)=0.0d0
1429 end if
1430 16 continue
1431 do 17 i5=1,d
1432 z(i5)=x(pi(ii),i5)
1433 17 continue
1434 term=ehg128(z,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,
1435 + vval2)
1436 diagl(pi(ii))=diagl(pi(ii))+term
1437 do 18 i5=0,d
1438 vval2(i5,l)=0
1439 18 continue
1440 end if
1441 13 continue
1442 12 continue
1443 end if
1444 if(setlf)then
1445 c $Lf sub {:,l,:} = V SIGMA sup {+} U sup T Q sup T W$
1446 if(.not.(k.ge.d+1))then
1447 call ehg182(196)
1448 end if
1449 do 19 i5=1,nf
1450 lq(l,i5)=psi(i5)
1451 19 continue
1452 do 20 i6=1,nf
1453 do 21 i5=0,d
1454 lf(i5,l,i6)=0
1455 21 continue
1456 20 continue
1457 do 22 j=1,k
1458 do 23 i5=1,nf
1459 eta(i5)=0
1460 23 continue
1461 do 24 i5=1,k
1462 eta(i5)=u(i5,j)
1463 24 continue
1464 call DQRSL(b,nf,nf,k,qraux,eta,eta,work,work,work,work,
1465 + 10000,info)
1466 if(tol.lt.sigma(j))then
1467 scale=1.D0/sigma(j)
1468 else
1469 scale=0.D0
1470 end if
1471 do 25 i5=1,nf
1472 eta(i5)=eta(i5)*(scale*w(i5))
1473 25 continue
1474 do 26 i=1,nf
1475 i7=eta(i)
1476 do 27 i5=0,d
1477 if(i5.lt.k)then
1478 lf(i5,l,i)=lf(i5,l,i)+e(1+i5,j)*i7
1479 else
1480 lf(i5,l,i)=0
1481 end if
1482 27 continue
1483 26 continue
1484 22 continue
1485 end if
1486 7 continue
1487 if(trl.ne.0)then
1488 if(n.le.0)then
1489 trl=0.D0
1490 else
1491 i3=n
1492 i1=diagl(i3)
1493 do 28 i2=i3-1,1,-1
1494 i1=diagl(i2)+i1
1495 28 continue
1496 trl=i1
1497 end if
1498 end if
1499 return
1500 end
1501
1502 subroutine lowesb(xx,yy,ww,diagl,infl,iv,wv)
1503 integer infl
1504 integer iv(*)
1505 DOUBLE PRECISION xx(*),yy(*),ww(*),diagl(*),wv(*)
1506 c Var
1507 DOUBLE PRECISION trl
1508 logical setlf
1509
1510 integer ifloor
1511 external ifloor
1512 external ehg131,ehg182,ehg183
1513
1514 if(.not.(iv(28).ne.173))then
1515 call ehg182(174)
1516 end if
1517 if(iv(28).ne.172)then
1518 if(.not.(iv(28).eq.171))then
1519 call ehg182(171)
1520 end if
1521 end if
1522 iv(28)=173
1523 if(infl.ne.0)then
1524 trl=1.D0
1525 else
1526 trl=0.D0
1527 end if
1528 setlf=(iv(27).ne.iv(25))
1529 call ehg131(xx,yy,ww,trl,diagl,iv(20),iv(29),iv(3),iv(2),iv(5),
1530 + iv(17),iv(4),iv(6),iv(14),iv(19),wv(1),iv(iv(7)),iv(iv(8)),
1531 + iv(iv(9)),iv(iv(10)),iv(iv(22)),iv(iv(27)),wv(iv(11)),
1532 + iv(iv(23)),wv(iv(13)),wv(iv(12)),wv(iv(15)),wv(iv(16)),
1533 + wv(iv(18)),ifloor(iv(3)*wv(2)),wv(3),wv(iv(26)),wv(iv(24)),
1534 + wv(4),iv(30),iv(33),iv(32),iv(41),iv(iv(25)),wv(iv(34)),
1535 + setlf)
1536 if(iv(14).lt.iv(6)+DBLE(iv(4))/2.D0)then
1537 call ehg183('k-d tree limited by memory; nvmax=',
1538 + iv(14),1,1)
1539 else
1540 if(iv(17).lt.iv(5)+2)then
1541 call ehg183('k-d tree limited by memory. ncmax=',
1542 + iv(17),1,1)
1543 end if
1544 end if
1545 return
1546 end
1547
1548 c lowesd() : Initialize iv(*) and v(1:4)
1549 c ------ called only by loess_workspace() in ./loessc.c
1550 subroutine lowesd(iv, liv,lv, v, d,n,f,ideg,nf,nvmax, setlf)
1551 integer liv,lv, d,n, ideg,nf,nvmax, setlf
1552 c setlf {Rboolean}: if(true) need L [nf x nvmax] matrices
1553 integer iv(liv)
1554 double precision f, v(lv)
1555
1556 c had nf = min(n,ifloor(n*f))
1557
1558 integer bound,i,i1,i2,j,ncmax,vc
1559 external ehg182
1560 integer ifloor
1561 external ifloor
1562 c
1563 c unnecessary initialization of i1 to keep g77 -Wall happy
1564 c
1565 i1 = 0
1566 cc version -> versio
1567 c if(.not.(versio.eq.106))then
1568 c call ehg182(100)
1569 c end if
1570 iv(28)=171
1571 iv(2)=d
1572 iv(3)=n
1573 vc=2**d
1574 iv(4)=vc
1575 if(.not.(0.lt.f))then
1576 call ehg182(120)
1577 end if
1578
1579 iv(19)=nf
1580 iv(20)=1
1581 if(ideg.eq.0)then
1582 i1=1
1583 else
1584 if(ideg.eq.1)then
1585 i1=d+1
1586 else
1587 if(ideg.eq.2)then
1588 i1=int(dble((d+2)*(d+1))/2.d0)
1589 end if
1590 end if
1591 end if
1592 iv(29)=i1
1593 iv(21)=1
1594 iv(14)=nvmax
1595 ncmax=nvmax
1596 iv(17)=ncmax
1597 iv(30)=0
1598 iv(32)=ideg
1599 if(.not.(ideg.ge.0))then
1600 call ehg182(195)
1601 end if
1602 if(.not.(ideg.le.2))then
1603 call ehg182(195)
1604 end if
1605 iv(33)=d
1606 do 3 i2=41,49
1607 iv(i2)=ideg
1608 3 continue
1609 iv(7)=50
1610 iv(8)=iv(7)+ncmax
1611 iv(9)=iv(8)+vc*ncmax
1612 iv(10)=iv(9)+ncmax
1613 iv(22)=iv(10)+ncmax
1614 c initialize permutation
1615 j=iv(22)-1
1616 do 4 i=1,n
1617 iv(j+i)=i
1618 4 continue
1619 iv(23)=iv(22)+n
1620 iv(25)=iv(23)+nvmax
1621 if(setlf.ne.0)then
1622 iv(27)=iv(25)+nvmax*nf
1623 else
1624 iv(27)=iv(25)
1625 end if
1626 bound=iv(27)+n
1627 if(.not.(bound-1.le.liv))then
1628 call ehg182(102)
1629 end if
1630 iv(11)=50
1631 iv(13)=iv(11)+nvmax*d
1632 iv(12)=iv(13)+(d+1)*nvmax
1633 iv(15)=iv(12)+ncmax
1634 iv(16)=iv(15)+n
1635 iv(18)=iv(16)+nf
1636 iv(24)=iv(18)+iv(29)*nf
1637 iv(34)=iv(24)+(d+1)*nvmax
1638 if(setlf.ne.0)then
1639 iv(26)=iv(34)+(d+1)*nvmax*nf
1640 else
1641 iv(26)=iv(34)
1642 end if
1643 bound=iv(26)+nf
1644 if(.not.(bound-1.le.lv))then
1645 call ehg182(103)
1646 end if
1647 v(1)=f
1648 v(2)=0.05d0
1649 v(3)=0.d0
1650 v(4)=1.d0
1651 return
1652 end
1653
1654 subroutine lowese(iv,wv,m,z,s)
1655 integer m
1656 integer iv(*)
1657 double precision s(m),wv(*),z(m,1)
1658
1659 external ehg133,ehg182
1660
1661 if(.not.(iv(28).ne.172))then
1662 call ehg182(172)
1663 end if
1664 if(.not.(iv(28).eq.173))then
1665 call ehg182(173)
1666 end if
1667 call ehg133(iv(2),iv(4),iv(14),iv(17),iv(iv(7)),iv(iv(
1668 +8)),iv(iv(9)),iv(iv(10)),wv(iv(11)),wv(iv(13)),wv(iv(12)),m,z,s)
1669 return
1670 end
1671
1672 c "direct" (non-"interpolate") fit aka predict() :
1673 subroutine lowesf(xx,yy,ww,iv,wv,m,z,l,ihat,s)
1674 integer m,ihat
1675 c m = number of x values at which to evaluate
1676 integer iv(*)
1677 double precision xx(*),yy(*),ww(*),wv(*),z(m,1),l(m,*),s(m)
1678
1679 logical i1
1680
1681 external ehg182,ehg136
1682 if(171.le.iv(28))then
1683 i1=(iv(28).le.174)
1684 else
1685 i1=.false.
1686 end if
1687 if(.not.i1)then
1688 call ehg182(171)
1689 end if
1690 iv(28)=172
1691 if(.not.(iv(14).ge.iv(19)))then
1692 call ehg182(186)
1693 end if
1694
1695 c do the work; in ehg136() give the argument names as they are there:
1696 c ehg136(u,lm,m, n, d, nf, f, x, psi, y ,rw,
1697 call ehg136(z,m,m,iv(3),iv(2),iv(19),wv(1),xx,iv(iv(22)),yy,ww,
1698 c kernel, k, dist, eta, b, od,o,ihat,
1699 + iv(20),iv(29),wv(iv(15)),wv(iv(16)),wv(iv(18)),0,l,ihat,
1700 c w, rcond,sing, dd, tdeg,cdeg, s)
1701 + wv(iv(26)),wv(4),iv(30),iv(33),iv(32),iv(41),s)
1702 return
1703 end
1704
1705 c Called either from loess_raw() only for case [surf_stat = "interpolate/exact"], or
1706 c from loess_ise() {used only when 'se = TRUE' and surface = "interpolate"}
1707 subroutine lowesl(iv,wv,m,z,l)
1708 integer m
1709 integer iv(*)
1710 double precision l(m,*), wv(*), z(m,1)
1711
1712 external ehg182,ehg191
1713
1714 if(.not.(iv(28).ne.172))then
1715 call ehg182(172)
1716 end if
1717 if(.not.(iv(28).eq.173))then
1718 call ehg182(173)
1719 end if
1720 if(.not.(iv(26).ne.iv(34)))then
1721 call ehg182(175)
1722 end if
1723 call ehg191(m,z,l,iv(2),iv(3),iv(19),iv(6),iv(17),iv(4),iv(iv(7)),
1724 + wv(iv(12)),iv(iv(10)),iv(iv(9)),iv(iv(8)),wv(iv(11)),iv(14),
1725 + wv(iv(24)),wv(iv(34)),iv(iv(25)))
1726 return
1727 end
1728
1729 c Not used
1730 subroutine lowesr(yy,iv,wv)
1731 integer iv(*)
1732 DOUBLE PRECISION yy(*),wv(*)
1733
1734 external ehg182,ehg192
1735 if(.not.(iv(28).ne.172))then
1736 call ehg182(172)
1737 end if
1738 if(.not.(iv(28).eq.173))then
1739 call ehg182(173)
1740 end if
1741 call ehg192(yy,iv(2),iv(3),iv(19),iv(6),iv(14),wv(iv(13)),
1742 + wv(iv(34)),iv(iv(25)))
1743 return
1744 end
1745
1746 subroutine lowesw(res,n,rw,pi)
1747 c Tranliterated from Devlin's ratfor
1748
1749 c implicit none
1750 c Args
1751 integer n
1752 double precision res(n), rw(n)
1753 integer pi(n)
1754 c Var
1755 integer identi,i,i1,nh
1756 double precision cmad,rsmall
1757
1758 integer ifloor
1759 double precision d1mach
1760
1761 external ehg106
1762 external ifloor
1763 external d1mach
1764
1765 c Identity -> identi
1766
1767 c find median of absolute residuals
1768 do 3 i1=1,n
1769 rw(i1)=dabs(res(i1))
1770 3 continue
1771 do 4 identi=1,n
1772 pi(identi)=identi
1773 4 continue
1774 nh=ifloor(dble(n)/2.d0)+1
1775 c partial sort to find 6*mad
1776 call ehg106(1,n,nh,1,rw,pi,n)
1777 if((n-nh)+1.lt.nh)then
1778 call ehg106(1,nh-1,nh-1,1,rw,pi,n)
1779 cmad=3*(rw(pi(nh))+rw(pi(nh-1)))
1780 else
1781 cmad=6*rw(pi(nh))
1782 end if
1783 rsmall=d1mach(1)
1784 if(cmad.lt.rsmall)then
1785 do 5 i1=1,n
1786 rw(i1)=1
1787 5 continue
1788 else
1789 do 6 i=1,n
1790 if(cmad*0.999d0.lt.rw(i))then
1791 rw(i)=0
1792 else
1793 if(cmad*0.001d0.lt.rw(i))then
1794 rw(i)=(1-(rw(i)/cmad)**2)**2
1795 else
1796 rw(i)=1
1797 end if
1798 end if
1799 6 continue
1800 end if
1801 return
1802 end
1803
1804 subroutine lowesp(n,y,yhat,pwgts,rwgts,pi,ytilde)
1805 integer n
1806 integer pi(n)
1807 double precision y(n),yhat(n),pwgts(n),rwgts(n),ytilde(n)
1808 c Var
1809 double precision c,i1,i4,mad
1810 integer i2,i3,i,m
1811
1812 external ehg106
1813 integer ifloor
1814 external ifloor
1815 c median absolute deviation (using partial sort):
1816 do 3 i=1,n
1817 ytilde(i)=dabs(y(i)-yhat(i))*dsqrt(pwgts(i))
1818 pi(i) = i
1819 3 continue
1820 m=ifloor(dble(n)/2.d0)+1
1821 call ehg106(1,n,m,1,ytilde,pi,n)
1822 if((n-m)+1.lt.m)then
1823 call ehg106(1,m-1,m-1,1,ytilde,pi,n)
1824 mad=(ytilde(pi(m-1))+ytilde(pi(m)))/2
1825 else
1826 mad=ytilde(pi(m))
1827 end if
1828 c magic constant
1829 c=(6*mad)**2/5
1830 do 5 i=1,n
1831 ytilde(i)= 1 - ((y(i)-yhat(i))**2 * pwgts(i))/c
1832 5 continue
1833 do 6 i=1,n
1834 ytilde(i)=ytilde(i)*dsqrt(rwgts(i))
1835 6 continue
1836 if(n.le.0)then
1837 i4=0.d0
1838 else
1839 i3=n
1840 i1=ytilde(i3)
1841 do 7 i2=i3-1,1,-1
1842 i1=ytilde(i2)+i1
1843 7 continue
1844 i4=i1
1845 end if
1846 c=n/i4
1847 c pseudovalues
1848 do 8 i=1,n
1849 ytilde(i)=yhat(i) + (c*rwgts(i))*(y(i)-yhat(i))
1850 8 continue
1851 return
1852 end
1853
1854 subroutine ehg124(ll,uu,d,n,nv,nc,ncmax,vc,x,pi,a,xi,lo,hi,c,v,
1855 + vhit,nvmax,fc,fd,dd)
1856
1857 integer ll,uu,d,n,nv,nc,ncmax,vc,nvmax,fc,dd
1858 integer a(ncmax),c(vc,ncmax),hi(ncmax),lo(ncmax),pi(n),vhit(nvmax)
1859 DOUBLE PRECISION fd, v(nvmax,d),x(n,d),xi(ncmax)
1860
1861 logical i1,i2,leaf
1862 integer i4,inorm2,k,l,m,p,u, upper, lower, check, offset
1863 DOUBLE PRECISION diam,diag(8),sigma(8)
1864
1865 external ehg125,ehg106,ehg129
1866 integer IDAMAX
1867 external IDAMAX
1868 p=1
1869 l=ll
1870 u=uu
1871 lo(p)=l
1872 hi(p)=u
1873 c top of while loop
1874 3 if(.not.(p.le.nc))goto 4
1875 do 5 i4=1,dd
1876 diag(i4)=v(c(vc,p),i4)-v(c(1,p),i4)
1877 5 continue
1878 diam=0
1879 do 6 inorm2=1,dd
1880 diam=diam+diag(inorm2)**2
1881 6 continue
1882 diam=DSQRT(diam)
1883 if((u-l)+1.le.fc)then
1884 i1=.true.
1885 else
1886 i1=(diam.le.fd)
1887 end if
1888 if(i1)then
1889 leaf=.true.
1890 else
1891 if(ncmax.lt.nc+2)then
1892 i2=.true.
1893 else
1894 i2=(nvmax.lt.nv+DBLE(vc)/2.D0)
1895 end if
1896 leaf=i2
1897 end if
1898 if(.not.leaf)then
1899 call ehg129(l,u,dd,x,pi,n,sigma)
1900 k=IDAMAX(dd,sigma,1)
1901 m=int(DBLE(l+u)/2.D0)
1902 call ehg106(l,u,m,1,x(1,k),pi,n)
1903
1904 c all ties go with hi son
1905 c top of while loop
1906 c bug fix from [email protected] 2006-07-20
1907 offset = 0
1908 7 if(((m+offset).ge.u).or.((m+offset).lt.l))goto 8
1909 if(offset .lt. 0)then
1910 lower = l
1911 check = m + offset
1912 upper = check
1913 else
1914 lower = m + offset + 1
1915 check = lower
1916 upper = u
1917 end if
1918 call ehg106(lower,upper,check,1,x(1,k),pi,n)
1919 if(x(pi(m + offset),k).eq.x(pi(m+offset+1),k))then
1920 offset = -offset
1921 if(offset .ge. 0) then
1922 offset = offset + 1
1923 end if
1924 goto 7
1925 else
1926 m = m + offset
1927 goto 8
1928 end if
1929
1930 c bottom of while loop
1931 8 if(v(c(1,p),k).eq.x(pi(m),k))then
1932 leaf=.true.
1933 else
1934 leaf=(v(c(vc,p),k).eq.x(pi(m),k))
1935 end if
1936 end if
1937 if(leaf)then
1938 a(p)=0
1939 else
1940 a(p)=k
1941 xi(p)=x(pi(m),k)
1942 c left son
1943 nc=nc+1
1944 lo(p)=nc
1945 lo(nc)=l
1946 hi(nc)=m
1947 c right son
1948 nc=nc+1
1949 hi(p)=nc
1950 lo(nc)=m+1
1951 hi(nc)=u
1952 call ehg125(p,nv,v,vhit,nvmax,d,k,xi(p),2**(k-1),2**(d-k),
1953 + c(1,p),c(1,lo(p)),c(1,hi(p)))
1954 end if
1955 p=p+1
1956 l=lo(p)
1957 u=hi(p)
1958 goto 3
1959 c bottom of while loop
1960 4 return
1961 end
1962
1963 subroutine ehg129(l,u,d,x,pi,n,sigma)
1964 integer d,execnt,i,k,l,n,u
1965 integer pi(n)
1966 DOUBLE PRECISION machin,alpha,beta,t
1967 DOUBLE PRECISION sigma(d),x(n,d)
1968 DOUBLE PRECISION D1MACH
1969 external D1MACH
1970 save machin,execnt
1971 data execnt /0/
1972 c MachInf -> machin
1973 execnt=execnt+1
1974 if(execnt.eq.1)then
1975 c initialize d1mach(2) === DBL_MAX:
1976 machin=D1MACH(2)
1977 end if
1978 do 3 k=1,d
1979 alpha=machin
1980 beta=-machin
1981 do 4 i=l,u
1982 t=x(pi(i),k)
1983 alpha=min(alpha,x(pi(i),k))
1984 beta=max(beta,t)
1985 4 continue
1986 sigma(k)=beta-alpha
1987 3 continue
1988 return
1989 end
1990
1991 c {called only from ehg127} purpose...?...
1992 subroutine ehg137(z,leaf,nleaf,d,ncmax,a,xi,lo,hi)
1993 integer d,nleaf
1994 integer leaf(256),a(ncmax),hi(ncmax),lo(ncmax),pstack(20)
1995 DOUBLE PRECISION z(d),xi(ncmax)
1996
1997 integer p,stackt
1998
1999 external ehg182
2000 c stacktop -> stackt
2001 c find leaf cells affected by $z$
2002 stackt=0
2003 p=1
2004 nleaf=0
2005 c top of while loop
2006 3 if(.not.(0.lt.p))goto 4
2007 if(a(p).eq.0)then
2008 c leaf
2009 nleaf=nleaf+1
2010 leaf(nleaf)=p
2011 c Pop
2012 if(stackt.ge.1)then
2013 p=pstack(stackt)
2014 else
2015 p=0
2016 end if
2017 stackt=max(0,stackt-1)
2018 else
2019 if(z(a(p)).eq.xi(p))then
2020 c Push
2021 stackt=stackt+1
2022 if(.not.(stackt.le.20))then
2023 call ehg182(187)
2024 end if
2025 pstack(stackt)=hi(p)
2026 p=lo(p)
2027 else
2028 if(z(a(p)).le.xi(p))then
2029 p=lo(p)
2030 else
2031 p=hi(p)
2032 end if
2033 end if
2034 end if
2035 goto 3
2036 c bottom of while loop
2037 4 if(.not.(nleaf.le.256))then
2038 call ehg182(185)
2039 end if
2040 return
2041 end
2042
2043 C-- For Error messaging, call the "a" routines at the bottom of ./loessc.c :
2044 subroutine ehg183(s, i, n, inc)
2045 character s*(*)
2046 integer i, n, inc
2047 call ehg183a(s, len(s), i, n, inc)
2048 end
2049
2050 subroutine ehg184(s, x, n, inc)
2051 character s*(*)
2052 double precision x
2053 integer n, inc
2054 call ehg184a(s, len(s), x, n, inc)
2055 end