Вы находитесь на странице: 1из 3
& HOUSEHDLDER'S ALGORITHM ©.5 5 & To obtain a symmetric tridiagonal matrix A(n-1) similar & to the symmerac matrix A= All), construct the Zollewing & matrices A(2),A(3),++,A(nel) where AH) ~ A(z, J}7*E, for Beach = 1,2, ne * S INEUT; Dimension ny matrix A. ® & OUTPUT: A{a-1) (At each step, A can be overwritten.) eyms(1OK", TAR", NAME", TINP', TNT, TL", J" vee syms(4Q", TKR, "8" RSQ", Ti, TU, TEROD',| 82725 eyms("L'; ' FLAG", "CUE"; mbuR = 1; FALSE ~ 0s {printf (1, "This 1s the Householder Methed.\n"); ok = FALSE) fprint£(1, "the symmetric array A will be input from a tent file\a’); fprintf(1, tin the c nt)? fpeante (1 ACL 2), AUL2), AML 3), very AGM, Natl; fpeinef(1,* AID 2b, A231, Ly Arm sats spesace (1 AU33)) ety ALBym), Ant] fprinté(1.* f Rinin)\aint): TpEINtT (1, "Place as many entries as desired on each line, but separate rice with\n") Syms (OK, “AAT, NAME", TINE*, Lu smus('o", TKK", "Ss", 25g", "Vi, Ut, "PROD", *2" syms("L"; "FLAG", *292")7 HUE = 1} FALSE ~ 04 fprintf(1, "This is che Householder Method. \n") OK = The symmetric exrey A will be input fan @ tent filelat|y s\n) A(L,2, AlL2), Alb), Rid3), A203), AC 3), Aah atls Bi2rndy aly RUZ ny, ia fprintf(1, ‘Has the input file been created? ~ enter ¥ or N.\n'); AB = ieputl" GEAR w= "YAR == ty* fprine{(1,'inpu> che Cile nate in the form ~ drivername.ext)n'); qprantt (1, ‘for exemple: ASTATA.DTA\A'| 7 NAME = Lnput |" "ts" INP = fopen(WAME,"E¢") OK ~ FALSE, while OF ~~ FALSE Spesect 1," che dimension mein!) N= input f(1,'at least one blank. \n\n\n"); rintf(1,'Has the input file boon created? - enter ¥ or N.\n')7 AA = input(" ','s"); Lt AA = "TAA Epeint£(1,'Input the file name in the form ~ drives fprintt(1,'for exampl ALDATA.DTA\n")+ MAME = input(' *, 3"); INP = fopen(NAME, rt"); OK = FALSE: while OK =~ FALSE Antf(1, "Input the dimension n.\n")i N= input(' ")+ ifN > 1 A= zeros(N,N)s = zeros(L,NIi persa (LN) = zeros(L,N)+ or - 1:6 ed=IiN A(LjJ) = fscanf (INP, "SE", 117 A(T) = AIL a)e end; end; name-ext\n") 7 3 v STEP 12 AIK.) » sTEP 13 for J > KN RiKe3) = OF AG.®) RiopB) = OF » STEP 14 AK+L,R) = AUREL, K)-VORHL) ZUR) AK, Kel) = AUK, X & STEP 15 sprint? (1, "Choice of ousput method: \n"hy ipranti(1,"1. Gutput to screenin'); fprant#(1,"2. Output to cext file\nt rprantt (1, "Please enter 1 or 2.1n"); FLAG = input(" *) Lf FLAG == 2 Sprint (1, "Input the file name in the form ~ drive:name.ext\n")s fprinti(1,*for oxample — R:OUTPUT.DTA\n") MAME = impuc(* °,°3")7 of outpat method: \n'); ur to screen\n"); ut to text file\n"); eater Lor Qin! £(1,'2. Oury '£(1, "Pleas FLAG = input(' ") if FLAG == 2 {printi(1,'Input the file name in the form - drive Epeintf(1,'for example — A:OUTPUT.DTA\n') ¢ pame.ext\n") 7 NAME = input (? t,'5"); OUP ~ fopen(NAME, "we"}; oR ~ ends Epeintt (OUP, ‘HOUSEHOLDER MBTHOD\n\n"); fprintf(oue, ‘The similar tridiagonal m rowo\n\s") forl-1:N for J- 1: ix follows - output by Eprincf(OuP, ' B1L.8f", AIT, I); endy Eprintt(oue, ‘\nin'|s end; Af OUP == 1 Eclose (OUP) Epeintf(1,'Ourput file $s created successfully \n',NAME); ends end;

Вам также может понравиться