astep -c c418 -p l1 file1 file2 ...

- Write a function [M,L] = elimMat(A,k) which given matrix A, index k computes the elimination matrix M and L as specified on page 67
- Write an myLU function which combines M1'M2' ... M2 M1 A into L and U
- Do a backSubst function. (a fwdSubst function is provided below as an example)
- Show how to use your programs to solve Ax=b by method of (p. 68)
- Factorization: L U = A
- fwdSubst to solve for y in: Ly=b
- backSubst to solve for x in: Ux = y

- Test your program with e.g. example 2.13 and one test of your own design. Write a m-file script to execute the text and comment on what's happening in each step.

% fwdSubst Forward substitution to solve Ly=b by tail recursion % cmput 340, 2004 function y = fwdSubst(L,b,k) [m,n]=size(L); if ~exist('k') % If first call no k param given, but k=1 k=1; end y=b(k)/L(k,k) if k < n % Recursion step l = [zeros(k,1);L(k+1:m,k)] y = [y;fwdSubst(L,b-y*l,k+1)] end

Newsgroups: ualberta.courses.cmput.340 Subject: Re: L1 myLu(...) References:--text follows this line-- Paul Cartledge writes: > If I could get some clarification on the myLU(...) function, that would be > great. > > I believe it is wrong to assume that we will only be getting 3x3 matrices > for this lab, so I am wondering how we are to send in parameters to > myLU(). Obvioulsy your function should not just handle 3x3 matrices. Look back to the reading list for lab 1, and make sure you have read and understood the parts of the Matlab tutorial that was covered. In particular, ch 3 has the answer for how to extract properties (such as size) from a passed in matrix. Especially pay attention to table 4. Then take a look at the sample fwdSubst function supplied and see how parameters are used. > > If there's a varying number of matrices to be sent in, is there a Why would you like to pass in a varying number of matrices? > way to store the intermediate matrices we need for computation obtained > from elimMat() so that we can send them into myLU(). If you use recursion you have the benefit of a new set of intermediate variables at each call. Again study the tutorial, then the sample routine. /Martin ---------------------------------------- Newsgroups: ualberta.courses.cmput.340 Subject: Re: Leading Diag Entries of Unreduced Portions being Zero References: --text follows this line-- Don Rivers writes: > The textbook talks about the possibility of there being a leading zero in > a part we've yet to reduce. Is there an elegant way for us to interchange > rows, 1. Yes, this is essentially the same as piviting 2. You are not required to implement this in the lab, but in preparation for the lab test you should be aware of the issue from your readings (as you obvioulsy are) so you can answer oral questions. > or will all of the matrices that we will be tested on not have > leading zeros in parts that we are working on? On a test matrix with a leading 0 you will have to point out why your code doesn't handle it, identify the problem, and the particular place in the code. /Martin ------------------------------------ Newsgroups: ualberta.courses.cmput.340 Subject: Re: NxN, or MxN? References: --text follows this line-- Don Rivers writes: > I don't know if this has been answered, but are only going to be tested on > Square Matrices, or on nonSquares as well? Not required to handle non-square matrices. > > I notice that matlab's lu() complains if you pass it a nonsquare matrix, > so do we have a similar requirement? Actually, it is possible to compute an L U factorization through elimination even for an mxn matrix. It is just not implemented in matlab 5 (but was fixed in matlab 6). /Martin