Skip to content

Commit 9f9a9dc

Browse files
authored
Fix getindex (#121)
* fix a bug in local_solution_spec * fix getindex
1 parent c026e6b commit 9f9a9dc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/bitvector.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Base.eltype(::Type{<:StaticElementVector}) = UInt64
4747
@inbounds if ii1 == ii2
4848
(x.data[ii1+1] >> (i1-ii1*64-1)) & (1<<S - 1)
4949
else # cross two integers
50-
(x.data[ii1+1] >> (i1-ii*64-S+1)) | (x.data[ii2+1] & (1<<(i2-ii1*64) - 1))
50+
(x.data[ii1+1] >> (i1-ii1*64-S+1)) | (x.data[ii2+1] & (1<<(i2-ii2*64) - 1))
5151
end
5252
end
5353
function StaticElementVector(nflavor::Int, x::AbstractVector)

test/bitvector.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ using ProblemReductions: statictrues, staticfalses, StaticBitVector, onehotv
2828
@test ProblemReductions.hamming_distance(bv"110_111", bv"100_111") == 1
2929
end
3030

31+
@testset "getindex StaticElementVector" begin
32+
sev = StaticElementVector(20, collect(0:19))
33+
@test sev[1] == 0
34+
@test sev[10] == 9
35+
@test sev[20] == 19
36+
end

0 commit comments

Comments
 (0)