Example #1
0
 def density_matrix_call(self, state):
     new_state = (1 - self.psum) * state
     for p, gate, inv_gate in zip(self.probs, self.gates, self.inverse_gates):
         if isinstance(gate, M):
             state = K.density_matrix_collapse(gate, state, [0])
         else:
             state = gate(state)
         new_state += p * state
         if inv_gate is not None:
             state = inv_gate(state) # reset to the original state vector
     return new_state
Example #2
0
 def _density_matrix_call(self, state):
     return K.density_matrix_collapse(self, state, self.result_list())
Example #3
0
 def density_matrix_call(self, state):
     if K.name == "custom":
         result = self.result_tensor()
     else:
         result = self.result_list()
     return K.density_matrix_collapse(self, state, result)