Std::complex multiplication

Hi @bdallen,

Great question! I knew I had some code lying around from a couple of years ago when I was first messing around with this, so I looked it up - sadly I’ve not left any particularly enlightening comments for myself. I have a sample which is similar to yours - using std::complex<T> on-device with for some simple operations.

I’ve since had a quick search and I’m starting to remember what’s going on. The compiler replaces part of the complex multiply and divide operations with a function call to a support library that handles cases like NaN and infinite inputs. I’m not sure that it’s necessarily a great idea to do this in general, but on the assumption that your code avoids NaN and infinite numbers, you can use the compiler flag -ffast-math to avoid emitting this support code and I think at this stage it basically just works.

I think a more specificaion-based answer would suggest that it won’t work, but personally I think it’s interesting to look at code that we might be able to run, because the technology allows us to do so.

I hope this helps,
Duncan.