1
C @(#)funct2i.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 FUNC2I(NRPRM,PRM,FCT,GRD,PIXEL,WEIGHT,IDIM1,IDIM2,
31
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40
C Function to compute the sum of residuals and the gradient.
44
C Approximating Function.
53
C CALL LSFUN2(NRPRM,PRM,FCT,GRD
54
C + PIXEL,WEIGHT,IDIM1,IDIM2,IDIM3)
57
C NRPRM INTEGER Number of parameters
58
C PRM (NRPRM) DOUBLE Parameters
59
C PIXEL (IDIM_) REAL pixel values of the image
60
C WEIGHT (IDIM_) REAL weighting factors
61
C IDIM_ INTEGER dimension of the 3-dim image.
67
C FCT DOUBLE Sum of residuals
68
C GRD (NRPRM) DOUBLE Gradient
77
C Ph. DEFERT, Feb 1986
82
C-----------------------------------------------------------------------
85
C .. Scalar Arguments ..
86
INTEGER NRPRM,IDIM1,IDIM2,IDIM3
89
C .. Array Arguments ..
90
DOUBLE PRECISION PRM(NRPRM),GRD(NRPRM)
91
REAL PIXEL(IDIM1,IDIM2,IDIM3),WEIGHT(IDIM1,IDIM2,IDIM3)
93
C .. Scalars in Common ..
97
C .. Arrays in Common ..
100
C .. Local Scalars ..
101
DOUBLE PRECISION W,Y,Y1,YOUT,YY
102
INTEGER IFUN,K,BEGFCT,I1,I2,I3,IP
107
C .. Common blocks ..
109
C .. External Files ..
110
INCLUDE 'MID_INCLUDE:FITNAGI.INC/NOLIST'
111
DOUBLE PRECISION PARDER(MAXPAR)
112
INCLUDE 'MID_INCLUDE:FITNAGC.INC/NOLIST'
113
COMMON /LSQFUN/ICOL,NRCOL,ISTAR,WGTTYP
115
C .. Executable Statements ..
117
C Deal with simple linear constraints
122
PRM(K) = PRM(IP)*PRPFAC(K)
129
C Go through the image
142
IF (WGTTYP(1:1).EQ.'C') THEN
145
ELSE IF (WGTTYP(1:1).EQ.'W') THEN
148
ELSE IF (WGTTYP(1:1).EQ.'S') THEN
150
IF (YY.LT.1.E-12) THEN
157
ELSE IF (WGTTYP(1:1).EQ.'I') THEN
158
W = 1./WEIGHT(I1,I2,I3)**2
161
C Compute fitting values
166
CALL FTFUNC(FCTCOD(IFUN),NRIND,X,ACTPAR(IFUN),
167
+ PRM(BEGFCT),YOUT,PARDER(BEGFCT))
169
BEGFCT = BEGFCT + ACTPAR(IFUN)
171
FCT = FCT + W* (Y1-Y)**2
175
GRD(K) = GRD(K) + 2.D0*W*PARDER(K)* (Y1-Y)
178
GRD(IP) = GRD(IP) + 2.D0*W*PARDER(K)* (Y1-Y)/
183
X(1) = X(1) + STEP(1)
185
X(2) = X(2) + STEP(2)
187
X(3) = X(3) + STEP(3)