support for complex type numbers?
zmiimz opened this issue · comments
Dear Milan,
thanks for very interesting module.
Any plans to add support of complex type numbers and arrays (at least where it is easy and directly applicable)?
@zmiimz: I am in process of implementing the specific procedures for complex
numbers (real32
, real64
, and real128
kinds). While for most functions the implementation is trivial, for a few it is not because of different rules for complex arithemetic. Since I almost don't work at all with complex
numbers, I do not know what kind of behavior is most expected, or "least astonishing" :). Specifically:
-
Take a look at the
complex
implementations ofarange
in https://github.com/wavebitscientific/functional-fortran/blob/operators-and-complex-support/src/lib/mod_functional.f90. Because theincrement
is of typecomplex
, one could define the resulting array to have length determined by theRe(increment)
orIm(increment)
. Currently, it is implemented as to useRe(increment)
to determine size whenRe(increment) /= 0
, andIm(increment)
otherwise. Would this be the most expected behavior to you or there is something else you would recommend? -
How would you expect
sort
to work oncomplex
numbers? Sort byRe(x)
, byIm(x)
, or bynorm(x)
?
Dear Milan,
thanks for the update. The answer is as easy as it can be. Because there is no meaning of order for complex numbers ( with the exception Im(z) == 0) any choice will be just ok. ) Sure, the most proper way would be to make it modifiable (let the user to decide the ordering by Re, Im, Abs, or lexicographic) but I am afraid it will take too much time to implement. So this is entirely up to you if you want to do this.
Hello @zmiinz, see PR #6 which adds full support for complex numbers, now merged into master.