1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Add lauchli.m from special-matrix package, avoiding the need for a
package (special-matrix) for just one file.
-- Thomas Weber <thomas.weber.mail@gmail.com> Fri, 04 Apr 2008 22:02:13 +0200
--- /dev/null
+++ b/inst/lauchli.m
@@ -0,0 +1,32 @@
+## -*- texinfo -*-
+## @deftypefn {Function File} {@var{a}} = lauchli (@var{n})
+## @deftypefnx {Function File} {@var{a}} = lauchli (@var{n},@var{mu})
+## Creates the matrix [ ones(1,@var{n}); @var{mu}*eye(@var{n}) ]
+## The value @var{mu} defaults to sqrt(eps).
+## This is an ill-conditioned system for testing the
+## accuracy of the QR routine.
+##
+## @example
+## @group
+## A = lauchli(15);
+## [Q, R] = qr(A);
+## norm(Q*R - A)
+## norm(Q'*Q - eye(rows(Q)))
+## @end group
+## @end example
+## @end deftypefn
+## @seealso {ones,zeros,eye}
+
+## This program is in the public domain
+## Author: Paul Kienzle <pkienzle@users.sf.net>
+
+function A = lauchli(n,mu)
+ if (nargin < 1 || nargin > 2)
+ usage("A = lauchli(n [, mu])");
+ endif
+
+ if (nargin < 2), mu = sqrt(eps); endif
+
+ A = [ ones(1,n); mu*eye(n) ];
+
+endfunction
|