Skip to content
Snippets Groups Projects
Commit 6f520dbd authored by Yoann Guilhem's avatar Yoann Guilhem
Browse files

Simplified and optimized gtVectorLab2Cryst and gtVectorCryst2Lab.

parent 8bd32c83
No related branches found
No related tags found
No related merge requests found
...@@ -88,14 +88,17 @@ if M == 1 && N > 1 ...@@ -88,14 +88,17 @@ if M == 1 && N > 1
Vs = squeeze(sum(Vc(:, [1 1 1], ones(N, 1)).*g, 1)).'; Vs = squeeze(sum(Vc(:, [1 1 1], ones(N, 1)).*g, 1)).';
elseif M >= 1 && N == 1 elseif M >= 1 && N == 1
% Transpose g to get gT, reshape it and expand it along 1st axis % % Transpose g to get gT, reshape it and expand it along 1st axis
gT = reshape(g.', [1 3 3]); % gT = reshape(g.', [1 3 3]);
%
% Reshape Vc % % Reshape Vc
Vc = reshape(Vc, [M 1 3]); % Vc = reshape(Vc, [M 1 3]);
%
% % Multiply and sum along 3rd axis to reproduce Vs = gT . Vc
% Vs = sum(bsxfun(@times, gT, Vc), 3);
% Multiply and sum along 3rd axis to reproduce Vs = gT . Vc % Can be simply done with this formulae
Vs = sum(bsxfun(@times, gT, Vc), 3); Vs = Vc * g;
elseif M == N && diag elseif M == N && diag
% Transpose and reshape Vc % Transpose and reshape Vc
......
...@@ -88,14 +88,17 @@ if M == 1 && N > 1 ...@@ -88,14 +88,17 @@ if M == 1 && N > 1
Vc = squeeze(sum(Vs([1 1 1], :, ones(N, 1)).*g, 2)).'; Vc = squeeze(sum(Vs([1 1 1], :, ones(N, 1)).*g, 2)).';
elseif M >= 1 && N == 1 elseif M >= 1 && N == 1
% Transpose g to get gT, reshape it and expand it along 1st axis % % Transpose g to get gT, reshape it and expand it along 1st axis
g = reshape(g, [1 3 3]); % g = reshape(g, [1 3 3]);
%
% Reshape Vs % % Reshape Vs
Vs = reshape(Vs, [M 1 3]); % Vs = reshape(Vs, [M 1 3]);
%
% % Multiply and sum along 3rd axis to reproduce Vc = g . Vs
% Vc = sum(bsxfun(@times, g, Vs), 3);
% Multiply and sum along 3rd axis to reproduce Vc = g . Vs % Can be simply done with this formulae
Vc = sum(bsxfun(@times, g, Vs), 3); Vc = (g * Vs.').';
elseif M == N && diag elseif M == N && diag
% Transpose and reshape Vc % Transpose and reshape Vc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment