function [GLCCgas_recog,res,deltaP]=GLCCfuc1Modify(SetNum,XCELL,Y,nnl,tXCELL,tY,g,L)
lam=100;
%g=0.01;
r=2;
res=[];
a=zeros(SetNum,1);
ta=cell(SetNum,1);
B=cell(SetNum,1);
P=cell(SetNum,1);
[m n]=size(XCELL{1});
dist=[];
%%
%计算W矩阵
W=zeros(n,n);
for i=1:n-nnl
    W(i,i)=10^8;
end
%%
%权值赋初值
for i=1:SetNum
    a(i)=1/SetNum;
end
%%
%初始化F
ftemp=W;
for i=1:SetNum
    ftemp=ftemp+a(i)^r*L{i};
end
F=ftemp^(-1)*W*Y;
%%
for i=1:SetNum
    B{i}=zeros(1,size(Y,2));
end
Pt=zeros(m,SetNum*size(Y,1));
for i=1:SetNum,P0{i}=zeros(n,6);end
%%
for k=1:20
    Dr= diag(0.5*(diag(Pt*Pt'+eps).^(-0.5)));
    %计算P
    for i=1:SetNum
        P{i}=(XCELL{i}*XCELL{i}'+g*Dr)^(-1)*(XCELL{i}*F-XCELL{i}*ones(n,1)*B{i});
    end
    Pt=[];
     for i=1:SetNum
        Pt=[Pt,P{i}];
    end
    %计算B
    for i=1:SetNum
        B{i}=(ones(1,n)*ones(n,1))^(-1)*(ones(1,n)*F-ones(1,n)*XCELL{i}'*P{i});
    end
    
    %计算F
    ftemp=W+eye(n)*SetNum;
    for i=1:SetNum
        ftemp=ftemp+lam*a(i)^r*L{i};
    end
    
    ftemp2=W*Y;
    for i=1:SetNum
        ftemp2=ftemp2+(XCELL{i}'*P{i}+ones(n,1)*B{i});
    end
   F=ftemp^(-1)*ftemp2;
    
    %计算权值
    for i=1:SetNum
        ta{i}=((1/(trace(F'*L{i}*F)))^(1/(r-1)));
    end
    tempta=0;
    for i=1:SetNum
        tempta=tempta+ta{i};
    end
    
    for i=1:SetNum
        a(i)=ta{i}/tempta;
    end
    res1=0;
    res2=0;
    res3=0;
    for i=1:SetNum
        res1=res1+norm(F-(XCELL{i}'*P{i}+ones(n,1)*B{i}));
    end
    [u,sigma,v]=svd(Pt);
    res2=g*1/2*sum(sum(sigma))+trace((F-Y)'*W*(F-Y));
    
    for i=1:SetNum
        res3=res3+a(i)^r*L{i};
    end
    res3=lam*trace(F'*res3*F);
    res=[res res1+res2+res3]; 
    for i=1:SetNum,deP(i)=norm(P{i}-P0{i},'fro')/norm(P{i},'fro');end;deltaP(k)=sum(deP);
    for i=1:SetNum,P0{i}=P{i};end
end
[m1 n1]=size(tXCELL{1});
yout_t=0;
  for i=1:SetNum
        yout_t=yout_t+tXCELL{i}'*P{i}+ones(n1,1)*B{i};
  end
yout_t=yout_t/SetNum;

[c1,d1]=sort(yout_t');
[ty1,ty2]=sort(tY');
yte=d1(6,:);
yte_T=ty2(6,:);
% figure
% plot(yte,'*');

GLCCgas_recog=length(find(yte_T==yte))/length(yte)*100

