-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: Allow any real number for gate angles (#97)
- Loading branch information
1 parent
2e61d5b
commit 7422cb3
Showing
13 changed files
with
349 additions
and
378 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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Braket" | ||
uuid = "19504a0f-b47d-4348-9127-acc6cc69ef67" | ||
authors = ["Katharine Hyatt <[email protected]>"] | ||
version = "0.9.3" | ||
version = "0.9.4" | ||
|
||
[deps] | ||
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc" | ||
|
@@ -39,8 +39,8 @@ Aqua = "=0.8" | |
AxisArrays = "=0.4.7" | ||
Base64 = "1.6" | ||
CSV = "=0.10.14" | ||
CodeTracking = "=1.3.5" | ||
Compat = "=4.15.0" | ||
CodeTracking = "=1.3.6" | ||
Compat = "=4.16.0" | ||
DataStructures = "=0.18.20" | ||
Dates = "1.6" | ||
DecFP = "=1.3.2" | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "PyBraket" | ||
uuid = "e85266a6-1825-490b-a80e-9b9469c53660" | ||
authors = ["Katharine Hyatt <[email protected]>"] | ||
version = "0.9.3" | ||
version = "0.9.4" | ||
|
||
[deps] | ||
Braket = "19504a0f-b47d-4348-9127-acc6cc69ef67" | ||
|
@@ -14,11 +14,11 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" | |
|
||
[compat] | ||
Aqua = "=0.8" | ||
Braket = "=0.9.3" | ||
Braket = "=0.9.4" | ||
CondaPkg = "=0.2.23" | ||
DataStructures = "=0.18.20" | ||
LinearAlgebra = "1.6" | ||
PythonCall = "=0.9.21" | ||
PythonCall = "=0.9.22" | ||
Statistics = "1" | ||
StructTypes = "=1.10.0" | ||
Test = "1.6" | ||
|
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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
(::Type{G})(c::Circuit) where {G<:Gate} = throw(ArgumentError("gate applied to a circuit must have targets.")) | ||
(::Type{G})(c::Circuit, args...) where {G<:Gate} = apply_gate!(Val(n_angles(G)), IR.Control(ir_typ(G)), IR.Target(ir_typ(G)), G, c, args...) | ||
apply_gate!(::Type{G}, c::Circuit, args...) where {G<:Gate} = apply_gate!(Val(n_angles(G)), IR.Control(ir_typ(G)), IR.Target(ir_typ(G)), G, c, args...) | ||
(::Type{G})(c::Circuit, args...) where {G<:Gate} = apply_gate!(Val(n_angles(G)), n_controls(G), n_targets(G), G, c, args...) | ||
(::Type{Unitary})(c::Circuit, args...) = apply_gate!(Unitary, c, args...) | ||
apply_gate!(::Type{G}, c::Circuit, args...) where {G<:Gate} = apply_gate!(Val(n_angles(G)), n_controls(G), n_targets(G), G, c, args...) | ||
|
||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, arg::IntOrQubit, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), arg)) | ||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, v::VecOrQubitSet, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = (foreach(i->add_instruction!(c, Instruction{G}(G(angle), i)), v); return c) | ||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, v::NTuple{Nq, Ti}, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N, Nq, Ti} = (foreach(i->add_instruction!(c, Instruction{G}(G(angle), i)), v); return c) | ||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, args...) where {G<:Gate, N} = (foreach(i->add_instruction!(c, Instruction{G}(G(args[end-(N-1):end]), i)), args[1:end-N]); return c) | ||
apply_gate!(::Val{0}, ::IR.NoControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, qs::IntOrQubit...) where {G<:Gate} = (foreach(i->add_instruction!(c, Instruction{G}(G(), i)), qs); return c) | ||
apply_gate!(::Val{N}, ::Val{0}, ::Val{1}, ::Type{G}, c::Circuit, args...) where {G<:Gate, N} = (foreach(i->add_instruction!(c, Instruction{G}(G(args[end-(N-1):end]), i)), args[1:end-N]); return c) | ||
apply_gate!(::Val{0}, ::Val{0}, ::Val{1}, ::Type{G}, c::Circuit, args::IntOrQubit...) where {G<:Gate} = (foreach(i->add_instruction!(c, Instruction{G}(G(), i)), args); return c) | ||
apply_gate!(::Val{0}, ::Val{0}, ::Val{1}, ::Type{G}, c::Circuit, args::VecOrQubitSet) where {G<:Gate} = (foreach(i->add_instruction!(c, Instruction{G}(G(), i)), args); return c) | ||
apply_gate!(::Val{N}, ::Val{0}, ::Val{1}, ::Type{G}, c::Circuit, args::VecOrQubitSet, angles::Union{Real, FreeParameter}...) where {N, G<:Gate} = (foreach(i->add_instruction!(c, Instruction{G}(G(tuple(angles[1:N]...)), i)), args); return c) | ||
|
||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, t1::IntOrQubit, t2::IntOrQubit, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [t1, t2])) | ||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:2])) | ||
apply_gate!(::Val{N}, ::IR.NoControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, args::NTuple{2, Ti}, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), args[1:2])) | ||
apply_gate!(::Val{N}, ::Val{0}, ::Val{2}, ::Type{G}, c::Circuit, t1::IntOrQubit, t2::IntOrQubit, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [t1, t2])) | ||
apply_gate!(::Val{N}, ::Val{0}, ::Val{2}, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:2])) | ||
apply_gate!(::Val{N}, ::Val{0}, ::Val{2}, ::Type{G}, c::Circuit, args::NTuple{2, Ti}, angle::Union{Real, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), args[1:2])) | ||
|
||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, ci::IntOrQubit, ti::IntOrQubit, angles::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angles), [ci, ti])) | ||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, args::VecOrQubitSet, angles::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angles), args[1:2])) | ||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, args::NTuple{2, Ti}, angles::Union{Float64, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angles), [args...])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{1}, ::Type{G}, c::Circuit, ci::IntOrQubit, ti::IntOrQubit, angles::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angles), [ci, ti])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{1}, ::Type{G}, c::Circuit, args::VecOrQubitSet, angles::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angles), args[1:2])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{1}, ::Type{G}, c::Circuit, args::NTuple{2, Ti}, angles::Union{Real, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angles), [args...])) | ||
|
||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, ci::IntOrQubit, t1::IntOrQubit, t2::IntOrQubit, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [ci, t1, t2])) | ||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:3])) | ||
apply_gate!(::Val{N}, ::IR.SingleControl, ::IR.DoubleTarget, ::Type{G}, c::Circuit, args::NTuple{3, Ti}, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), [args...])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{2}, ::Type{G}, c::Circuit, ci::IntOrQubit, t1::IntOrQubit, t2::IntOrQubit, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [ci, t1, t2])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{2}, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:3])) | ||
apply_gate!(::Val{N}, ::Val{1}, ::Val{2}, ::Type{G}, c::Circuit, args::NTuple{3, Ti}, angle::Union{Real, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), [args...])) | ||
|
||
apply_gate!(::Val{N}, ::IR.DoubleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, c1::IntOrQubit, c2::IntOrQubit, ti::IntOrQubit, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [c1, c2, ti])) | ||
apply_gate!(::Val{N}, ::IR.DoubleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:3])) | ||
apply_gate!(::Val{N}, ::IR.DoubleControl, ::IR.SingleTarget, ::Type{G}, c::Circuit, args::NTuple{3, Ti}, angle::Union{Float64, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), [args...])) | ||
apply_gate!(::Val{N}, ::Val{2}, ::Val{1}, ::Type{G}, c::Circuit, c1::IntOrQubit, c2::IntOrQubit, ti::IntOrQubit, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), [c1, c2, ti])) | ||
apply_gate!(::Val{N}, ::Val{2}, ::Val{1}, ::Type{G}, c::Circuit, args::VecOrQubitSet, angle::Union{Real, FreeParameter}...) where {G<:Gate, N} = add_instruction!(c, Instruction{G}(G(angle), args[1:3])) | ||
apply_gate!(::Val{N}, ::Val{2}, ::Val{1}, ::Type{G}, c::Circuit, args::NTuple{3, Ti}, angle::Union{Real, FreeParameter}...) where {G<:Gate, N, Ti} = add_instruction!(c, Instruction{G}(G(angle), [args...])) | ||
|
||
apply_gate!(::Val{0}, ::IR.NoControl, ::IR.MultiTarget, ::Type{Unitary}, c::Circuit, v::VecOrQubitSet, m::Matrix{ComplexF64}) = add_instruction!(c, Instruction{Unitary}(Unitary(m), v)) | ||
apply_gate!(::Val{0}, ::IR.NoControl, ::IR.MultiTarget, ::Type{Unitary}, c::Circuit, args...) = add_instruction!(c, Instruction{Unitary}(Unitary(args[end]), [args[1:end-1]...])) | ||
apply_gate!(::Type{Unitary}, c::Circuit, v::VecOrQubitSet, m::Matrix{ComplexF64}) = add_instruction!(c, Instruction{Unitary}(Unitary(m), v)) | ||
apply_gate!(::Type{Unitary}, c::Circuit, args...) = add_instruction!(c, Instruction{Unitary}(Unitary(args[end]), [args[1:end-1]...])) |
Oops, something went wrong.
7422cb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
7422cb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/112687
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: