%  Az = zerm(A,epp);
%
%  Function ZERM runs through all elements in a matrix and 
%  and zeros out the real and/or the imaginary part of the 
%  complex number if the corresponding part is less than the 
%  optional argument EPP in absolute value. The default value 
%  of EPP is 1e-14.
%
%  Written by: Kjetil Havre 13/9-1996.
%  
%

function Az = zerm(A,epp)
   Az = [];
   if nargin < 2
      epp = 1e-14;
   end
   if nargin < 1
      disp('Usage: Az = zerm(A,epp)');
      return;
   end
   
   [mt,rd,cd,nx] = minfo(A);
   
   if mt ~= 'cons'
      disp('Only intended for constant matrices.')
      return
   end
   
   Az = A;
   for i=1:rd
      for j=1:cd
         if isreal(A(i,j)) == 1
	    if abs(A(i,j)) < epp
	       Az(i,j) = 0;
	    end
	 else
	    if abs(real(A(i,j))) < epp
	       Az(i,j) = imag(A(i,j))*sqrt(-1);
	    end
	    if abs(imag(A(i,j))) < epp
	       Az(i,j) = real(Az(i,j));	    
	    end	    
	 end
      end
   end
end
