Introducing Complex Numbers Update

Hey @scanon ,

From what I understand, you were planning on implementing complex numbers at some point, and was wondering if you had any update on the progress.

The reason why I ask is that I'm planning on introducing complex number differentiation into the Swift for TensorFlow project. So I wanted to see if you have any prototype I can work from while you finalize it and introduce it through Swift Evolution.

4 Likes

I can’t speak for Steve, but I’d expect a Complex type to be similar to that in @xwu’s Numeric Annex.

• • •

However, I am not convinced that complex numbers necessarily belong in the standard library. If we ever create an official Math library, I might expect them there (alongside linear algebra and signal processing).

2 Likes

Thanks for pointing me to that library @Nevin!

I'm still pretty new to the community, so I haven't been following along what everyone has been saying until recently. However, I did notice that SE-0246: Generic Math Functions was accepted, which introduced the Real protocol as standard in Swift without name spacing it in Math. So it seems there could be a possibility of adding Complex type as part of the standard library.

However, for what I'll be doing (differentiating complex numbers), I don't have a strong opinion on where it will exist, and the decision about where it will exist can be made when it's brought up in Swift Evolution when/if complex numbers are added. So I think the topic of where it will belong can be discussed later in the future.

1 Like

It's reasonable to expect that the complex type and basic arithmetic operations will go in the standard library eventually, because we want to be able to import C API that uses C's _Complex type. It's also reasonable to expect that more sophisticated complex API might end up in a separate library.

It's definitely a post-5.1 feature, though.

6 Likes

It's definitely a post-5.1 feature, though.

Okay that sounds good thanks for letting me know! While I investigate the capability of differentiating complex numbers, I'll work with @xwu's library then. But then if everything is successful on my end, I'll replace it with your implementation of complex numbers once it lands on master and thus can be merged downstream into the tensorflow branch.

1 Like

Yeah, I agree. This will likely go into the Swift stdlib directly, not in an add on package. The core team recently had a discussion with this and had a tentative agreement that "stuff in c99 libm" is in scope for the Swift standard library, and that includes C _Complex.

-Chris

5 Likes