function [Fobj]=COMMU_Fw(dataX,dataY,same_index,diff_index,w,Dl,B,C)
%%compute the objective function F
[n,p]=size(dataX);
q=size(dataY,2);
Ks=size(same_index,2);
Kr=size(diff_index,2);

Dm=eye(p,p);
for i=1:q
   Dm=Dm+w(i)*B(:,i)*B(:,i)';%p*p
end
      
D=zeros(n,Kr*Ks); 
 for k=1:Kr    
     Dr=dataX-dataX(diff_index(:,k),:);
     for j=1:Ks
          Ds=dataX-dataX(same_index(:,j),:);   
          D(:,Ks*(k-1)+j)=diag(dataY(same_index(:,j),:)*Dl*dataY(diff_index(:,k),:)')-diag(Dr*Dm*Dr')+diag(Ds*Dm*Ds');               
     end
 end
[maxD,index]=max(D,[],2);
Fobj=C/n*sum(maxD(maxD>0).^2)+norm(w,1);
end