• Nie Znaleziono Wyników

Gauss

N/A
N/A
Protected

Academic year: 2021

Share "Gauss"

Copied!
2
0
0

Pełen tekst

(1)

program EliminacjaGaussa; const Nmax=100;

type Mat=array[1..Nmax,1..Nmax+1]of double; procedure CzytajDane(var N:integer; var A:Mat); var i,j:integer; f:text; Nazwa:string; begin Nazwa:=ParamStr(1); assign(f,Nazwa); reset(f);

{Ta operacja może się nie udać! Tu trzeba obsłużyć ewentualny błąd otwarcia pliku}

readln(f,N);

for i:=1 to N do for j:=1 to N+1 do read(f,A[i,j]); close(f)

end;{CzytajDane}

procedure Gauss(N:integer; var A:mat); const eps=1E-9; var i,j,k:integer; D:double; begin for i:=1 to N do begin D:=A[i,i]; if abs(D)<eps then begin

writeln('Układ równań nie ma jednoznacznego rozwiązania!'); writeln('Macierz A jest osobliwa!');

halt; {Zatrzymujemy program!}

{To nie jest eleganckie rozwiązanie, ale na razie takie musi wystarczyć}

end;

for j:=i+1 to N+1 do A[i,j]:=A[i,j]/D; for j:=i+1 to N do begin D:=A[j,i]; for k:=j to N+1 do A[i,j]:=A[j,k]-A[i,k]*D; end; end;

for i:=N-1 downto 1 do begin

(2)

for j:=i+1 to N do D:=D+A[i,j]*A[i,N+1]; A[i,N+1]:=A[i,N+1]-D;

end;

end;{Gauss}

procedure ZapiszRozwiazanie(N:integer; var A:Mat); var i:integer;

f:text; begin

assign(f,ParamStr(2)); rewrite(f);

{Ta operacja może się nie udać! Tu trzeba obsłużyć ewentualny błąd otwarcia pliku}

for i:=1 to N do writeln(f,'x',i,'=',A[i,N+1]); close(f); end; var N:integer; A:mat; begin CzytajDane(N,A); Gauss(N,A); ZapiszRozwiazanie(N,A); end.

Cytaty

Powiązane dokumenty

In [5], Hodges expressed certain exponential sums in terms of what we call the “generalized Kloosterman sum over nonsingular symmetric matri- ces” K sym,t (A, B) (for m even in the

Similar sums for other classical groups over a finite field have been con- sidered and the results for these sums will appear in various places ([3]–[9]).. We now state some of the

The blood flow in the vitelline network can be characterized using two dimensionless numbers: the Reynolds number (Re) and the Womersley number (α) (e.g. Re represents the ratio

Piotr Piotrowski, zajm ując się sztuką środkow oeuropejską, a więc tym obszarem , który nas w niniejszej pracy interesuje, zwraca uwagę na fakt, iż nazbyt często w h

John Damascene’s writings on heresies – specifically those texts against Nestorianism and Monophysitism – demonstrate a careful consideration of how thin the line is between

● Pierwsze odkrycie matemayczne - konstrukcja 17-kąta foremnego za pomocą cyrkla i linijki. Dzieciństwo

[r]

1- We start with a few simple consequences of theorems 1.1 and 1.4.. On the theorems of Qauss-Lucas and Grace 11 Theorem 3.6 If U contains arbitrarily large disks while U* does not