% Script to test forward-substitution.m for
% solving a lower triangular system by forward-substitution
% Input matrix L is an n by n lower triangular matrix
% Input vector b is n by 1
% Input scalar n specifies the dimensions of the arrays
% Output vector x is the solution to the linear system
% L x = b
% K. Ming Leung, 01/25/03

clear all;
L=[ 1  0  0
    2 -4  0
    2 -6 -1];
b=[3; -6; 1];

n=4500; L = rand(n,n); b = rand(n,1);
n=length(b); 
%
loopMax = 1;
% Row processing takes a little longer in MATLAB
tic;
for loop = 1:loopMax
xR = forwardSubstitutionR(L,b,n); end; toc;  

tic;
for loop = 1:loopMax
xC = forwardSubstitutionC(L,b,n); end; toc; 

error = max(abs(xR-xC)),