*-- Author : I.O. Skillicorn SUBROUTINE FTLFT(XS,YS,L,KEY,AS,BS,ES) DIMENSION XS(100),YS(100) DOUBLE PRECISION X(100), Y(100) DOUBLE PRECISION A, B, E DOUBLE PRECISION SUMX, SUMY, SUMXY, SUMXX, SUMYY, COUNT DOUBLE PRECISION XMED, YMED, SCARTX, SCARTY IF(L-2)25,1,1 1 COUNT=0.0D0 SUMX=0.0D0 SUMY=0.0D0 SUMXY=0.0D0 SUMXX=0.0D0 SUMYY=0.0D0 DO10 J=1,L X(J) = DBLE(XS(J)) Y(J) = DBLE(YS(J)) IF(Y(J).EQ.0.0D0.AND.KEY.EQ.0)GOTO10 SUMX=SUMX+X(J) SUMY=SUMY+Y(J) COUNT=COUNT+1.0D0 10 CONTINUE IF(COUNT.LE.1.0D0)GOTO25 YMED=SUMY/COUNT XMED=SUMX/COUNT DO 20 J=1,L IF(Y(J).EQ.0.0D0.AND.KEY.EQ.0)GOTO20 SCARTX=X(J)-XMED SCARTY=Y(J)-YMED SUMXY=SUMXY+SCARTX*SCARTY SUMXX=SUMXX+SCARTX*SCARTX SUMYY=SUMYY+SCARTY*SCARTY 20 CONTINUE IF(SUMXX.EQ.0.0D0)GOTO25 A=SUMXY/SUMXX B=YMED-A*XMED IF(COUNT.LT.3.0D0)GOTO101 E=(SUMYY-SUMXY*A)/(COUNT-2.0D0) GOTO100 25 A=0.0D0 B=0.0D0 101 E=0.0D0 100 CONTINUE AS = A BS = B ES = E RETURN END * * * *