Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/KPMtools/rand_psd.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
rev | line source |
---|---|
wolffd@0 | 1 function M = rand_psd(d, d2, k) |
wolffd@0 | 2 % Create a random positive definite matrix of size d by d by k (k defaults to 1) |
wolffd@0 | 3 % M = rand_psd(d, d2, k) default: d2 = d, k = 1 |
wolffd@0 | 4 |
wolffd@0 | 5 if nargin<2, d2 = d; end |
wolffd@0 | 6 if nargin<3, k = 1; end |
wolffd@0 | 7 if d2 ~= d, error('must be square'); end |
wolffd@0 | 8 |
wolffd@0 | 9 M = zeros(d,d,k); |
wolffd@0 | 10 for i=1:k |
wolffd@0 | 11 A = rand(d); |
wolffd@0 | 12 M(:,:,i) = A*A'; |
wolffd@0 | 13 end |