it seems to be an issue with the clang
compiler. It may not be so great with complex numbers. See, e.g.: here and here.
On the board you will find installed clang++-3.9
and g++-6.3
. The latter seems to be producing the expected result. You can switch to gcc
/g++
by setting COMPILER=gcc
in the Make parameters
entry in the IDE.
# g++ test.cpp && ./a.out
ansC: (1,0)
with test.cpp
being:
#include <complex>
#include <iostream>
int main(){
std::complex<float> ansC, numerC, denomC;
numerC = std::complex<float>(3, 0);
denomC = std::complex<float>(3, 0);
ansC = numerC / denomC;
std::cout << " ansC: " << ansC << "\n";
return 0;
}
I also installed clang++-6.0
on my board (from here) and it produces the same result as g++
. To use clang++-6.0
once installed you'd have to add to the Make parameters: CXX=/path/to/clang++-6.0
.