@@ -46,7 +46,7 @@ where ``\hbar`` is the reduced Planck constant, and ``k_B`` is the Boltzmann con
4646function n_thermal (ω:: T1 , ω_th:: T2 ) where {T1<: Real ,T2<: Real }
4747 x = exp (ω / ω_th)
4848 n = ((x != 1 ) && (ω_th > 0 )) ? 1 / (x - 1 ) : 0
49- return _FType (promote_type (T1, T2))(n)
49+ return _float_type (promote_type (T1, T2))(n)
5050end
5151
5252@doc raw """
@@ -125,7 +125,7 @@ julia> round(convert_unit(1, :meV, :mK), digits=4)
125125function convert_unit (value:: T , unit1:: Symbol , unit2:: Symbol ) where {T<: Real }
126126 ! haskey (_energy_units, unit1) && throw (ArgumentError (" Invalid unit :$(unit1) " ))
127127 ! haskey (_energy_units, unit2) && throw (ArgumentError (" Invalid unit :$(unit2) " ))
128- return _FType (T)(value * (_energy_units[unit1] / _energy_units[unit2]))
128+ return _float_type (T)(value * (_energy_units[unit1] / _energy_units[unit2]))
129129end
130130
131131get_typename_wrapper (A) = Base. typename (typeof (A)). wrapper
@@ -174,24 +174,26 @@ for AType in (:AbstractArray, :AbstractSciMLOperator)
174174end
175175
176176# functions for getting Float or Complex element type
177- _FType (:: AbstractArray{T} ) where {T<: Number } = _FType (T)
178- _FType (:: Type{Int32} ) = Float32
179- _FType (:: Type{Int64} ) = Float64
180- _FType (:: Type{Float32} ) = Float32
181- _FType (:: Type{Float64} ) = Float64
182- _FType (:: Type{Complex{Int32}} ) = Float32
183- _FType (:: Type{Complex{Int64}} ) = Float64
184- _FType (:: Type{Complex{Float32}} ) = Float32
185- _FType (:: Type{Complex{Float64}} ) = Float64
186- _CType (:: AbstractArray{T} ) where {T<: Number } = _CType (T)
187- _CType (:: Type{Int32} ) = ComplexF32
188- _CType (:: Type{Int64} ) = ComplexF64
189- _CType (:: Type{Float32} ) = ComplexF32
190- _CType (:: Type{Float64} ) = ComplexF64
191- _CType (:: Type{Complex{Int32}} ) = ComplexF32
192- _CType (:: Type{Complex{Int64}} ) = ComplexF64
193- _CType (:: Type{Complex{Float32}} ) = ComplexF32
194- _CType (:: Type{Complex{Float64}} ) = ComplexF64
177+ _float_type (:: AbstractArray{T} ) where {T<: Number } = _float_type (T)
178+ _float_type (:: Type{Int32} ) = Float32
179+ _float_type (:: Type{Int64} ) = Float64
180+ _float_type (:: Type{Float32} ) = Float32
181+ _float_type (:: Type{Float64} ) = Float64
182+ _float_type (:: Type{Complex{Int32}} ) = Float32
183+ _float_type (:: Type{Complex{Int64}} ) = Float64
184+ _float_type (:: Type{Complex{Float32}} ) = Float32
185+ _float_type (:: Type{Complex{Float64}} ) = Float64
186+ _float_type (T:: Type{<:Real} ) = T # Allow other untracked Real types, like ForwardDiff.Dual
187+ _complex_float_type (:: AbstractArray{T} ) where {T<: Number } = _complex_float_type (T)
188+ _complex_float_type (:: Type{Int32} ) = ComplexF32
189+ _complex_float_type (:: Type{Int64} ) = ComplexF64
190+ _complex_float_type (:: Type{Float32} ) = ComplexF32
191+ _complex_float_type (:: Type{Float64} ) = ComplexF64
192+ _complex_float_type (:: Type{Complex{Int32}} ) = ComplexF32
193+ _complex_float_type (:: Type{Complex{Int64}} ) = ComplexF64
194+ _complex_float_type (:: Type{Complex{Float32}} ) = ComplexF32
195+ _complex_float_type (:: Type{Complex{Float64}} ) = ComplexF64
196+ _complex_float_type (T:: Type{<:Complex} ) = T # Allow other untracked Complex types, like ForwardDiff.Dual
195197
196198_convert_eltype_wordsize (:: Type{T} , :: Val{64} ) where {T<: Int } = Int64
197199_convert_eltype_wordsize (:: Type{T} , :: Val{32} ) where {T<: Int } = Int32
0 commit comments