Open in the MATLAB editor: f08ak_example
function f08ak_example fprintf('f08ak example results\n\n'); a = [ -5.42 3.28 -3.68 0.27 2.06 0.46; -1.65 -3.40 -3.20 -1.03 -4.06 -0.01; -0.37 2.35 1.90 4.31 -1.76 1.13; -3.15 -0.11 1.99 -2.70 0.26 4.50]; m = int64(4); n = 6; nrhs = 2; % Compute the LQ Factorisation of A [lq, tau, info] = f08ah(a); % Solve L*Y = B b = [ -2.87 -5.23; 1.63 0.29; -3.52 4.76; 0.45 -8.41]; [y, info] = f07te(... 'Lower', 'Notrans', 'Non-unit', lq(1:m,1:m), b); % Add some zero rows to Y y(m+1:n,1:nrhs) = 0; % Compute minimum-norm solution X = (Q**T)*Y side = 'Left'; trans = 'Transpose'; [x, info] = f08ak( ... side, trans, lq, tau, y); disp('Least squares solution X'); disp(x);
f08ak example results Least squares solution X 0.2371 0.7383 -0.4575 0.0158 -0.0085 -0.0161 -0.5192 1.0768 0.0239 -0.6436 -0.0543 -0.6613