% GENCOND generates a symmetric matrix with a given condition number
%
%  
%  A=gencond(n,c) Generates a matrix A of size n with condition number
%  approximately equal to c (especially for larger values of c).
%  
%  [A,ce]=gencond(n,c) Generates a matrix A of size n with condition
%  number approximately equal to c, and the real condition number is
%  given in ce.
%
%  INPUTS 
%  n-> size of the matrix
%  c-> approximate condition number
%
%  OUPUTS
%  A-> the constructed matrix
%  ce-> The condition number of A
%
%
%   Software written by Raf Vandebril
%   Raf.Vandebril-at-cs.kuleuven.be
%   Revision Date: 10/05/2010


function [A,ce]=gencond(n,c)
  
  A=rand(n,n);
  [Q,R]=qr(A);
  
  d=diag(rand(n,1));
  d(1,1)=1/c;
  d(n,n)=1;
  
  A=Q'*d*Q;
  
  ce=cond(A);
