function [m, b, Q, F] = mbQF(T, k)
%[m, b, Q, F] = mbQF(T, k)
%Pro makroskopicky gradient T vrati reseni k-te reseni rovnice
%kompatibility austenit-martenzit
 I=eye(3);

 C=T'*T;
 [E, L] = eig(C);
 [l, idx]=sort(diag(L));
 E=E(:, idx);

 M = (sqrt(l(3)-l(1))/( sqrt(l(3)) + sqrt(l(1)) ))* ...
     ( -sqrt(1 - l(1))*E(:,1) - (-1)^k*sqrt( l(3) - 1 )*E(:,3));
 rho=norm(M);
 m=M/rho;
 b = rho*( sqrt( l(3)*(1-l(1))/(l(3)-l(1)) )*E(:,1) - ...
     (-1)^k*sqrt( l(1)*(l(3)-1)/(l(3)-l(1)) )*E(:,3) );
 Q = (I + b*m')*inv(T);
 F = Q*T;
end