Cody

# Problem 3073. Projector Matrix

Solution 2129711

Submitted on 15 Feb 2020 by Augusto Mazzei
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))

ans = logical 1

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

ans = logical 0

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

ans = logical 1

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

ans = logical 1

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

ans = logical 1

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

ans = logical 1

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

ans = logical 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))

ans = logical 0

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

ans = logical 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

ans = logical 1

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

ans = logical 1

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

ans = logical 1