]> Creatis software - CreaPhase.git/blob - octave_packages/miscellaneous-1.1.0/lauchli.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / miscellaneous-1.1.0 / lauchli.m
1 ## -*- texinfo -*-
2 ## @deftypefn {Function File} {@var{a}} = lauchli (@var{n})
3 ## @deftypefnx {Function File} {@var{a}} = lauchli (@var{n},@var{mu})
4 ## Creates the matrix [ ones(1,@var{n}); @var{mu}*eye(@var{n}) ]
5 ## The value @var{mu} defaults to sqrt(eps).
6 ## This is an ill-conditioned system for testing the
7 ## accuracy of the QR routine.
8 ##
9 ## @example
10 ## @group
11 ##       A = lauchli(15);
12 ##       [Q, R] = qr(A);
13 ##       norm(Q*R - A)
14 ##       norm(Q'*Q - eye(rows(Q)))
15 ## @end group
16 ## @end example
17 ## @end deftypefn
18 ## @seealso {ones,zeros,eye}
19
20 ## This program is in the public domain
21 ## Author: Paul Kienzle <pkienzle@users.sf.net>
22
23 function A = lauchli(n,mu)
24   if (nargin < 1 || nargin > 2)
25     usage("A = lauchli(n [, mu])");
26   endif
27
28   if (nargin < 2), mu = sqrt(eps); endif
29
30   A = [ ones(1,n); mu*eye(n) ];
31
32 endfunction