c++stlvectorcomplex-numbers

How to get Vector of Complex numbers from two vectors (real & imag)


I have two vectors of floats and i want them to become one vector of Complex numbers. I'm stuck. I don't mind using iterators, but i am sure it'd be rediscovering the wheel i'm not informed about. Is my code leading me in the right direction?

typedef std::vector<float> CVFloat;
CVFloat vA, vB;
//fil vectors
typedef std::complex<CVFloat> myComplexVector;
myComplexVector* vA_Complex = new myComplexVector(vA, vB);

The code above is going through the compiler correctly, but when i want to get single numbers from myComplexVector using iterator i get error "Undefined symbol 'const_iterator'" (Borland C++)

myComplexVector::const_iterator it = vA_Complex->begin();

Solution

  • Here you are creating a "complex" object whose real and imaginary parts are vectors of floats.
    Maybe what you actually want to do is creating a vector of complex objects whose real and imaginary parts are floats?

    EDIT: myComplexVector is not a vector, is a complex. That's why a const_iterator for it is not defined.