@@ -2,7 +2,7 @@ module QuantumToolboxCUDAExt
22
33using QuantumToolbox
44using QuantumToolbox: makeVal, getVal
5- import QuantumToolbox: _sparse_similar
5+ import QuantumToolbox: _sparse_similar, _convert_eltype_wordsize
66import CUDA: cu, CuArray, allowscalar
77import CUDA. CUSPARSE: CuSparseVector, CuSparseMatrixCSC, CuSparseMatrixCSR, AbstractCuSparseArray
88import SparseArrays: SparseVector, SparseMatrixCSC
@@ -81,27 +81,20 @@ function cu(A::QuantumObject; word_size::Union{Val,Int} = Val(64))
8181
8282 return cu (A, makeVal (word_size))
8383end
84- cu (A:: QuantumObject , word_size:: Union{Val{32},Val{64}} ) = CuArray {_change_eltype (eltype(A), word_size)} (A)
84+ cu (A:: QuantumObject , word_size:: Union{Val{32},Val{64}} ) = CuArray {_convert_eltype_wordsize (eltype(A), word_size)} (A)
8585function cu (
8686 A:: QuantumObject{ObjType,DimsType,<:SparseVector} ,
8787 word_size:: Union{Val{32},Val{64}} ,
8888) where {ObjType<: QuantumObjectType ,DimsType<: AbstractDimensions }
89- return CuSparseVector {_change_eltype (eltype(A), word_size)} (A)
89+ return CuSparseVector {_convert_eltype_wordsize (eltype(A), word_size)} (A)
9090end
9191function cu (
9292 A:: QuantumObject{ObjType,DimsType,<:SparseMatrixCSC} ,
9393 word_size:: Union{Val{32},Val{64}} ,
9494) where {ObjType<: QuantumObjectType ,DimsType<: AbstractDimensions }
95- return CuSparseMatrixCSC {_change_eltype (eltype(A), word_size)} (A)
95+ return CuSparseMatrixCSC {_convert_eltype_wordsize (eltype(A), word_size)} (A)
9696end
9797
98- _change_eltype (:: Type{T} , :: Val{64} ) where {T<: Int } = Int64
99- _change_eltype (:: Type{T} , :: Val{32} ) where {T<: Int } = Int32
100- _change_eltype (:: Type{T} , :: Val{64} ) where {T<: AbstractFloat } = Float64
101- _change_eltype (:: Type{T} , :: Val{32} ) where {T<: AbstractFloat } = Float32
102- _change_eltype (:: Type{Complex{T}} , :: Val{64} ) where {T<: Union{Int,AbstractFloat} } = ComplexF64
103- _change_eltype (:: Type{Complex{T}} , :: Val{32} ) where {T<: Union{Int,AbstractFloat} } = ComplexF32
104-
10598QuantumToolbox. to_dense (A:: MT ) where {MT<: AbstractCuSparseArray } = CuArray (A)
10699
107100QuantumToolbox. to_dense (:: Type{T1} , A:: CuArray{T2} ) where {T1<: Number ,T2<: Number } = CuArray {T1} (A)
0 commit comments