Didn't check to see how many other useful Fortran math intrinsics only support
real and not complex arguments. I'm sure in some cases it doesn't make sense, but not in this one.
On Tuesday, October 19, 2021 at 6:53:51 AM UTC-7, Al Greynolds wrote:
(snip)
Didn't check to see how many other useful Fortran math intrinsics only supportGoing down the list, it seems that the BESSEL functions, GAMMA,
real and not complex arguments. I'm sure in some cases it doesn't make sense,
but not in this one.
LOG_GAMMA, LOG10, and NORM2.
As far as I know, all are defined for complex values.
One reason I can think of for this lack of support is that complex functions add,
well, a complication that is not easily solved: branch cuts.
Of course there are conventions for most of these functions that you could adhere to, but doing so is less than trivial (see for instance the article by Anton
Shterenlikht in the Fortran Forum a few years ago) and the features are probably
of importance to a small group of programmers only.
On Wednesday, October 20, 2021 at 12:33:37 AM UTC-7, arjen wrote:Hm, might be a nice addition for the Fortran stdlib, as it is being developed at https://github.com/fortran-lang/stdlib/.
(snip)
One reason I can think of for this lack of support is that complex functions add,It seems that gamma is well defined for complex values, other than non-positive
well, a complication that is not easily solved: branch cuts.
Of course there are conventions for most of these functions that you could adhere to, but doing so is less than trivial (see for instance the article by Anton
Shterenlikht in the Fortran Forum a few years ago) and the features are probably
of importance to a small group of programmers only.
integers.
https://en.wikipedia.org/wiki/Gamma_function
As for erf(z), from: https://en.wikipedia.org/wiki/Error_function
it seems also to be defined for complex values.
It mentions libcerf, which is a broken link, but then:
http://ab-initio.mit.edu/wiki/index.php/Faddeeva_Package
which seems to be C++ with a C wrapper, so should be callable from Fortran.
For a simulation I needed the complex Fresnel Integral which can be simply related to an error function with a complex argument. Checking the Fortran 2018 standard I was surprised it only allowed real arguments for ERF. More surprising I found that theplotting package I use with my Fortran codes, the venerable Gnuplot, does support a complex CERF, e.g. a Cornu spiral plot:
fresnel(x) = {1.,1.}*cerf(sqrt(pi)*{1.,-1.}*x/2.)/2.
set parametric
unset key
set samples 1000
plot real(fresnel(t)),imag(fresnel(t))
Didn't check to see how many other useful Fortran math intrinsics only support real and not complex arguments. I'm sure in some cases it doesn't make sense, but not in this one.
Al
For a simulation I needed the complex Fresnel Integral which can be simply related
to an error function with a complex argument.
For a simulation I needed the complex Fresnel Integral which can be simply related
to an error function with a complex argument. Checking the Fortran 2018 standard
I was surprised it only allowed real arguments for ERF.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 269 |
Nodes: | 16 (3 / 13) |
Uptime: | 127:58:38 |
Calls: | 6,183 |
Calls today: | 3 |
Files: | 11,930 |
Messages: | 5,188,394 |