M.Sc. in High-Performance Computing 5613 - C programming Assignment 6 Rules

advertisement
M.Sc. in High-Performance Computing
5613 - C programming
Assignment 6
Mike Peardon (mjp@maths.tcd.ie)
School of Mathematics, TCD
Rules
To submit, make a single tar-ball with all your code and a pdf of any written part
you want to include. Submit this via msc.tchpc.tcd.ie by Monday December 7th.
Attempt all parts. Marks will be given for the efficiency of your implementation. Late
submissions without prior arrangement or a valid explanation will result in reduced
marks.
Question
Using your tridiagonal matrix structure from Assignment 4, write a C program to read
the elements of a tridiagonal matrix T from a text file and print x, the solution to the
linear system
T x = y,
where y is a vector whose first entry is 1 and all other entries are zero. The first line of
the text file should have a single integer indicating the size of the matrix. Subsequent
lines should contain the non-zero entries in each row. You can assume the matrix is
well-conditioned so there is no need for pivoting. As an example, a matrix is given
below, with its text equivalent;
Text-file format
Example matrix
4


1.2 −0.4
0
0
1.2 -0.4
 −0.5 1.4 −0.3

0
-0.5 1.4 -0.3

T =
 0
−0.4 1.1 −0.6 
-0.4 1.1 -0.6
0
0
−0.5 1.3
-0.5 1.3
Download