X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=random_orthogonal_matrix.m;fp=random_orthogonal_matrix.m;h=8c7cea5541e7aa8890893f9327b63934290cc7a7;hp=0000000000000000000000000000000000000000;hb=f7394188abd4c5ca3a8e6a74ac16b97a4966df5e;hpb=b1a89e6359bfef7a07ffe49bc703b51ef47574a9 diff --git a/random_orthogonal_matrix.m b/random_orthogonal_matrix.m new file mode 100644 index 0000000..8c7cea5 --- /dev/null +++ b/random_orthogonal_matrix.m @@ -0,0 +1,25 @@ +function U = random_orthogonal_matrix(integerN) + % + % Generate a random orthogonal matrix. + % + % INPUT: + % + % - ``integerN`` -- The dimension of the resulting square matrix. + % + % OUTPUT: + % + % - ``U`` -- An orthogonal matrix of dimension integerN. + % + % REFERENCES: + % + % 1. G.W. Stewart, Efficient Generation of Random Orthogonal Matrices, + % SIAM J. Numer. Analysis, 1980, pp. 403--409, Section 3. + % + + % We begin by computing a random matrix A. + A = rand(integerN); + + % The Q-R decomposition of A will give us an orthogonal factor of A. + % See the reference for why this doesn't suck. + [U, R] = qr(A); +end