Cody

# Problem 3073. Projector Matrix

Solution 599510

Submitted on 20 Mar 2015 by Yalong Liu
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% P = (1/2)*[1 -1; -1 1]; assert(isequal(projector_matrix(P),1))

2   Pass
%% P = [1 1; 1 0]; assert(isequal(projector_matrix(P),0))

3   Pass
%% theta = pi/2; P = .5*[1-cos(theta) sin(theta); sin(theta) 1+cos(theta)]; assert(isequal(projector_matrix(P),1))

4   Pass
%% P = (1/3)*[2 1 -1; 1 2 1; -1 1 2]; assert(isequal(projector_matrix(P),1))

5   Pass
%% P = [-2 1; -6 3]; assert(isequal(projector_matrix(P),1))

6   Pass
%% P = [1 1; 0 0]; assert(isequal(projector_matrix(P),1))

7   Pass
%% P = [-2 1; -6 2]; assert(isequal(projector_matrix(P),0))

8   Pass
%% theta = pi/2; P = .5*[1-cos(theta) sin(theta); 1+sin(theta) 1+cos(theta)]; assert(isequal(projector_matrix(P),0))

9   Pass
%% P = [1 0; 0 1]; assert(isequal(projector_matrix(P),1))

10   Pass
%% ind = randi(4); switch ind case 1 P = (1/2)*[1 -1; -1 1]; assert(isequal(projector_matrix(P),1)) case 2 P = [1 1; 0 0]; assert(isequal(projector_matrix(P),1)) case 3 P = [-2 1; -6 3]; assert(isequal(projector_matrix(P),1)) case 4 P = [-2 1; -6 2]; assert(isequal(projector_matrix(P),0)) end

11   Pass
%% ind = randi(4); switch ind case 1 P = [1 1; 0 0]; assert(isequal(projector_matrix(P),1)) case 2 theta = pi/2; P = .5*[1-cos(theta) sin(theta); 1+sin(theta) 1+cos(theta)]; assert(isequal(projector_matrix(P),0)) case 3 P = [-2 1; -6 2]; assert(isequal(projector_matrix(P),0)) case 4 P = (1/2)*[1 -1; -1 1]; assert(isequal(projector_matrix(P),1)) end

12   Pass
%% ind = randi(4); switch ind case 1 P = [-2 1; -6 3]; assert(isequal(projector_matrix(P),1)) case 2 theta = pi/2; P = .5*[1-cos(theta) sin(theta); 1+sin(theta) 1+cos(theta)]; assert(isequal(projector_matrix(P),0)) case 3 P = (1/2)*[1 -1; -1 1]; assert(isequal(projector_matrix(P),1)) case 4 P = [-2 1; -6 2]; assert(isequal(projector_matrix(P),0)) end