From: Michael Orlitzky Date: Fri, 22 Mar 2013 07:47:09 +0000 (-0400) Subject: Add an optional upper bound argument to random_positive_definite_matrix(). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=dd4952297ff354dc22696eb88c573198f2397348;p=octave.git Add an optional upper bound argument to random_positive_definite_matrix(). --- diff --git a/random_positive_definite_matrix.m b/random_positive_definite_matrix.m index fb3be2c..9b3f0f0 100644 --- a/random_positive_definite_matrix.m +++ b/random_positive_definite_matrix.m @@ -1,4 +1,4 @@ -function A = random_positive_definite_matrix(integerN) +function A = random_positive_definite_matrix(integerN, max_entry = realmax) % % Generate a random, symmetric positive-definite (SPD) matrix. % @@ -13,12 +13,14 @@ function A = random_positive_definite_matrix(integerN) % % - ``integerN`` -- The dimension of the resulting matrix. % + % - ``max_entry`` -- (optional) Upper bound on the entries. + % % OUTPUT: % % - ``A`` -- A symmetric, positive definite matrix. % U = random_orthogonal_matrix(integerN); - d = unifrnd(eps, realmax, 1, integerN); + d = unifrnd(eps, max_entry, 1, integerN); D = diag(d); A = U*D*U'; end