Skip to content

Commit 6863bd0

Browse files
Fe-r-ozKrastanov
andauthored
noncliff: improve performance of _allthreesumtozero (#377)
--------- Co-authored-by: Stefan Krastanov <[email protected]>
1 parent 624eedd commit 6863bd0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/nonclifford.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,13 @@ function expect(p::PauliOperator, s::GeneralizedStabilizer) # TODO optimize
161161
end
162162

163163
"""Same as `all(==(0), (a.+b.+c) .% 2)`"""
164-
function _allthreesumtozero(a,b,c) # TODO consider using bitpacking and SIMD xor with less eager shortcircuiting -- probably would be much faster
165-
@inbounds @simd for i in 1:length(a)
166-
iseven(a[i]+b[i]+c[i]) || return false
164+
function _allthreesumtozero(a,b,c)
165+
n = length(a)
166+
@inbounds @simd for i in 1:n
167+
odd = (a[i]+b[i]+c[i]) & 1
168+
if odd != 0
169+
return false
170+
end
167171
end
168172
true
169173
end

0 commit comments

Comments
 (0)