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 @author: Peter Rakyta, Ph.D. 23 from squander
import N_Qubit_Decomposition_adaptive
33 from squander
import Circuit
37 Circuit_ret = Circuit( qbit_num )
40 Layer = Circuit( qbit_num )
41 for target_qbit
in range(qbit_num):
42 Layer.add_U3(target_qbit,
True,
True,
True )
44 Circuit_ret.add_Circuit( Layer )
48 for idx
in range(0,level_num):
50 for target_qbit
in range(1, qbit_num-1, 2):
53 Layer = Circuit( qbit_num )
55 Layer.add_CNOT( target_qbit=target_qbit, control_qbit=target_qbit+1 )
56 Layer.add_U3( target_qbit,
True,
True,
True )
57 Layer.add_U3( target_qbit+1,
True,
True,
True )
59 Circuit_ret.add_Circuit( Layer )
62 for target_qbit
in range(0, qbit_num-1, 2):
65 Layer = Circuit( qbit_num )
67 Layer.add_CNOT( target_qbit=target_qbit, control_qbit=target_qbit+1 )
68 Layer.add_U3( target_qbit,
True,
True,
True )
69 Layer.add_U3( target_qbit+1,
True,
True,
True )
71 Circuit_ret.add_Circuit( Layer )
91 num_of_parameters = gate_structure.get_Parameter_Num()
95 parameters = np.random.uniform( 0.0, 2*np.pi, (num_of_parameters,) )
102 entropy = gate_structure.get_Second_Renyi_Entropy( parameters=parameters, qubit_list=qubit_list )
103 print(
'The second Renyi entropy is:', entropy)
106 page_entropy = len(qubit_list) * np.log(2.0) - 1.0/( pow(2, qbit_num-2*len(qubit_list)+1) )
108 print(
'The page entropy: ', page_entropy)
def create_custom_gate_structure(qbit_num, level_num=2)