Skip to content

Commit eb31194

Browse files
FIx errors on docs and CUDAExt
1 parent 510c709 commit eb31194

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

ext/QuantumToolboxCUDAExt.jl

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module QuantumToolboxCUDAExt
22

33
using QuantumToolbox
4+
using QuantumToolbox: makeVal, getVal
45
import CUDA: cu, CuArray
56
import CUDA.CUSPARSE: CuSparseVector, CuSparseMatrixCSC, CuSparseMatrixCSR
67
import SparseArrays: SparseVector, SparseMatrixCSC
@@ -70,19 +71,26 @@ Return a new [`QuantumObject`](@ref) where `A.data` is in the type of `CUDA` arr
7071
- `A::QuantumObject`: The [`QuantumObject`](@ref)
7172
- `word_size::Int`: The word size of the element type of `A`, can be either `32` or `64`. Default to `64`.
7273
"""
73-
cu(A::QuantumObject; word_size::Int = 64) =
74-
((word_size == 64) || (word_size == 32)) ? cu(A, Val(word_size)) :
75-
throw(DomainError(word_size, "The word size should be 32 or 64."))
76-
cu(A::QuantumObject, word_size::TW) where {TW<:Union{Val{32},Val{64}}} =
77-
CuArray{_change_eltype(eltype(A), word_size)}(A)
78-
cu(
74+
function cu(A::QuantumObject; word_size::Union{Val,Int} = Val(64))
75+
_word_size = getVal(makeVal(word_size))
76+
77+
((_word_size == 64) || (_word_size == 32)) || throw(DomainError(_word_size, "The word size should be 32 or 64."))
78+
79+
return cu(A, makeVal(word_size))
80+
end
81+
cu(A::QuantumObject, word_size::Union{Val{32},Val{64}}) = CuArray{_change_eltype(eltype(A), word_size)}(A)
82+
function cu(
7983
A::QuantumObject{ObjType,DimsType,<:SparseVector},
80-
word_size::TW,
81-
) where {ObjType,DimsType,TW<:Union{Val{32},Val{64}}} = CuSparseVector{_change_eltype(eltype(A), word_size)}(A)
82-
cu(
84+
word_size::Union{Val{32},Val{64}},
85+
) where {ObjType<:QuantumObjectType,DimsType<:AbstractDimensions}
86+
return CuSparseVector{_change_eltype(eltype(A), word_size)}(A)
87+
end
88+
function cu(
8389
A::QuantumObject{ObjType,DimsType,<:SparseMatrixCSC},
84-
word_size::TW,
85-
) where {ObjType,DimsType,TW<:Union{Val{32},Val{64}}} = CuSparseMatrixCSC{_change_eltype(eltype(A), word_size)}(A)
90+
word_size::Union{Val{32},Val{64}},
91+
) where {ObjType<:QuantumObjectType,DimsType<:AbstractDimensions}
92+
return CuSparseMatrixCSC{_change_eltype(eltype(A), word_size)}(A)
93+
end
8694

8795
_change_eltype(::Type{T}, ::Val{64}) where {T<:Int} = Int64
8896
_change_eltype(::Type{T}, ::Val{32}) where {T<:Int} = Int32

ext/QuantumToolboxCairoMakieExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function _plot_wigner(
8383
location::Union{GridPosition,Nothing},
8484
colorbar::Bool;
8585
kwargs...,
86-
) where {DT,OpType<:Union{BraQuantumObject,KetQuantumObject,OperatorQuantumObject}}
86+
) where {OpType<:Union{BraQuantumObject,KetQuantumObject,OperatorQuantumObject}}
8787
fig, location = _getFigAndLocation(location)
8888

8989
lyt = GridLayout(location)
@@ -116,7 +116,7 @@ function _plot_wigner(
116116
location::Union{GridPosition,Nothing},
117117
colorbar::Bool;
118118
kwargs...,
119-
) where {DT,OpType<:Union{BraQuantumObject,KetQuantumObject,OperatorQuantumObject}}
119+
) where {OpType<:Union{BraQuantumObject,KetQuantumObject,OperatorQuantumObject}}
120120
fig, location = _getFigAndLocation(location)
121121

122122
lyt = GridLayout(location)

src/qobj/eigsolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ julia> λ
4545
1.0 + 0.0im
4646
4747
julia> ψ
48-
2-element Vector{QuantumObject{KetQuantumObject, Dimensions{1, Tuple{Space}},Vector{ComplexF64}}}:
48+
2-element Vector{QuantumObject{KetQuantumObject, Dimensions{1, Tuple{Space}}, Vector{ComplexF64}}}:
4949
5050
Quantum Object: type=Ket dims=[2] size=(2,)
5151
2-element Vector{ComplexF64}:

0 commit comments

Comments
 (0)