bmad-sim / NonlinearNormalForm.jl

Nonlinear normal form analysis using truncated power series
https://bmad-sim.github.io/NonlinearNormalForm.jl/
GNU General Public License v3.0
1 stars 0 forks source link

TPSAMap negative powers bug #8

Closed mattsignorelli closed 6 months ago

mattsignorelli commented 6 months ago

For some reason, when writing (something)^(negative_number), Julia does not just call ^(something, negative_number). Instead it calls inv(something)^(-1*negative_number). This definition does not agree with FPP. For example, for a TPSAMap m, inv(m)^3 != inv(m^3). In fact inv(m)^3 is very problematic, whereas inv(m^3) is not.

This is only a problem for TPSAMaps

DavidSagan commented 6 months ago

Solution is to define your own function function Base.literal_pow(::typeof(^), a::A, b::Val{p}) where p where A is the appropriate TPSA type.

mattsignorelli commented 6 months ago

@DavidSagan thanks! I'm going to add this to GTPSA too because it is likely faster.

fixed with #3b2c62d