
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Jbn,in,jn] = Jbar_ind(n);  %first variant
Jbn = tril(Jbn);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Jbo,io,jo] = Jbar(n); 
Jbo = tril(Jbo);
indso=find(Jbo);


%rez=Jbo-Jbn;
%kr=find(rez(:));

%RT=VT*R*VT';
%RTr=RT(kr);
%LTr=LT(kr);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[GG,ig,jg,ing,jng] = gangster(n); 
GG = tril(GG);
indsg=find(GG);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
V = [ eye( n-1 ); - ones( n-1,1)'];         
e = ones(n,1);
VT = [1, zeros(1,(n-1)*(n-1));kron(e,e)/n, kron(V,V) ];   %clanak
VT = sparse(VT);


m = n^2+1;
P=io;
Q=jo;
MM = [];

for cnt = 1 : length(indso),
  Eij = zeros(n^2+1);
  Eij(indso(cnt)) = 1;
  Eij = (Eij + Eij')/2;

  VTEijVT = VT'*Eij*VT;
  VTEijVT = (VTEijVT+ VTEijVT')/2; 
%  VTEijVT(indso) = zeros(length(indso),1);

  GVT = VTEijVT(:);  

 MM = [MM GVT];
end;


% second test
v = rand(length(indso),1);
P=io;
Q=jo;
Mat =[];
for cnt = 1 : length(indso),
  Eij = zeros(n^2+1);
  Eij(indso(cnt)) = 1;
  Eij = (Eij + Eij')/2;
  [GEij1] = G(Eij,P,Q,eq,n);
 
  GEij = zeros(length(indso),1);
  GEij(cnt) = 1;

keyboard
  Mat = [Mat, GEij];
end;

norm(Mat - R22)


re = Mat*v;



[GTt] = GT(v,P,Q,eq,n);

  


