Skip to content

Commit

Permalink
Fix typos, simplify codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
waltergu committed Dec 14, 2024
1 parent bfc20d6 commit 4dc8c30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/DegreesOfFreedom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1571,14 +1571,14 @@ The `half` parameter determines the behavior of generating operators, which fall
function expand!(operators::Operators, term::Term, bond::Bond, hilbert::Hilbert; half::Bool=false)
if term.bondkind == bond.kind
value = term.value * term.amplitude(bond) * term.factor
if !isapprox(value, 0.0, atol=atol, rtol=rtol)
if !isapprox(value, 0, atol=atol, rtol=rtol)
for coupling in term.coupling(bond)
for opt in expand(coupling, Val(kind(term)), bond, hilbert)
isapprox(opt.value, 0.0, atol=atol, rtol=rtol) && continue
isapprox(opt.value, 0, atol=atol, rtol=rtol) && continue
if half
add!(operators, opt*valtype(eltype(operators))(value/(term.ishermitian ? 2 : 1)))
add!(operators, opt*scalartype(operators)(value/(term.ishermitian ? 2 : 1)))
else
opt = opt*valtype(eltype(operators))(value)
opt = opt*scalartype(operators)(value)
add!(operators, opt)
term.ishermitian || add!(operators, opt')
end
Expand Down Expand Up @@ -1840,7 +1840,7 @@ struct Boundary{Names, D<:Number, V<:AbstractVector} <: LinearTransformation
end
@inline Base.:(==)(bound₁::Boundary, bound₂::Boundary) = keys(bound₁)==keys(bound₂) && ==(efficientoperations, bound₁, bound₂)
@inline Base.isequal(bound₁::Boundary, bound₂::Boundary) = isequal(keys(bound₁), keys(bound₂)) && isequal(efficientoperations, bound₁, bound₂)
@inline Base.valtype(::Type{<:Boundary}, M::Type{<:Operator}) = reparameter(M, :value, promote_type(Complex{Int}, valtype(M)))
@inline Base.valtype(::Type{<:Boundary}, M::Type{<:Operator}) = reparameter(M, :value, promote_type(Complex{Int}, scalartype(M)))
@inline Base.valtype(B::Type{<:Boundary}, MS::Type{<:Operators}) = (M = valtype(B, eltype(MS)); Operators{M, idtype(M)})

"""
Expand Down
4 changes: 2 additions & 2 deletions src/Frameworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ function OperatorGenerator(bonds::Vector{<:Bond}, hilbert::Hilbert, terms::OneOr
terms = OneOrMore(terms)
constops = Operators{mapreduce(term->operatortype(eltype(bonds), typeof(hilbert), typeof(term)), promote_type, terms)}()
map(term->expand!(constops, term, term.ismodulatable ? emptybonds : innerbonds, hilbert; half=half), terms)
alterops = NamedTuple{map(id, terms)}(expansion(terms, emptybonds, innerbonds, hilbert, valtype(eltype(constops)); half=half))
boundops = NamedTuple{map(id, terms)}(expansion(terms, boundbonds, hilbert, boundary, valtype(eltype(constops)); half=half))
alterops = NamedTuple{map(id, terms)}(expansion(terms, emptybonds, innerbonds, hilbert, scalartype(constops); half=half))
boundops = NamedTuple{map(id, terms)}(expansion(terms, boundbonds, hilbert, boundary, scalartype(constops); half=half))
parameters = NamedTuple{map(id, terms)}(map(value, terms))
return OperatorGenerator(CategorizedGenerator(constops, alterops, boundops, parameters, boundary, style), bonds, hilbert, terms, half)
end
Expand Down
2 changes: 1 addition & 1 deletion src/QuantumOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ end
"""
OperatorProd{V, I<:Tuple} <: OperatorPack{V, I}
A special kind of `OperatorPack`, where the relation between the coefficient and each component of the opeator id can be viewed as product.
A special kind of `OperatorPack`, where the relation between the coefficient and each component of the operator id can be viewed as product.
"""
abstract type OperatorProd{V, I<:Tuple} <: OperatorPack{V, I} end
@inline Base.promote_rule(::Type{M}, ::Type{N}) where {M<:OperatorProd, N<:Number} = reparameter(M, :value, promote_type(valtype(M), N))
Expand Down

0 comments on commit 4dc8c30

Please sign in to comment.