From aa4f7c9924e5997c1bed24865244ec564e36b0b7 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 21 Aug 2023 17:54:22 -0400 Subject: [PATCH] fix MIS x86 SubspaceMap Int64 instead of Int bug --- lib/BloqadeMIS/src/loss.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/BloqadeMIS/src/loss.jl b/lib/BloqadeMIS/src/loss.jl index 044bad51d..218881aca 100644 --- a/lib/BloqadeMIS/src/loss.jl +++ b/lib/BloqadeMIS/src/loss.jl @@ -52,30 +52,30 @@ function rydberg_density_sum end rydberg_density_sum(x) = rydberg_density_sum(identity, x) struct SubspaceMap - d::Dict{Int,Int} + d::Dict{Int64,Int64} end function SubspaceMap(f, subspace::Subspace) - key = Vector{Int}(undef, length(subspace)) - val = Vector{Int}(undef, length(subspace)) + key = Vector{Int64}(undef, length(subspace)) + val = Vector{Int64}(undef, length(subspace)) origin = vec(subspace) @inbounds Threads.@threads for idx in 1:length(origin) cfg = origin[idx] key[idx] = cfg val[idx] = to_int64(f(cfg)) end - return SubspaceMap(Dict{Int,Int}(zip(key, val))) + return SubspaceMap(Dict{Int64,Int64}(zip(key, val))) end Base.length(map::SubspaceMap) = length(map.d) -Base.getindex(map::SubspaceMap, cfg::Int) = map.d[cfg] -(map::SubspaceMap)(cfg::Int) = map[cfg] +Base.getindex(map::SubspaceMap, cfg::Integer) = map.d[cfg] +(map::SubspaceMap)(cfg::Integer) = map[cfg] function to_int64(b::BitVector) # workaround type piracy length(b) <= 64 || throw(ArgumentError("length is larger than 64")) # NOTE: since we only use this to calculate number of ones # thus we don't need to check top bit - return reinterpret(Int, b.chunks[1]) + return reinterpret(Int64, b.chunks[1]) end struct ConfigAmplitude{Reg<:YaoAPI.AbstractRegister}