Skip to content

Commit

Permalink
use onehot batch (#16)
Browse files Browse the repository at this point in the history
* use onehot batch
  • Loading branch information
Roger-luo authored and GiggleLiu committed May 17, 2019
1 parent a2462d1 commit 49df431
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "YaoArrayRegister"
uuid = "e600142f-9330-5003-8abb-0ebd767abc51"
version = "0.3.7"
version = "0.3.8"

[deps]
BitBasis = "50ba71b6-fa0f-514d-ae9a-0916efc90dcf"
Expand All @@ -15,7 +15,7 @@ YaoBase = "a8f54c17-34bc-5a9d-b050-f522fe3f755f"
julia = "^1.0.0"
LuxurySparse = "~0.4.0"
YaoBase = "~0.9.0"
BitBasis = "^0.4.0"
BitBasis = "^0.5.0"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
5 changes: 2 additions & 3 deletions src/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ArrayReg{1,Complex{Float32},Array...}
ArrayReg(bitstr::BitStr) = ArrayReg(ComplexF64, bitstr)
ArrayReg(::Type{T}, bitstr::BitStr) where T = ArrayReg{1}(T, bitstr)
ArrayReg{B}(bitstr::BitStr) where B = ArrayReg{B}(ComplexF64, bitstr)
ArrayReg{B}(::Type{T}, bitstr::BitStr) where {B, T} = ArrayReg{B}(hcat((onehot(T, bitstr) for k in 1:B)...))
ArrayReg{B}(::Type{T}, bitstr::BitStr) where {B, T} = ArrayReg{B}(onehot(T, bitstr, B))


"""
Expand Down Expand Up @@ -320,8 +320,7 @@ product_state(total::Int, bit_config::Integer; nbatch::Int=1) = product_state(Co
product_state(::Type{T}, bit_str::BitStr; nbatch::Int=1) where T = ArrayReg{nbatch}(T, bit_str)

function product_state(::Type{T}, total::Int, bit_config::Integer; nbatch::Int=1) where T
raw_state = hcat((onehot(T, total, bit_config) for k in 1:nbatch)...)
return ArrayReg{nbatch}(raw_state)
return ArrayReg{nbatch}(onehot(T, total, bit_config, nbatch))
end

"""
Expand Down

0 comments on commit 49df431

Please sign in to comment.