3 Created on Fri Jun 26 14:42:56 2020 4 Copyright 2020 Peter Rakyta, Ph.D. 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 10 http://www.apache.org/licenses/LICENSE-2.0 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see http://www.gnu.org/licenses/. 21 @author: Peter Rakyta, Ph.D. 29 from scipy.stats
import unitary_group
34 from mpi4py
import MPI
36 except ModuleNotFoundError:
39 from squander
import N_Qubit_Decomposition_adaptive
40 from scipy.io
import loadmat
44 data = loadmat(
'data/Umtx.mat')
48 cDecompose = N_Qubit_Decomposition_adaptive( Umtx.conj().T, level_limit_max=5, level_limit_min=0 )
49 angl = cDecompose.get_Global_Phase()
50 Umtx_assert = cDecompose.get_Unitary()
52 assert(np.abs(angl)<2*np.pi)
55 cDecompose.set_Global_Phase(angl_new)
56 global_phase_factor = np.sqrt(2)*np.cos(angl_new)+1j*np.sqrt(2)*np.sin(angl_new)
57 cDecompose.apply_Global_Phase_Factor()
58 angl_assert = cDecompose.get_Global_Phase()
60 assert(np.abs(angl_assert)<1e-8)
61 Umtx_assert_new=cDecompose.get_Unitary()
62 assert(np.sum(np.abs(Umtx_assert*global_phase_factor-Umtx_assert_new))<0.00001)