Homework 12, LU Decomposition

(15 points)

This homework leads you through a normal pattern of work, when using someone else's subroutines. Your objective is to obtain and test 2 Linpack subroutines from Netlib. To be certain that the linear algebra subroutines function correctly, and more importantly that you understand all of the arguments, you must test them with a simple program to obtain a known solution to set of linear equations.

Begin by obtaining the file lin1.f, then get sgefa.f, sgesl.f, and all other subroutines and functions used by sgefa.f and sgesl.f from the "linpack" subdirectory Netlib.. Add the contents of the files sgefa.f and sgesl.f to the end of the file lin1.f to produce a single program file named "lin1.f". I recommend that you do this by placing the cursor in vi at the end of the file and while in command mode, type the string

:r sgefa.f

move the cursor to the bottom of the file again and type

:r sgesl.f

Run one test to be certain that the basic program works. Compare your output to my file lin1.out using the Unix utility "diff". This comparison can be done by first routing the output of your program to another file (say "my.out"), then making the comparison with diff. Type the following two lines:

a.out > my.out
diff my.out lin1.out
If things worked properly "diff" will send no output to your screen. If not, it will print differences between the file "lin1.out" that I generated, and the file "my.out" that you generated.

When you have the right answers, modify lin1.f so that it requests the number of equations from the program's user (store this in a variable named "n" or "neq") and allocates any needed array space based on this number of equations. Be sure to make the necessary changes so that the program functions with this variable "neq" rather than the hardwired 6 equations and unknowns. However, to make our lives easier grading this, don't change the FORMAT statements. Check the output from your program for 4, 6, and 10 equations. In each case the last line(s) of numbers (after "Ax =") should match the first printed line(s) of numbers that follow the caption " Right Hand Side of the linear equation Ax=b".

Leave the resulting program in your homework directory as the file "lin1.f".

Homework List / Home

Maintained by John Mahaffy : jhm@psu.edu