1
C @(#)funct2t.for 19.1 (ES0-DMD) 02/25/03 13:17:38
2
C===========================================================================
3
C Copyright (C) 1995 European Southern Observatory (ESO)
5
C This program is free software; you can redistribute it and/or
6
C modify it under the terms of the GNU General Public License as
7
C published by the Free Software Foundation; either version 2 of
8
C the License, or (at your option) any later version.
10
C This program is distributed in the hope that it will be useful,
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
C GNU General Public License for more details.
15
C You should have received a copy of the GNU General Public
16
C License along with this program; if not, write to the Free
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
21
C Internet e-mail: midas@eso.org
22
C Postal address: European Southern Observatory
23
C Data Management Division
24
C Karl-Schwarzschild-Strasse 2
25
C D 85748 Garching bei Muenchen
27
C===========================================================================
29
SUBROUTINE FUNC2T(NRPRM,PRM,FCT,GRD)
30
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39
C Function to compute the sum of residuals and the gradient.
43
C Approximating Function.
52
C CALL LSFUN2(NRPRM,PRM,FCT,GRD)
55
C NRPRM INTEGER Number of parameters
56
C PRM (NRPRM) DOUBLE Parameters
62
C FCT DOUBLE Sum of residuals
63
C GRD (NRPRM) DOUBLE Gradient
72
C Ph. DEFERT, Feb 1986
77
C-----------------------------------------------------------------------
80
C .. Scalar Arguments ..
84
C .. Array Arguments ..
85
DOUBLE PRECISION PRM(NRPRM),GRD(NRPRM)
87
C .. Scalars in Common ..
91
C .. Arrays in Common ..
95
DOUBLE PRECISION W,Y,Y1,YOUT,YY
96
INTEGER IDAT,IFUN,ISTAT,K,NC,NROW,NS,BEGFCT,IP
103
C .. External Files ..
104
INCLUDE 'MID_INCLUDE:FITNAGI.INC/NOLIST'
105
DOUBLE PRECISION PARDER(MAXPAR)
106
INCLUDE 'MID_INCLUDE:FITNAGC.INC/NOLIST'
108
C .. Common blocks ..
109
COMMON /LSQFUN/ICOL,NRCOL,ISTAR,WGTTYP
111
C .. Executable Statements ..
113
C Deal with simple linear constrains
118
PRM(K) = PRM(IP)*PRPFAC(K)
125
C Go through the table
127
CALL TBIGET(FZIDEN,NC,NROW,NS,NAC,NAR,ISTAT)
130
CALL TBSGET(FZIDEN,IDAT,ISEL,ISTAT)
131
IF ( .NOT. ISEL) GO TO 70
132
CALL TBRRDR(FZIDEN,IDAT,NRCOL,ICOL(ISTAR),XVAL(ISTAR),
136
VALID = VALID .AND. ( .NOT. NULL(K))
138
IF ( .NOT. VALID) GO TO 70
145
C Compute the weighting factors
147
IF (WGTTYP(1:1).NE.'W') THEN
148
IF (WGTTYP(1:1).EQ.'C') THEN
151
ELSE IF (WGTTYP(1:1).EQ.'S') THEN
153
IF (YY.LT.1.E-12) THEN
160
ELSE IF (WGTTYP(1:1).EQ.'I') THEN
167
C Compute the fitting values
172
CALL FTFUNC(FCTCOD(IFUN),NRIND,X,ACTPAR(IFUN),PRM(BEGFCT),
173
+ YOUT,PARDER(BEGFCT))
175
BEGFCT = BEGFCT + ACTPAR(IFUN)
178
FCT = FCT + W* (Y1-Y)**2
183
GRD(K) = GRD(K) + 2.D0*W*PARDER(K)* (Y1-Y)
186
GRD(IP) = GRD(IP) + 2.D0*W*PARDER(K)* (Y1-Y)/PRPFAC(K)