Skip to content

Commit

Permalink
Improve runtime by making vertex term a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonReinhard committed Sep 13, 2024
1 parent f7cf596 commit b90c62b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/computable_dags/compute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
import ComputableDAGs: compute, compute_effort, children

const e = sqrt(4π / 137)
_vertex() = -1im * e * gamma()
const VERTEX = -1im * e * gamma()

compute_effort(::ComputeTask_BaseState) = 0
compute_effort(::ComputeTask_Propagator) = 0
Expand Down Expand Up @@ -117,21 +117,21 @@ end
photon::Propagated{Photon,V1},
electron::Propagated{Electron,V2},
) where {V1,V2}
return Unpropagated(Electron(), photon.value * _vertex() * electron.value) # photon - electron -> electron
return Unpropagated(Electron(), photon.value * VERTEX * electron.value) # photon - electron -> electron
end
@inline function compute( # photon, positron
::ComputeTask_Pair,
photon::Propagated{Photon,V1},
positron::Propagated{Positron,V2},
) where {V1,V2}
return Unpropagated(Positron(), positron.value * _vertex() * photon.value) # photon - positron -> positron
return Unpropagated(Positron(), positron.value * VERTEX * photon.value) # photon - positron -> positron
end
@inline function compute( # electron, positron
::ComputeTask_Pair,
electron::Propagated{Electron,V1},
positron::Propagated{Positron,V2},
) where {V1,V2}
return Unpropagated(Photon(), positron.value * _vertex() * electron.value) # electron - positron -> photon
return Unpropagated(Photon(), positron.value * VERTEX * electron.value) # electron - positron -> photon
end

@inline function compute(
Expand All @@ -156,7 +156,7 @@ end
electron::Propagated{Electron,V2},
positron::Propagated{Positron,V3},
) where {V1,V2,V3}
return positron.value * (_vertex() * photon.value) * electron.value
return positron.value * (VERTEX * photon.value) * electron.value
end

# this compiles in a reasonable amount of time for up to about 1e4 parameters
Expand Down

0 comments on commit b90c62b

Please sign in to comment.