Interesting issue. From reading your error message it seems your compiler is not sure what version of the * operator to work with?
This is not throwing an error on g++, so I can't test it. From what I'm reading you need to give the compiler a little help to determine what to do.
I'm not sure if this would resolve it or not, but try wrapping the complex variables in parenthesis... term1[n] = (y1[n]) + (W_N[n]) * (y2[n]);
Other way to solve it is to cast it...? term1[n] = ((complex<double>) y1[n]) + ((complex<double>) W_N[n]) * ((complex <double>) y2[n]);
Sorry, I hope one of those helped. Anyone here using Visual Studios who might be able to help?
The compiler was not sure which one should be given a stronger weight in this situation, so it stalled out rather than trying to guess. This is safe behavior in general since you wouldn't want it guessing wrong and resulting in undefined behavior in a finished software product.
@newbieg I understand that. I am confused since each vector element is explicitly a complex<double>, for both operand vectors. So, the first candidate should be picked. It should not be ambiguous- is what I think.
And you would think your problem would be more widespread on the internet since I'd assume a lot of people who work with complex would be using doubles and would use the * operator too, but I could not find any post with this specific issue.
Mind if I ask what version of G++ you're on? Mine is Ubuntu 10.3.0 I'm still trying to get mine to throw the same error and it's not causing one.
@Rabik771, I can't reproduce your problem. What does this do with your compiler?
Are you sure that the error that you state is referring to the lines you have posted?
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <vector>
#include <complex>
usingnamespace std;
int main()
{
vector<complex<double>> W = { { 1.0, 2.0 }, { 3.0, 4.0 } };
vector<complex<double>> Z = { { 5.0, 6.0 }, { 7.0, 8.0 } };
for ( int i = 0; i < 2; i++ ) cout << W[i] * Z[i] << '\n';
}
@newbieg, I'm using CodeBlocks 20.03, compiler: gcc 5.1.0, standard: c++17
@lastchance, Your snippet doesn't throw any error. I tried a similar snippet before posting here. There wasn't any problem. The problem only pops out in a FFT function I wrote.
@lastchance, I'm sorry for not adding the includes and main. Showing the whole code is difficult as its a fairly large DLL. The FFT function should be standalone. The error is from current version where I have yet to complete CZT function.
And weirdly, after writing two more lines for CZT function (same file) the error is just gone. Now it compiles properly.
Note: I have added two more process lines for CZT function but no return statement.