function Z = rndsas(m,n,alpha,mu,om)
% RNDSAS  random sample generation from unit dispersion complex symmetric alpha-stable distribution. 
% 
% INPUT PARAMETERS:
%    m, n    size of the sample
%    alpha   characteristic exponent (real number in [0.1,2])
%            alpha = 2 corresponds to CN distribution 
%    mu      symmetry center (complex-valued). Also equals the mean when alpha>1.  
%    om      pseudo-dispersion parameter (complex-valued) with property  |om| inside [0,1].  
%            Since dispersion parameter = 1, om  is equal to the circularity quotient when 
%            the variance exists (i.e. only in the case that alpha=2)
%          
% OUTPUT 
%    Z     random sample of length n from  S_alpha(mu,dispersion=1,pseudo-dispersion=om) 
%
% (c) Esa Ollila, contact: esollila AT wooster.hut.fi
%
% If you use this program, please cite 
%    E. Ollila, J. Eriksson, V. Koivunen, "Complex univariate elliptically symmetric distributions", 
%       submitted to IEEE Transactions on Signal Processing, Dec. 2009. 
%-------------------------------------------------------------------------------

if (abs(om)>1)  
     error('Input parameter om should have modulus <= 1')
end

if alpha < .1 || alpha > 2,
  error('alpha must be in [.1,2] ')
end

% STEP 1
cc  = abs(om);    % cc = |om| (equals the circularity coefficient provided it exists)
ang = angle(om);  % ang = Arg(om) (equals the circularity angle provided it exists)

% STEP 2
Z0 = rndsas0(m,n,alpha)

% STEP 3
a = sqrt(1+cc); 
b = sqrt(1-cc); 
Zp = (1/2)*(a+b)*Z0 + (1/2)*(a-b)*conj(Z0);

% STEP 4
Z = mu + exp(j*ang/2)*Zp; 
