unit1.pas

来自「1、说明: 本书中所有的常用数值算法子过程按书中的章数分别放在以C开头」· PAS 代码 · 共 75 行

PAS
75
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ISET:^integer; GSET:^real;
implementation
//PROGRAM D7R1
//Driver for routine FIT
uses
  unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
const
  s1='%9.6f';
  NPT = 100; SPREAD = 0.5;  
var
    X,Y,SIG:array[0..100] of real;
    F:TextFile;
    I,NWT,MWT:integer; A,B,SIGA,SIGB,CHI2,Q:real;
begin
  New(ISET); New(GSET);
  Iset^:=0; GSET^:=0;
  Randomize;
  For I:=1 To NPT do
  begin
    X[I]:=0.1 * I;
        Y[I]:=-2 * X[I] + 1 + SPREAD * GASDEV;
        SIG[I]:=SPREAD;
  end;
  //输出计算结果到文件
  AssignFile(F, 'd:\delphi_shu\p7\d7r1.dat');
  Rewrite(F);
  Writeln(F);
  For MWT:=0 To 1 do
  begin
    FIT(X, Y, NPT, SIG, MWT, A, B, SIGA, SIGB, CHI2, Q);
    If MWT = 0 Then
    begin
      Writeln(F, 'Ignoring standard deviation ');
      Writeln(F);
    end
    Else
    begin
      Writeln(F);
      Writeln(F, '   Including standard deviation ');
      Writeln(F);
    end;
    Writeln(F,'   A:=',Format(s1,[A]),'    Uncertainty:', Format(S1,[SIGA]));
    Writeln(F,'   B:=',Format(S1,[B]),'    Uncertainty:', Format(S1,[SIGB]));
    Writeln(F, '   Chi-squared:  ', Format(S1,[CHI2]));
    Writeln(F, '   Goodness-of-fit:  ', Format(S1,[Q]));
  end;
  CloseFile(F);
  //屏幕显示计算结果
  memo1.Lines.LoadFromFile('d:\delphi_shu\p7\d7r1.dat');
end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?