Skip to content

Commit

Permalink
Fix getindex (#121)
Browse files Browse the repository at this point in the history
* fix a bug in local_solution_spec

* fix getindex
  • Loading branch information
nzy1997 authored Dec 23, 2024
1 parent c026e6b commit 9f9a9dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bitvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Base.eltype(::Type{<:StaticElementVector}) = UInt64
@inbounds if ii1 == ii2
(x.data[ii1+1] >> (i1-ii1*64-1)) & (1<<S - 1)
else # cross two integers
(x.data[ii1+1] >> (i1-ii*64-S+1)) | (x.data[ii2+1] & (1<<(i2-ii1*64) - 1))
(x.data[ii1+1] >> (i1-ii1*64-S+1)) | (x.data[ii2+1] & (1<<(i2-ii2*64) - 1))
end
end
function StaticElementVector(nflavor::Int, x::AbstractVector)
Expand Down
6 changes: 6 additions & 0 deletions test/bitvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ using ProblemReductions: statictrues, staticfalses, StaticBitVector, onehotv
@test ProblemReductions.hamming_distance(bv"110_111", bv"100_111") == 1
end

@testset "getindex StaticElementVector" begin
sev = StaticElementVector(20, collect(0:19))
@test sev[1] == 0
@test sev[10] == 9
@test sev[20] == 19
end

0 comments on commit 9f9a9dc

Please sign in to comment.