def _define_fixed_operators(self): N1 = self.N1 N2 = self.N2 self.I = tensor([ops.identity(N1), ops.identity(N2)]) self.a1 = tensor([ops.destroy(N1), ops.identity(N2)]) self.a1_dag = tensor([ops.create(N1), ops.identity(N2)]) self.a2 = tensor([ops.identity(N1), ops.destroy(N2)]) self.a2_dag = tensor([ops.identity(N1), ops.create(N2)]) self.q1 = tensor([ops.position(N1), ops.identity(N2)]) self.p1 = tensor([ops.momentum(N1), ops.identity(N2)]) self.n1 = tensor([ops.num(N1), ops.identity(N2)]) self.q2 = tensor([ops.identity(N1), ops.position(N2)]) self.p2 = tensor([ops.identity(N1), ops.momentum(N2)]) self.n2 = tensor([ops.identity(N1), ops.num(N2)]) self.parity1 = tensor([ops.parity(N1), ops.identity(N2)]) self.parity2 = tensor([ops.identity(N1), ops.parity(N2)]) tensor_with = [None, ops.identity(N2)] self.translate1 = ops.TranslationOperator(N1, tensor_with=tensor_with) self.displace1 = lambda a: self.translate1(sqrt(2) * a) self.rotate1 = ops.RotationOperator(N1, tensor_with=tensor_with) tensor_with = [ops.identity(N1), None] self.translate2 = ops.TranslationOperator(N2, tensor_with=tensor_with) self.displace2 = lambda a: self.translate2(sqrt(2) * a) self.rotate2 = ops.RotationOperator(N2, tensor_with=tensor_with)
def _define_fixed_operators(self): N = self.N self.I = ops.identity(N) self.a = ops.destroy(N) self.a_dag = ops.create(N) self.q = ops.position(N) self.p = ops.momentum(N) self.n = ops.num(N) self.parity = ops.parity(N) self.phase = ops.Phase() self.rotate = ops.RotationOperator(N) self.translate = ops.TranslationOperator(N) self.displace = lambda a: self.translate(sqrt(2) * a) self.SNAP = ops.SNAP(N)
def _define_fixed_operators(self): N = self.N N_large = self._N_large self.I = tensor([ops.identity(2), ops.identity(N)]) self.a = tensor([ops.identity(2), ops.destroy(N)]) self.a_dag = tensor([ops.identity(2), ops.create(N)]) self.q = tensor([ops.identity(2), ops.position(N)]) self.p = tensor([ops.identity(2), ops.momentum(N)]) self.n = tensor([ops.identity(2), ops.num(N)]) self.parity = tensor([ops.identity(2), ops.parity(N)]) self.sx = tensor([ops.sigma_x(), ops.identity(N)]) self.sy = tensor([ops.sigma_y(), ops.identity(N)]) self.sz = tensor([ops.sigma_z(), ops.identity(N)]) self.sm = tensor([ops.sigma_m(), ops.identity(N)]) tensor_with = [ops.identity(2), None] self.phase = ops.Phase() self.translate = ops.TranslationOperator(N, tensor_with=tensor_with) self.displace = lambda a: self.translate(sqrt(2) * a) self.rotate = ops.RotationOperator(N, tensor_with=tensor_with) # displacement operators with larger intermediate hilbert space used for tomography self.translate_large = lambda a: tensor( [ops.identity(2), ops.TranslationOperator(N_large)(a)[:, :N, :N]] ) self.displace_large = lambda a: self.translate_large(sqrt(2) * a) self.displaced_parity_large = lambda a: tf.linalg.matmul( tf.linalg.matmul(self.displace_large(a), self.parity), self.displace_large(-a), ) tensor_with = [None, ops.identity(N)] self.rotate_qb_xy = ops.QubitRotationXY(tensor_with=tensor_with) self.rotate_qb_z = ops.QubitRotationZ(tensor_with=tensor_with) self.rxp = self.rotate_qb_xy(tf.constant(pi / 2), tf.constant(0)) self.rxm = self.rotate_qb_xy(tf.constant(-pi / 2), tf.constant(0)) # qubit sigma_z measurement projector self.P = {i: tensor([ops.projector(i, 2), ops.identity(N)]) for i in [0, 1]} self.sx_selective = tensor([ops.sigma_x(), ops.projector(0, N)]) + tensor( [ops.identity(2), ops.identity(N) - ops.projector(0, N)] )
def _define_fixed_operators(self): N = self.N self.I = tensor([ops.identity(2), ops.identity(N)]) self.a = tensor([ops.identity(2), ops.destroy(N)]) self.a_dag = tensor([ops.identity(2), ops.create(N)]) self.q = tensor([ops.identity(2), ops.position(N)]) self.p = tensor([ops.identity(2), ops.momentum(N)]) self.n = tensor([ops.identity(2), ops.num(N)]) self.parity = tensor([ops.identity(2), ops.parity(N)]) self.sx = tensor([ops.sigma_x(), ops.identity(N)]) self.sy = tensor([ops.sigma_y(), ops.identity(N)]) self.sz = tensor([ops.sigma_z(), ops.identity(N)]) self.sm = tensor([ops.sigma_m(), ops.identity(N)]) self.hadamard = tensor([ops.hadamard(), ops.identity(N)]) tensor_with = [ops.identity(2), None] self.phase = ops.Phase() self.translate = ops.TranslationOperator(N, tensor_with=tensor_with) self.displace = lambda a: self.translate(sqrt(2) * a) self.rotate = ops.RotationOperator(N, tensor_with=tensor_with) self.SNAP = ops.SNAP(N, tensor_with=tensor_with) self.SNAP_miscalibrated = ops.SNAPv3(N, chi=1e6, pulse_len=3.4e-6) tensor_with = [None, ops.identity(N)] self.rotate_qb_xy = ops.QubitRotationXY(tensor_with=tensor_with) self.rotate_qb_z = ops.QubitRotationZ(tensor_with=tensor_with) self.rxp = self.rotate_qb_xy(tf.constant(pi / 2), tf.constant(0)) self.rxm = self.rotate_qb_xy(tf.constant(-pi / 2), tf.constant(0)) # qubit sigma_z measurement projector self.P = { i: tensor([ops.projector(i, 2), ops.identity(N)]) for i in [0, 1] } self.sx_selective = tensor([ops.sigma_x(), ops.projector(0, N)]) + \ tensor([ops.identity(2), ops.identity(N)-ops.projector(0, N)])
def test_destroy(self): npt.assert_array_equal( destroy(self.N), tf.cast(qt.destroy(self.N).full(), dtype=tf.complex64))
def __init__(self): self.a = destroy(100) self.a_dag = create(100) super().__init__()