function [L,cc]=yima(M,n,e)
%y=1:2^n;
%Y=daoweixu(y,n);
%LL=-ones(1,2^n);
%for i=1:2^n
% LL(i)=M(Y(i));
%end
w0=1-e;
w1=e;
W0=e;
W1=1-e;
LL=daoweixu(M,n);
for i=1:2^n
if (LL(i)==0)
LL(i)=w0/w1;
else
LL(i)=W0/W1;
end
end
[~,P]=polarize(n,e);
L=-ones(2^n,n+1)*0.1;
L(:,n+1)=LL;
u=-ones(1,2^n);
S=-ones(2^n,n); %%%%%%%%% L S V 初始化为-1的矩阵
V=-ones(1,2^n-2);
for j=1:n %指数项矩阵右上角初始赋值0
for i=1:2^(j-1)
S(i,j)=0;
end
end
l=1;
while(l<=2^n)
if (P(l)~=1)
u(l)=0;
else
j=1;
i=l;
if (l>1) %%%%%%%%
S(l,1)=u(l-1);
end %%%%%%%%
if (l>2)
if (mod(l,2)==0)
p=l-2;
for t=1:p
V(t)=u(t);
end
else
p=l-1;
for t=1:p
V(t)=u(t);
end
end
end
while(j<n+1)
if (rem(fix((i-1)/(2^(j-1))),2)==1)
if (L(i-2^(j-1),j+1)==-0.1)
%%%%%%%%%%%%%%%%%%%%%子程序2 这里
if (l>=3)
p=fix((p+1)/2);
for q=1:p
V(q)=mod(V(2*q-1)+V(2*q),2);
end
i=i-2^(j-1);
j=j+1;
if(S(i,j)==-1)
S(i,j)=V(p);
%else
% if (V(p)~=S(i,j))
% k=10000000
% end
end
i;
j;
V;
else
i=i-2^(j-1);
j=j+1;
end
elseif (L(i-2^(j-1),j+1)~=-0.1&&L(i,j+1)==-0.1)
%%%%%%%%%%%%%%%%%%%%%子程序4
if (l>=3)
p=fix((p+1)/2);
for q=1:p
V(q)=V(2*q);
end
j=j+1;
if(S(i,j)==-1)
S(i,j)=V(p);
% else
% if (V(p)~=S(i,j))
% k=10000000
% end
end
i;
j;
V;
else
j=j+1;
end
elseif (L(i-2^(j-1),j+1)~=-0.1&&L(i,j+1)~=-0.1)
L(i,j)=(L(i-2^(j-1),j+1)^(1-2*S(i,j)))*L(i,j+1);
if L(i,j)==inf
L(i,j)=1.000e+50;
end
if (j==1) %$$$$$$$$$$$$$$$$$$$$$$$
break;
else
j=1;
i=l;
if (l>2)
if (mod(l,2)==0)
p=l-2;
for t=1:p
V(t)=u(t);
end
else
p=l-1;
for t=1:p
V(t)=u(t);
end
end
end
continue;
end
end
else
if (L(i,j+1)==-0.1)
%%%%%%%%%%%%%%%%%%%%%子程序1
if (l>=3)
p=fix((p+1)/2);
for q=1:p
V(q)=mod(V(2*q-1)+V(2*q),2);
end
j=j+1;
if(S(i,j)==-1)
S(i,j)=V(p);
%else
% if (V(p)~=S(i,j))
% k=10000000
% end
end
i;
j;
V;
else
j=j+1;
end
elseif (L(i,j+1)~=-0.1&&L(i+2^(j-1),j+1)==-0.1)
%%%%%%%%%%%%%%%%%%%%%子程序3
if (l>=3)
p=fix((p+1)/2);
for q=1:p
V(q)=V(2*q);
end
i=i+2^(j-1);
j=j+1;
if(S(i,j)==-1)
S(i,j)=V(p);
%else
% if (V(p)~=S(i,j))
% k=10000000
% end
end
i;
j;
V;
else
i=i+2^(j-1);
j=j+1;
end
elseif (L(i,j+1)~=-0.1&&L(i+2^(j-1),j+1)~=-0.1)
L(i,j)=(L(i,j+1)*L(i+2^(j-1),j+1)+1)/(L(i,j+1)+L(i+2^(j-1),j+1));
if L(i,j)==inf
L(i,j)=1.000e+50;
end
if (j==1)
break;
else
j=1;
i=l;
if (l>2)
if (mod(l,2)==0)
p=l-2;
for t=1:p
V(t)=u(t);
end
else
p=l-1;
for t=1:p
V(t)=u(t);
end
end
end
continue;
end
end
end
end
if (L(l,1)>=1)
u(l)=0;
else
u(l)=1;
end
end
l=l+1;
end
L;
S;
cc=u;