CE 311K Lab9 Pt1

# CE 311K Lab9 Pt1 - CE311K Introduction to Computer Methods...

This preview shows pages 1–3. Sign up to view the full content.

Sheet1 Page 1 ! CE311K Introduction to Computer Methods ! Lab9 - Systems of Linear Equations Program lab9 ! Declaration of Variables real a(50,50), b(50), x(50) integer n, i, j real er, tol ! Open I/O files Input file called input.txt, output file out.dat Open(unit=5, file='input.txt',status='old') Open(unit=6, file='out.dat', status='unknown') ! Initialization of the Matrix ! Read(5,*) n ! Reads the number of equations to solve ! Loop to store matrix of coefficients in a, and array of constants in b Do i=1,n read (5,*) (a(i,j), j=1,n), b(i) x(i)=0 Enddo print *, 'Input Matrix: ' write (6,*) 'Input Matrix' call printer(a, n, b, j) !Calls function that prints system of equations !a Matrix of coefficients of nxj !b Array of constants of nx1 ! er: error code, tol: tolerable number ! +initialize er at zero er=0 ! +set tolerance error as 1E-8 tol=1e-8 call Gauss(a, b, n, x, tol, er) ! +Write solutions to a file remember solutions are in the array x call printsol(n, j, x) End program lab9 ! Subroutine dealing with Gauss Elimination

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sheet1 Page 2 !a is matrix of coefficients !b is free vector !n is number of equations (dimensions of matrix a)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern