C****************************************************************
C* 								*
C*								*
C*	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY *
C*	EITHER FOR THE CREATION OR FOR THE CLINICAL EFFICACY	*
C*	OF THIS PROGRAM. USERS MUST ASSUME FULL RESPONSIBILITY	*
C*	FOR ANY RESULTS OR DIAGNOSES OBTAINED FROM THE USE	*
C*	OF THIS PROGRAM. QUESTIONS ON THE EXECUTION OF THIS	*
C*	PROGRAM MUST BE REFERRED BACK TO THE ORIGINAL AUTHOR.	*
C*								*
C* AUTHOR:	SALLY FORSTER					*
C*		C/O DEPARTMENT OF NUCLEAR MEDICINE		*
C*		GUY'S HOSPITAL				*
C*		LONDON, ENGLAND					*
C*								*
C*		TEL: 01-407-7600 EXT 2583/4			*
C*								*
C****************************************************************
	FUNCTION EXPFIT(I,J)
	IMPLICIT INTEGER*2(D-Z)
	IMPLICIT LOGICAL*1(A)
	COMMON//SAVDES(256),CURVE1(512),CURVE2(512)
	COMMON/FIT/CFITPA(4)
	REAL*8 CRES
C*****Y=A*EXP(X*B)
C*****RETURNS A,B,THALF,RESID IN CFITPA
C*****LOG(Y)=LOG(A)+B*X
	EXPFIT=1
C*****SAVES Y-VALUES ON DISK
	IF(PCV(1,12).LT.0)GOTO 300
C*****TAKES LOGS OF Y
	CALL LOG
C*****PERFORMS LINEAR REGRESSION PUTTING FITTED CURVE
C*****INTO CURVE 1
	IF(LINREG(I,J).LT.0)GOTO 200
C*****EXPONENTIATE
	CALL FEXP
C*****FETCHES ORIGIONAL Y-VALUES FROM DISK TO CURVE2
	IF(GCV(2,12).LT.0)GOTO 300
	CX=CFITPA(1)
	CFITPA(1)=EXP(CFITPA(2))
	CFITPA(2)=CX
	CFITPA(3)=-ALOG(2.)/CX
C*****CALCULATES RESIDUAL SUM OF SQUARES
	CFITPA(4)=SNGL(CRES(CURVE2,I,J,CURVE1))
	RETURN
200	EXPFIT=0
	RETURN
300	EXPFIT=-1
	RETURN
	END
