Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicite typecast in differential probability #147

Open
szabo137 opened this issue Jan 6, 2025 · 0 comments
Open

Implicite typecast in differential probability #147

szabo137 opened this issue Jan 6, 2025 · 0 comments
Labels
01 - Bug Something isn't working as expected; needs a fix good first issue Good for newcomers

Comments

@szabo137
Copy link
Member

szabo137 commented Jan 6, 2025

Problem statement

In the cross-section interface, there is an implicit typecasting for momenta with element types not equal to Float64. Consider, for instance, the test implementation introduced in #146:

using Random
using QEDbase

include("test_implementation/TestImplementation.jl")
using .TestImplementation

RNG = MersenneTwister(1)

MOM_TYPE = TestMomentum{Float32}

TESTPROC = TestProcess(2,2)
TESTMODEL = TestModel()
TESTPSDEF = TestPhaseSpaceDefinition{MOM_TYPE}()
P_IN = MOM_TYPE.(eachcol(rand(RNG,4,2)))
P_OUT = MOM_TYPE.(eachcol(rand(RNG,4,2)))
PS_POINT = TestPhaseSpacePoint(
                        TESTPROC, TESTMODEL, TESTPSDEF, P_IN, P_OUT
                    )
prop_on_psp = differential_probability(PS_POINT)

typeof(prop) # returns Float64, expected Float32

I guess the reason for this behavior is the implementation of averaging_norm, which returns the inverse of the number of spin configurations, which is the inverse of an integer, which is, per default, a Float64. This is then propagated to the top level, i.e. the differential_probability.

Similar behavior is found for differential_cross_section, probably caused by the same reason.

Suggested solution

Rewrite the parts involving the averaging_norm in such a way that the division with the number of spin combinations happens at a stage where the element type is known, e.g., directly in the calculation of differential_probability.

@szabo137 szabo137 added 01 - Bug Something isn't working as expected; needs a fix good first issue Good for newcomers labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Bug Something isn't working as expected; needs a fix good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant