Code covered by the BSD License  

Highlights from
QUBIT4MATLAB V4.0

from QUBIT4MATLAB V4.0 by Geza Toth
MATLAB package for quantum information science and quantum mechanics.

w=nm(v)
% nm   Normalization
%    nm(v) converts vector v into a column vector and
%    normalizes it. If v is not a vector, then
%    it normalizes it as a density matrix setting
%    the trace to 1.

function w=nm(v)
   [y,x]=size(v);
   if y==1,
     w=v.';
     w=w/sqrt(w'*w);    
   elseif x==1,
     w=v;
     w=w/sqrt(w'*w);
   else
     w=v/trace(v);
   end %if

Contact us at files@mathworks.com