Skip to content

Commit

Permalink
permit NOTs in MultiControlU
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov committed Jul 18, 2023
1 parent e29ca39 commit 64b437a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Quantikz"
uuid = "b0d11df0-eea3-4d79-b4a5-421488cbf74b"
authors = ["Stefan Krastanov <[email protected]>"]
version = "1.2"
version = "1.3"

[deps]
EndpointRanges = "340492b5-2a47-5f55-813d-aca7ddf97656"
Expand Down
11 changes: 10 additions & 1 deletion src/Quantikz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ struct MultiControlU <: QuantikzOp
control::ArrayOrRange
ocontrol::ArrayOrRange
target::ArrayOrRange
target_notU::ArrayOrRange
end

function MultiControlU(str::AbstractString,
control::ArrayOrRange,
ocontrol::ArrayOrRange,
target::ArrayOrRange)
MultiControlU(str,control,ocontrol,target,[])
end
MultiControlU(target::ArrayOrRange) = MultiControlU("\\;\\;",[],[],target)
MultiControlU(str::AbstractString, target::ArrayOrRange) = MultiControlU(str,[],[],target)
MultiControlU(control::ArrayOrRange,ocontrol::ArrayOrRange,target::ArrayOrRange) = MultiControlU("\\;\\;",control,ocontrol,target)
Expand All @@ -122,15 +129,17 @@ MultiControlU(control::Integer,target::ArrayOrRange) = MultiControlU("\\;\\;",[c
MultiControlU(str::AbstractString,control::Integer,target::Integer) = MultiControlU(str,[control],[],[target])
MultiControlU(control::Integer,target::Integer) = MultiControlU("\\;\\;",[control],[],[target])

affectedqubits(g::MultiControlU) = [g.control...,g.ocontrol...,g.target...]
affectedqubits(g::MultiControlU) = [g.control...,g.ocontrol...,g.target...,g.target_notU...]
function update_table!(qtable,step,g::MultiControlU)
table = qubitsview(qtable)
control = g.control
ocontrol = g.ocontrol
target = g.target
target_notU = g.target_notU
controls = sort([
[("\\ctrl",i) for i in control]...,
[("\\octrl",i) for i in ocontrol]...,
[("\\targ{}\\vqw",i) for i in target_notU]...,
], by=e->e[2])
m,M = extrema(target)
if length(controls)==0
Expand Down

2 comments on commit 64b437a

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

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/87749

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:

git tag -a v1.3.0 -m "<description of version>" 64b437a94cf92c536d4ac64dc882360668ae4ca7
git push origin v1.3.0

Please sign in to comment.