gdtk-uq / gdtk

The Gas Dynamics Toolkit (GDTk) is a set of software tools for simulating high speed fluid flow, maintained at The University of Queensland and the University of Southern Queensland, Australia.
https://gdtk.uqcloud.net/
Other
59 stars 15 forks source link

Nightmare bug in complex pow when given negative exponent. #40

Closed uqngibbo closed 9 months ago

uqngibbo commented 9 months ago

The pow overload in complex.d current uses a for loop when called with an integer exponent, which causes it to return instantly when given a negative exponent:

number x = 10.0;
T = pow(x, -2)
writefln("T %e ", T)
>>>  10.0

This was causing all kinds of trouble in the old 2T argon model, and might be a problem elsewhere.

kyleadm commented 9 months ago

Commit 0aa0702 should fix this issue.

The routines now correctly return:

number x = 10.0;
number T = pow(x, -2)
writefln("T %e ", T)
>>>  T 1.000000e-02-0.000000e+00i