如何从两个向量(real& imag)获得复数向量 [英] 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);
上面的代码正确地通过了编译器,但是当我想使用以下方式从myComplexVector中获取单个数字时迭代器我收到错误未定义符号'const_iterator'(Borland C ++)
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();
推荐答案
此处您要创建一个复杂对象,其实际
也许您真正想做的是创建一个复杂对象的向量,这些对象的实部和虚部都是浮点数?
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?
编辑:myComplexVector不是向量,是复杂的。这就是为什么未定义 const_iterator
的原因。
myComplexVector is not a vector, is a complex. That's why a const_iterator
for it is not defined.
这篇关于如何从两个向量(real& imag)获得复数向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!