You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a [`QuantumObject`](@ref) `A`, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than `tol`.
635
635
"""
636
-
tidyup(A::QuantumObject, tol::T= settings.tidyup_tol[]) where {T<:Real} =
636
+
tidyup(A::QuantumObject, tol::T= settings.tidyup_tol) where {T<:Real} =
Given a [`QuantumObject`](@ref) `A`, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than `tol`.
644
644
645
645
Note that this function is an in-place version of [`tidyup`](@ref).
646
646
"""
647
-
tidyup!(A::QuantumObject, tol::T= settings.tidyup_tol[]) where {T<:Real} = (tidyup!(A.data, tol); A)
648
-
functiontidyup!(A::AbstractSparseArray, tol::T2= settings.tidyup_tol[]) where {T2<:Real}
647
+
tidyup!(A::QuantumObject, tol::T= settings.tidyup_tol) where {T<:Real} = (tidyup!(A.data, tol); A)
648
+
functiontidyup!(A::AbstractSparseArray, tol::T2= settings.tidyup_tol) where {T2<:Real}
649
649
tidyup!(nonzeros(A), tol) # tidyup A.nzval in-place (also support for CUDA sparse arrays)
650
650
returndropzeros!(A)
651
651
end
652
-
tidyup!(A::AbstractArray{T}, tol::T2= settings.tidyup_tol[]) where {T<:Real,T2<:Real} =@. A =T(abs(A) > tol) * A
653
-
tidyup!(A::AbstractArray{T}, tol::T2= settings.tidyup_tol[]) where {T,T2<:Real} =
652
+
tidyup!(A::AbstractArray{T}, tol::T2= settings.tidyup_tol) where {T<:Real,T2<:Real} =@. A =T(abs(A) > tol) * A
653
+
tidyup!(A::AbstractArray{T}, tol::T2= settings.tidyup_tol) where {T,T2<:Real} =
654
654
@. A =T(abs(real(A)) > tol) *real(A) +1im*T(abs(imag(A)) > tol) *imag(A)
0 commit comments