% Matlab code randmatgen
%
% Generate a random matrix of specified condition number and dimension
%
% function A = randmatgen(logcond,n)
%    inputs:
%      logcond = base-10 log of condition number norm(A,2)*norm(inv(A),2)
%      n       = dimension
%    output:
%      A = matrix with desired properties
%
function A = randmatgen(logcond,n)
    [q1,r1]=qr(randn(n,n));
    [q2,r2]=qr(randn(n,n));
    d = diag(10.^((0:n-1)*logcond/(n-1)));
    A = q1*d*q2;

