-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update reproducing.m, PTR-BCR-4 #54
base: master
Are you sure you want to change the base?
Changes from all commits
1ae6292
a9538c7
78a0ca3
0ad8393
e1a2c70
d70ad3a
588e9d7
4067e14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,86 @@ | |
%% Pg. 21, PTR-BCR-2 | ||
%% Pg. 22, PTR-BCR-3 (example appears to be the same as PTR-BCR-1, and may have to be redone) | ||
%% Pg. 23, PTR-BCR-4 | ||
|
||
% Equation 1 in Example section of PTR-BCR-4 | ||
b = dec2bin(2^6-1:-1:0)-'0'; | ||
b1=b(:,1);b2=b(:,2);b3=b(:,3);b4=b(:,4);ba1=b(:,5);ba2=b(:,6); | ||
LHS = min(reshape(b1.*b2.*b3.*b4, 4, [])); | ||
RHS = min(reshape((b1 + b2 + b3 + b4 - ba1 - 2*ba2).^2, 4, [])); | ||
isequal(LHS,RHS); % Gives 1, confirmed by Nike on 6 April. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I appreciate that it would take a long time to type out I think I'd prefer MATLAB code that looks as close as possible to the equations in the book, then we can also keep your code containing the |
||
% Equation 2 in Example section of PTR-BCR-4 | ||
b = dec2bin(2^6-1:-1:0)-'0'; | ||
b1=b(:,1);b2=b(:,2);b3=b(:,3);b4=b(:,4);ba1=b(:,5);ba2=b(:,6); | ||
LHS = min(reshape(b1.*b2.*b3.*b4, 4, [])); | ||
RHS = min(reshape(b1.*b1 + b1.*b2 + b1.*b3 + b1.*b4 + b2.*b1 + b2.*b2 + b2.*b3 + b2.*b4 + b3.*b1 + b3.*b2 + b3.*b3 + b3.*b4 + b4.*b1 + b4.*b2 + b4.*b3 + b4.*b4 + ba1.*ba1 + 2*ba1.*ba2 + 2*ba2.*ba1 + 4*ba2.*ba2 - 2*b1.*ba1 - 2*b2.*ba1 - 2*b3.*ba1 - 2*b4.*ba1 - 4*b1.*ba2 - 4*b2.*ba2 - 4*b3.*ba2 - 4*b4.*ba2, 4, [])); | ||
isequal(LHS, RHS); | ||
% b = dec2bin(2^6-1:-1:0)-'0'; | ||
% LHS = ones(2^6,1); | ||
% for i = 1:4 | ||
% LHS = LHS.*b(:,i); | ||
% end | ||
% LHS = min(reshape(LHS, 4, [])); | ||
% RHS = zeros(2^6,1); | ||
% for i = 1:4 | ||
% for j = 1:4 | ||
% RHS = RHS + b(:,i).*b(:,j); | ||
% end | ||
% end | ||
% for i = 5:6 | ||
% for j = 5:6 | ||
% RHS = RHS + 2^(i+j-10)*b(:,i).*b(:,j); | ||
% end | ||
% end | ||
% for i = 1:4 | ||
% for j = 5:6 | ||
% RHS = RHS - 2^(j-4)*b(:,i).*b(:,j); | ||
% end | ||
% end | ||
% RHS = min(reshape(RHS, 4, [])); | ||
% isequal(LHS, RHS); | ||
|
||
% k = 8, Equation in Alternative forms section of PTR-BCR-4 | ||
b = dec2bin(2^11-1:-1:0)-'0'; | ||
LHS = ones(2^11,1); | ||
for i = 1:8 | ||
LHS = LHS.*b(:,i); | ||
end | ||
LHS = min(reshape(LHS, 8, [])); | ||
RHS = zeros(2^11,1); | ||
for i=1:8 | ||
RHS = RHS + b(:,i); | ||
end | ||
RHS = RHS - b(:,9) - 2*b(:,10) - 4*b(:,11); | ||
RHS = min(reshape(RHS.^2, 8, [])); | ||
isequal(LHS, RHS); | ||
|
||
% k = 8, Eq. 71 | ||
b = dec2bin(2^11-1:-1:0)-'0'; | ||
LHS = ones(2^11,1); | ||
for i = 1:8 | ||
LHS = LHS.*b(:,i); | ||
end | ||
LHS = min(reshape(LHS, 8, [])); | ||
RHS = zeros(2^11,1); | ||
for i = 1:8 | ||
for j = 1:8 | ||
RHS = RHS + b(:,i).*b(:,j); | ||
end | ||
end | ||
for i = 9:11 | ||
for j = 9:11 | ||
RHS = RHS + 2^(i+j-18)*b(:,i).*b(:,j); | ||
end | ||
end | ||
for i = 1:8 | ||
for j = 9:11 | ||
RHS = RHS - 2^(j-8)*b(:,i).*b(:,j); | ||
end | ||
end | ||
RHS = min(reshape(RHS, 8, [])); | ||
isequal(LHS, RHS); | ||
|
||
%% Pg. 24, PTR-KZ (needs an example!) | ||
%% PTR-KZ: b1b2b3 = min_ba(1 − (ba + b1 + b2 + b3) + ba (b1 + b2 + b3) + b1b2 + b1b3 + b2b3) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eq. 71 should come before Eq. 72.