Simulates a quantum circuit