-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
818153e
commit f5c7c8e
Showing
8 changed files
with
71 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
\******************************************************************************** | ||
* Copyright (c) 2023 the Qrisp authors | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
""" | ||
|
||
from jax.core import ShapedArray | ||
|
||
from qrisp.jax import AbstractQuantumCircuit, AbstractQubit, QuantumPrimitive | ||
|
||
# Create the primitive | ||
Measurement_p = QuantumPrimitive("measure") | ||
|
||
@Measurement_p.def_abstract_eval | ||
def measure_abstract_eval(state, qb): | ||
"""Abstract evaluation of the primitive. | ||
This function does not need to be JAX traceable. It will be invoked with | ||
abstractions of the actual arguments. | ||
Args: | ||
xs, ys, zs: abstractions of the arguments. | ||
Result: | ||
a ShapedArray for the result of the primitive. | ||
""" | ||
|
||
assert isinstance(qb, AbstractQubit) | ||
return AbstractQuantumCircuit(), ShapedArray((), bool) | ||
|
||
Measurement_p.num_qubits = 1 | ||
Measurement_p.multiple_results = True |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
\******************************************************************************** | ||
* Copyright (c) 2023 the Qrisp authors | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
""" | ||
|
||
from jax.core import Primitive | ||
|
||
# Wrapper to identify Qrisp primitives | ||
class QuantumPrimitive(Primitive): | ||
pass | ||
|