SpIN_Cal.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. function [ G , F , R ] = SpIN_Cal( W , X , G , F , Omega_G , Omega_F , Phi_G , Phi_F , D , k , lambda , F_theo , N_iter )
  2. W2 = W.^2;
  3. tilde_W2 = [W2,lambda*ones(size(W,1),1)];
  4. Omega_Bar_G = ones(size(G))-Omega_G;
  5. Omega_Bar_F = ones(size(F))-Omega_F;
  6. Delta_G = G.*Omega_Bar_G;
  7. Delta_F = F.*Omega_Bar_F;
  8. R = zeros(N_iter+1,1);
  9. R(1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  10. for i = 1 : N_iter
  11. x = OMP(G(:,2),D,k);
  12. tilde_X = [X,D*x];
  13. tilde_F = [F,[0;1]];
  14. % updating G
  15. Delta_G = Updt_Delta_G( tilde_W2 , tilde_X , Delta_G , Phi_G , tilde_F , Omega_Bar_G );
  16. G = Phi_G + Delta_G;
  17. % updating F
  18. Delta_F = Updt_Delta_F( W2 , X , G , Delta_F , Phi_F , Omega_Bar_F );
  19. F = Phi_F + Delta_F;
  20. R(i+1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  21. end
  22. end
  23. function [ Delta_F ] = Updt_Delta_F( W , X , G , Delta_F , Phi_F , Omega_B_F )
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. % Update rule for Delta_F %
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. Delta_F = Delta_F.*(Omega_B_F).*((G'*(W.*secu_plus(X-G*Phi_F)))./(G'*(W.*(G*Delta_F))));
  28. Delta_F(isnan(Delta_F))=0;
  29. end
  30. function [ Delta_G ] = Updt_Delta_G( W , X , Delta_G , Phi_G , F , Omega_B_G )
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  32. % Update rule for Delta_G %
  33. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  34. Delta_G = Delta_G.*(Omega_B_G).*((W.*secu_plus(X-Phi_G*F))*F')./((W.*(Delta_G*F)*F')); % mise à jour
  35. Delta_G(isnan(Delta_G))=0;
  36. end
  37. function [toto] = secu_plus(tutu,s)
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. % Goal: Security in the NMF procedure which project the negative data to
  40. % epsilon (small user-defined threshold
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. if(nargin<2)
  43. s=1.e-12;
  44. end
  45. toto=max(tutu,s);
  46. toto(isnan(tutu)) = 0;
  47. end