%test swap_angles() % b0 a0 b0f a0f [U0] % | | --> | | % b1 a1 b1f a1f [U1] %where angle(b0,a0)->angle(b1f,a1f) %and angle(b1,a1)->angle(b0f,a0f) global_defs; example = 1; switch example case (1) a0= get_unit_vec(randn(3,1)); b0= get_unit_vec(randn(3,1)); a1= get_unit_vec(randn(3,1)); b1= get_unit_vec(randn(3,1)); otherwise error("example number is out of range"); end vecs_in=[b0,a0;b1,a1]; [vecs_out, U1, U0] = swap_angles(vecs_in); b0f=vecs_out(1:3,1); a0f=vecs_out(1:3,2); b1f=vecs_out(4:6,1); a1f=vecs_out(4:6,2); error_circuit = norm( dr11(b1,b0)*dr11(a1,a0) - dr11(b1f,b0f)*dr11(a1f,a0f)*kron(U1,U0)) error_angle0 = abs(b0'*a0 - b1f'*a1f) error_angle1 = abs(b1'*a1 - b0f'*a0f)