Open in the MATLAB editor: f04lh_example
function f04lh_example fprintf('f04lh example results\n\n'); % Block structure of A n = int64(18); blkstr = [int64(2),4,5,3,4; 4, 7,8,6,5; 3, 4,2,3,0]; a1 = [-1.00 -0.98 -0.79 -0.15; -1.00 0.25 -0.87 0.35]; a2 = [ 0.78 0.31 -0.85 0.89 -0.69 -0.98 -0.76; -0.82 0.12 -0.01 0.75 0.32 -1.00 -0.53; -0.83 -0.98 -0.58 0.04 0.87 0.38 -1.00; -0.21 -0.93 -0.84 0.37 -0.94 -0.96 -1.00]; a3 = [-0.99 -0.91 -0.28 0.90 0.78 -0.93 -0.76 0.48; -0.87 -0.14 -1.00 -0.59 -0.99 0.21 -0.73 -0.48; -0.93 -0.91 0.10 -0.89 -0.68 -0.09 -0.58 -0.21; 0.85 -0.39 0.79 -0.71 0.39 -0.99 -0.12 -0.75; 0.17 -1.37 1.29 -1.59 1.10 -1.63 -1.01 -0.27]; a4 = [ 0.08 0.61 0.54 -0.41 0.16 -0.46; -0.67 0.56 -0.99 0.16 -0.16 0.98; -0.24 -0.41 0.40 -0.93 0.70 0.43]; a5 = [ 0.71 -0.97 -0.60 -0.30 0.18; -0.47 -0.98 -0.73 0.07 0.04; -0.25 -0.92 -0.52 -0.46 -0.58; 0.89 -0.94 -0.54 -1.00 -0.36]; % Flatten A a = [reshape(a1,[ 8,1]); reshape(a2,[28,1]); reshape(a3,[40,1]); reshape(a4,[18,1]); reshape(a5,[20,1])]; % Right hand side b = [-2.92; -1.27; -1.30; -1.17; -2.10; -4.51; -1.71; -4.59; -4.19; -0.93; -3.31; 0.52; -0.12; -0.05; -0.98; -2.07; -2.73; -1.95]; % Factorize A tol = 0; [AF, pivot, tol, index, ifail] = ... f01lh(n, blkstr, a, tol); % Solve system trans = 'N'; [x, ifail] = f04lh( ... trans, blkstr, AF, pivot, b); disp('Component solution'); disp(x);
f04lh example results Component solution 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000