Skip to content

ex7/PCA -> projectData.m and recoverData.m vectorized#14

Open
egoistpizza wants to merge 2 commits intoeverpeace:masterfrom
egoistpizza:ex7-vectorized
Open

ex7/PCA -> projectData.m and recoverData.m vectorized#14
egoistpizza wants to merge 2 commits intoeverpeace:masterfrom
egoistpizza:ex7-vectorized

Conversation

@egoistpizza
Copy link

Updated two of the graded assignments in the PCA section of the ex7 exercise, projectData.m and recoverData.m.
The for-loops used to assign the Z and X_rec variables have been converted to non-iterative vectorized matrix multiplication single-line codes.

Before -> After (projectData.m)

% Before

for i = 1: size(X, 1)
  Z(i, :) = (U_reduce'*X(i, :)')';
end

% After

Z = (U_reduce' * X')';

Before -> After (recoverData.m)

% Before

for i = 1:size(Z, 1)
  X_rec(i, :) = (U_reduce*Z(i, :)')';
end

% After

X_rec = (U_reduce*Z')';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant