🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.listserv.graph-ti
Article #30

(no subject given)

#30
From: Stephane Jantzen
Date: Mon, 21 Nov 1994 11:48
182 lines
4148 bytes
Hi

Here is the program for solving linear system, displaying all the steps.
As you'll see, it has been written using a "readable" way:It could be optimi-
zed, but as I'm still working on it ...
Some of the functions have not been implemented yet : Gauss Seidel and Jacobi
iterative methods.
In the last label part you'll find a lot of loops such as:

For(P,3,4)
...
End
For(P,3,4)
...
End

Don't trash them in one loop ! Job must be done sequentially, so it wouldn't
work.
Please e-mail me all comments, corrections or ideas !

-------------------------------------------------------------------------------
Stephane 'Peekaboo' Jantzen - stephane.jantzen@scinfo.u-nancy.fr
Ecole Superieure d'Informatique et d'Applications de Lorraine (E.S.I.A.L.)

	"Without the pain there'd be no learning	            _O_
	 Without the hurting we'd never change"	 -  Kate Bush        |<
-------------------------------------------------------------------------------



PROGRAM:Vect   /*  This program displays a vector. */

ClLCD
Disp "Vector"
Disp ""
For(I,1,4
Disp V(I)->Frac
End
Pause

PROGRAM:Mat    /*  This program displays a matrix */

For(I,1,4
ClLCD
Disp "Column"
Disp ""
Outpt(1,9,I
For(J,1,4
Disp A(J,I)->Frac
End:Pause:End

PROGRAM:Solve   /*  This is the main program */

A->B:V->W
ident 4->X
Lbl DE
ClLCD:X->Y
ident 4->X
Menu(1,"gauss",G,2,"jordan",J,3,"max p.",H,4,"inv(A)",V,5,"next",B
Lbl B
Menu(1,"A=LU",L,2,"choleski",C,3,"jacobi",E,4,"Seidel",F,5,"prev.",DE
Lbl H
For(P,1,4:P->MX
For(P,Q+1,4
If abs (A(Q,P))>abs (A(P,P)):Q->MX
End
ClLCD
Disp "Maximum in line : "
Outpt(1,19,MX
Pause
rSwap(A,P,MX)->A
V(P)->U:V(MX)->V(P):U->V(MX)
V(P)/A(P,P)->V(P)
multR(-1/A(P,P),A,P)->A
For(Q,1,4)
If Q==P:Q+1->Q
If Q>4:Goto Y
V(Q)-A(Q,P)V(P)->V(Q)
mRAdd(A(Q,P),A,P,Q)->A
Lbl Y:End
MultR(-1,A,P)->A
Mat
Vect
End
Goto DE
Lbl C
Fill(0,X)
square root(A(1,1))->X(1,1)
For(I,2,4)
A(I,1)/X(1,1)->X(I,1)
End
For(I,2,4)
square root(A(I,I)-sum seq(X(I,K)^2,K,1,I-1,1))->X(I,1)
End
(A(3,2)-X(3,1)X(2,1))/X(2,2)->X(3,2)
(A(4,2)-X(4,1)X(2,1))/X(2,2)->X(4,2)
(A(4,3)-X(4,1)X(3,1)-X(4,2)X(3,2))->X(4,3)
Goto DE
Lbl G
For(P,1,4)
V(P)/A(P,P)->V(P)
multR(-1/A(P,P),A,P)->A
For(Q,P+1,4)
V(Q)-A(Q,P)V(P)->V(Q)
mRAdd(A(Q,P),A,P,Q)->A
End
MultR(-1,A,P)->A
Mat
Vect
End
Goto DE
Lbl J
For(P,1,4)
V(P)/A(P,P)->V(P)
multR(-1/A(P,P),A,P)->A
For(Q,1,4)
If Q==P:Q+1->Q
If Q>4:Goto Z
V(Q)-A(Q,P)V(P)->V(Q)
mRadd(A(Q,P),A,P,Q)->A
Lbl Z
End
mult(-1,A,P)->A
Mat
Vect
End
Goto DE
Lbl V
For(P,1,4)
MultR(1/A(P,P),X,P)->X
multR(1/A(P,P),A,P)->A
For(Q,1,4)
If Q==P:Q+1->Q
If Q>4:Goto K
mRAdd(-A(Q,P),X,P,Q)->X
mRAdd(-A(Q,P),A,P,Q)->A
Lbl K
End
MultR(1,A,P)->A
ClLCD
Disp "Matrix A"
Pause
Mat
A->C:X->A
ClLCD
Disp "Matrix S"
Pause
Mat
C->A
End
Goto DE
Lbl L
ident 4->L
{4,4}->dim U
Fill(0,U)
A(1,1)->U(1,1)
For(P,1,4)
A(P,1)/A(1,1)->L(P,1)
A(1,P)->U(1,P)
End
For(P,2,4)
A(2,P)-L(2,1)U(1,P)->U(2,P)
End
For(P,3,4)
(A(P,2)-L(P,1)U(1,2))/U(2,2)->L(P,2)
End
For(P,3,4)
A(3,P)-L(3,1)U(1,P)-L(3,2)U(2,P)->U(3,P)
End
For(P,3,4)
(A(4,P)-L(4,1)U(1,P)-L(4,2)U(2,P))/U(P,3)->L(4,P)
End
ClLCD
Disp "Matrix L"
Pause
L->A
Mat
ClLCD
Disp "Matrix U"
Pause
U->A
Goto DE
Technical Details
Message-ID: <199411211148.MAA16344@castor.scinfo.u-nancy.fr>
Path: arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!psuvax1!uwm.edu!news.moneng.mei.com!sol.ctr.columbia.edu!newsxfer.itd.umich.edu!europa.eng.gtefsd.com!paladin.american.edu!auvm!scinfo.u-nancy.fr!Stephane.Jantzen

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 104512,56f24180c3f10f53
X-Google-Attributes: gid104512,public
X-Google-ArrivalTime: 1994-11-21 05:20:15 PST
Path: arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!psuvax1!uwm.edu!news.moneng.mei.com!sol.ctr.columbia.edu!newsxfer.itd.umich.edu!europa.eng.gtefsd.com!paladin.american.edu!auvm!scinfo.u-nancy.fr!Stephane.Jantzen
Subject: (no subject given)
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
Newsgroups: bit.listserv.graph-ti
Date: Mon, 21 Nov 1994 12:48:18 +0100
From: Stephane Jantzen <Stephane.Jantzen@scinfo.u-nancy.fr>
Message-ID: <199411211148.MAA16344@castor.scinfo.u-nancy.fr>
Apparently-To: graph-TI@ds0.internic.net
Sender: owner-graph-ti@dsmail.internic.net
Precedence: bulk
Reply-To: Stephane Jantzen <Stephane.Jantzen@scinfo.u-nancy.fr>
Lines: 183