Skip to content

Commit 6a19cac

Browse files
committed
Merge branch 'docs'
2 parents 57f1995 + b7b8938 commit 6a19cac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/GrayCodePosition.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ Base.@propagate_inbounds function Base.getindex(gcp::GCP, n ::Integer)
8686
end
8787
end
8888

89+
"""
90+
signedgraytransient(n::Integer)
91+
92+
Compute the `n`th signed Gray code transient index, in `1`-based indexing.
93+
"""
94+
@inline function signedgraytransient(n::T) where T <:Integer
95+
g = gray(n);
96+
pos = graytransient(n);
97+
ifelse(g & (1 << (pos - one(T))) == 0, -pos, pos)
98+
end
99+
100+
end
101+
89102
@inline function signedgraytransient(n::T) where T <:Integer
90103
g = gray(n);
91104
pos = graytransient(n);

0 commit comments

Comments
 (0)