www.pudn.com > RobustSF.zip > compute_projection_matrix.m, change:2014-07-16,size:1695b


function [UP,G] = compute_projection_matrix( U_hat,Sigma_hat,V_hat,tr_label,lambda) 
 
nclass=length(unique(tr_label)); 
mp=length(tr_label); 
HP=zeros(nclass,mp); 
 
for il=1:mp 
    HP(tr_label(il),il)=1; 
end 
 
 
X1= U_hat*Sigma_hat*V_hat'; 
[UP,~,VP]=svd(X1); 
HSP=HP*VP; 
 
 
C=length(U_hat); 
Sigma=diag(Sigma_hat); 
rrr=length(Sigma); 
Q=zeros(size(HSP)); 
G=C*ones(1,rrr)/rrr; 
 
iter=0; 
converged=false; 
tol=1e-10; 
maxIter=1000; 
preResult=1e-10; 
 
 
PreG=G*1000; 
PreQ=Q*1000; 
 
%% Start main loop 
while ~converged 
 
     
    %% update Q 
    for i=1:rrr 
        g=G(i)*G(i); 
        Q(:,i)=g*HSP(:,i)/(g+lambda); 
    end 
     
     
    %% update G 
    beta=zeros(1,rrr); 
    for i = 1:rrr 
       beta(i)=(norm(Q(:,i),'fro'))^(2/3); 
    end 
    ssum=sum(beta); 
    for i = 1:rrr 
        G(i) = C*beta(i)/ssum; 
    end 
     
   %% stopCriterion 
   ls=0; 
   for i=1:rrr 
       if G(i)==0 
           converged = true; 
           break; 
       else 
           ls=ls+(norm(Q(:,i),2)/G(i))^2; 
       end 
   end 
   Result=ls*lambda+(norm(HSP-Q,'inf'))^2; 
%    fprintf('result: %f\n',Result); 
 
     
    stopCriterion =abs(preResult-Result); 
    preResult=Result; 
    if stopCriterion< tol 
        converged = true; 
    end 
     stopCriterion1 =norm(PreG-G,'inf'); 
    PreG=G; 
     stopCriterion2 =norm(PreQ-Q,'inf'); 
    PreQ=Q; 
     if stopCriterion1< tol && stopCriterion2< tol 
        converged = true; 
    end 
    if ~converged && iter >= maxIter 
        disp('Maximum iterations reached') ; 
        converged = true ;        
    end   
   
    iter=iter+1; 
end 
 
for i=1:rrr 
    G(i)=G(i)/Sigma(i); 
end 
 
UP=UP(:,1:length(G)); 
end