home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
DELPX02.ZIP
/
NVSEARCH.INC
< prev
next >
Wrap
Text File
|
1991-05-16
|
2KB
|
71 lines
function min_function(plot : Boolean; var point : TSearchArray) : mysingle;
var F : mysingle;
data : integer;
A1,A2,A3,A4,A5,x1,x2,x3,x4,x5 : mysingle;
i : integer;
s2 : Myreal;
x,y : integer;
scale : Mysingle;
inc : mysingle; { decay rate of weighting exponential }
{$I equ.inc}{function Fn(i)}
begin
A1 := point[1];
A2 := point[3];
A3 := point[5];
A4 := point[7];
A5 := point[9];
x1 := point[2];
x2 := point[4];
x3 := point[6];
x4 := point[8];
x5 := point[10];
s2 := 0;
scale := 32768/(FullScale - ZeroScale);
inc := searchweight/(endFit1-startFit1);
IF CHECK THEN BEGIN
FOR I := 1 TO NUMVAR DO WRITE('PNT[',I,']:',POINT[I]:8,' ');
END
ELSE
i := startFit1;
if searchweight<>0 then begin
repeat
F := (Fn(i-StartFit1) - ZeroScale)*Yscale;
s2 := s2 + sqr(F-buffer1^[i])*exp((i-StartFit1)*inc);
i := i + round(SkipPoints*exp(-(i-StartFit1)*inc));
until i>EndFit1;
end;
if searchweight=0 then begin
s2 := 0;
repeat
F := (Fn(i - StartFit1) - ZeroScale)*scale;
s2 := s2 + sqr(F-buffer1^[i]);
i := i + SkipPoints;
until i>EndFit1;
end;
plot := false;
if (iter mod 11 = 0) then
if ((s2<=minstore) or plot) then begin
for i := StartFit1 to EndFit1 do begin
F := (Fn(i - StartFit1) - ZeroScale)*scale;
if F > 32767 then F := 32767;
if F < -32766 then F := -32766;
buffer2^[i] := round(F);
end;
IF NOT CHECK THEN
plotdata(buffer2,2);
end;
min_function := s2;
IF CHECK THEN WRITE('S2:',S2:6,#13,#10);
end;{ of function min_function----------------------------------------------}
{---------------------------------------------------------------------------}
{---------------------------------------------------------------------------}