--- a/src/library/stats/src/loessf.f
+++ b/src/library/stats/src/loessf.f
@@ -784,11 +784,26 @@
+ vval2(0:d,nvmax), lf(0:d,nvmax,nf)
integer lq(nvmax,nf),a(ncmax),c(vc,ncmax),lo(ncmax),hi(ncmax)
c Var
- integer lq1,i,i1,i2,j,p
+ integer i,i1,i2,j,p
+ integer, allocatable :: inv(:,:)
double precision zi(8)
double precision ehg128
external ehg128
+c Inverse neighbour positions; zero means that j is not a neighbour.
+c Ascending p preserves the original search's last-match semantics.
+ allocate(inv(nv,n))
+ do 20 j=1,n
+ do 21 i=1,nv
+ inv(i,j)=0
+ 21 continue
+ 20 continue
+ do 22 p=1,nf
+ do 23 i=1,nv
+ inv(i,lq(i,p))=p
+ 23 continue
+ 22 continue
+
do 3 j=1,n
do 4 i2=1,nv
do 5 i1=0,d
@@ -796,17 +811,8 @@
5 continue
4 continue
do 6 i=1,nv
-c linear search for i in Lq
- lq1=lq(i,1)
- lq(i,1)=j
- p=nf
-c top of while loop
- 7 if(.not.(lq(i,p).ne.j))goto 8
- p=p-1
- goto 7
-c bottom of while loop
- 8 lq(i,1)=lq1
- if(lq(i,p).eq.j)then
+ p=inv(i,j)
+ if(p.ne.0)then
do 9 i1=0,d
vval2(i1,i)=lf(i1,i,p)
9 continue
@@ -819,6 +825,7 @@
l(i,j)=ehg128(zi,d,ncmax,vc,a,xi,lo,hi,c,v,nvmax,vval2)
10 continue
3 continue
+ deallocate(inv)
return
end
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel