[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]] """ Uf = np.array([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]) # To find out whether an unknown function f with a corresponding unitary matrix Uf is constant or balanced, # we use the Deutsch-Jozsa algorithm qc = Circuit() # x - input qubit placeholder x = Qubit() # y - control qubit, set to 0 y = Qubit(np.array([1, 0])) qc.add_inputs(x, y) qc.add_layer(Id(), X()) qc.add_layer(H(n=2)) qc.add_layer(Oracle(mat=Uf)) qc.add_layer(H(), Id()) qc.add_measure() # When running the circuit, you can pass in qubit values in a feed_dict # You can run it multiple times with different values passed, but it will only compile once res = qc.run(feed_dict={x: np.array([1, 0])}) # Here res == qs.state print(qc) # The circuit is represented by a matrix: print(f'\nMatrix representation of the circuit:\n{qc.mat}\n') print(f'State: {qc.state}')