function y=kraus(x,Mcell)
% y=kraus(x,Mcell)
% 
% y = Sum_1^k M_i x M_i^*
%
% x,y are density matrices, Mi's are square n by n
%
% Mcell = [M_1;
%          ...
%          M_k];
[k,m]=size(Mcell); % here m is supposed to be 1
n=length(cell2mat(Mcell(1)));

y=zeros(n,n);
for i=1:k,
    Mi=cell2mat(Mcell(i));
    y=y+Mi*x*Mi';
end
end
    