wavebitscientific / functional-fortran

Functional programming for modern Fortran

Home Page:https://wavebitscientific.github.io/functional-fortran/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Take a look at the complex implementations of arange in https://github.com/wavebitscientific/functional-fortran/blob/operators-and-complex-support/src/lib/mod_functional.f90. Because the increment is of type complex, one could define the resulting array to have length determined by the Re(increment) or Im(increment). Currently, it is implemented as to use Re(increment) to determine size when Re(increment) /= 0, and Im(increment) otherwise. Would this be the most expected behavior to you or there is something else you would recommend?

  2. How would you expect sort to work on complex numbers? Sort by Re(x), by Im(x), or by norm(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.