From 2a4d7fca181646224d8de9d25849a5ef464381a3 Mon Sep 17 00:00:00 2001 From: "A. Yavorsky" Date: Mon, 15 Apr 2024 19:49:33 +0300 Subject: [PATCH] Performance --- src/manybody.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/manybody.jl b/src/manybody.jl index 56a7a098..33540702 100644 --- a/src/manybody.jl +++ b/src/manybody.jl @@ -360,6 +360,8 @@ Base.similar(occ::OccupationNumbers, ::Type{T}, dims::Dims) where {T} = OccupationNumbers(occ.statistics, similar(occ.occupations, T, dims)) Base.similar(::Type{OccupationNumbers{StatisticsT,T}}, dims::Dims) where {StatisticsT,T} = OccupationNumbers(StatisticsT(), similar(Vector{T}, dims)) +Base.isless(occ1::OccupationNumbers, occ2::OccupationNumbers) = occ1.occupations < occ2.occupations +Base.copyto!(dest::OccupationNumbers, src::OccupationNumbers) = copyto!(dest.occupations, src.occupations) Base.convert(::Type{OccupationNumbers{StatisticsT,T}}, occ::AbstractVector) where {StatisticsT,T} = OccupationNumbers(StatisticsT(), convert(Vector{T}, occ)) @@ -368,6 +370,7 @@ struct BosonStatistics end Base.@propagate_inbounds function state_transition!(buffer, occ::OccupationNumbers{BosonStatistics}, at_indices, a_indices) + any(==(0), (occ[m] for m in a_indices)) && return nothing factor_sq = 1 copyto!(buffer, occ) for i in a_indices @@ -384,6 +387,7 @@ end Base.@propagate_inbounds function state_transition!(buffer, occ::OccupationNumbers{FermionStatistics}, at_indices, a_indices) + any(==(0), (occ[m] for m in a_indices)) && return nothing factor = 1 copyto!(buffer, occ) for i in a_indices