{Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730} procedure MatGen ( var a : MATRIX ; lda, n : integer ) ; { } { PROGRAM: MATGEN } { } { VERSION: 1.0/TURBO DATE: 04/21/86 } { } { DESCRIPTION: } { } { Generate a test matrix with Hilbert } { coefficients. The matrix is symmetric and } { poorly conditioned. } { } { AUTHOR: } { } { Adam Fritz } { 133 Main Street } { Afton, New York 13730 } { } var i, j, nm1, ip1 : integer ; t : real ; begin { Validate Leading Dimension } if lda > 0 then begin { Validate Order } if (n > 1) and (n <= lda) then begin { Form Matrix and Vector } nm1 := n - 1 ; if n > 1 then begin for i := 1 to nm1 do begin a[i,i] := 1.0/(2*i-1) ; ip1 := i + 1 ; for j := ip1 to n do begin t := 1.0/(i+j-1) ; a[i,j] := t ; a[j,i] := t end end end ; t := 1.0/(2*n-1) ; a[n,n] := t end else begin writeln('Error: Invalid MATRIX Order, ', n,'.') ; BIOS(0) end end else begin writeln('Error: Invalid LEADING DIMENSION, ', lda) ; BIOS(0) end end ; {Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730}