% Test Script P3
% Checks out BlkTriSol
randn('seed',0);
clc
p = 100; r = 10; n = p*r;
A = cell(p,1); C = cell(p-1,1); D = cell(p-1,1);
for k=1:p
    A{k} = randn(r,r);
    if k<p
        C{k} = randn(r,r); D{k} = randn(r,r);
    end
end
b = randn(n,1);
x = BlkTriSolve(A,C,D,b);
% Form explicit T 
T = zeros(n,n);
for k=1:p
    rows = 1+(k-1)*r:k*r;
    T(rows,rows) = A{k};
    if k<p
        T(r+rows,rows) = C{k}; T(rows,r+rows) = D{k};
    end
end
err = norm(x-T\b)


 