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
In this section, we introduce the default global settings used throughout the package and show how to modify them.
4
+
5
+
All settings are stored in [`QuantumToolbox.settings`](@ref).
6
+
7
+
!!! warning "Differences from QuTiP"
8
+
Due to the differences in programming languages, solving algorithms, and many other reasons, these global settings (including their default values and usage) may be very different from those in `Python QuTiP`.
9
+
10
+
## List of settings
11
+
12
+
Here, we list out each setting along with the specific functions that will use it.
13
+
14
+
-`tidyup_tol::Float64 = 1e-14` : tolerance for [`tidyup`](@ref) and [`tidyup!`](@ref).
15
+
-`auto_tidyup::Bool = true` : Automatically tidyup during the following situations:
16
+
* Solving for eigenstates, including [`eigenstates`](@ref), [`eigsolve`](@ref), and [`eigsolve_al`](@ref).
17
+
- (to be announced)
18
+
19
+
## Change default settings
20
+
21
+
First, we can check the current [`QuantumToolbox.settings`](@ref):
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=1e-14) where {T<:Real} =QuantumObject(tidyup(A.data, tol), A.type, A.dimensions)
637
-
tidyup(A::AbstractArray, tol::T2=1e-14) where {T2<:Real} =tidyup!(copy(A), tol)
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`.
643
644
644
645
Note that this function is an in-place version of [`tidyup`](@ref).
645
646
"""
646
-
tidyup!(A::QuantumObject, tol::T=1e-14) where {T<:Real} = (tidyup!(A.data, tol); A)
647
-
functiontidyup!(A::AbstractSparseArray, tol::T2=1e-14) 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}
648
649
tidyup!(nonzeros(A), tol) # tidyup A.nzval in-place (also support for CUDA sparse arrays)
649
650
returndropzeros!(A)
650
651
end
651
-
tidyup!(A::AbstractArray{T}, tol::T2=1e-14) where {T<:Real,T2<:Real} =@. A =T(abs(A) > tol) * A
652
-
tidyup!(A::AbstractArray{T}, tol::T2=1e-14) 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} =
653
654
@. A =T(abs(real(A)) > tol) *real(A) +1im*T(abs(imag(A)) > tol) *imag(A)
0 commit comments