C ++求复杂浮点

时间:2015-07-29 07:36:02

标签: c++ multidimensional-array vector complex-numbers moving-average

我想知道是否有任何方法可以在向量中存储多维数组并找到数组的平均值。每个数组都包含复杂浮点数的相同维度。

#include <iostream>
#include <vector>

template <typename T> 
class MyGarden : public LittleGarden<T>
{
public:

    typedef LittleGarden<T> BaseClass;
    typedef typename BaseClass::value_type value_type;

    using BaseClass::Flowers_info;
    using BaseClass::Average;
};

 std::vector<array<T>> Collection;
 Collection.push_back(Flowers_info);  
 Average = std::accumulate(Collection.begin(),Collection.end(), 0)/Collection.size();

但我收到了错误:

error: no match for ‘operator=’ (operand types are ‘array<std::complex<float> >’ and ‘std::vector<array<std::complex<float> >, std::allocator<array<std::complex<float> > > >::size_type {aka long unsigned int}’)
Average = std::accumulate(Collection.begin(),Collection.end(), 0)/Collection.size();
        ^
error: no match for ‘operator+’ (operand types are ‘int’ and ‘array<std::complex<float> >’)  
   __init = __init + *__first;
                   ^
note:mismatched types ‘complext<T>’ and ‘int’

它在一个.h文件中,当Flowers_info被直接使用而不进入向量时它起作用,但我想收集大约10个Flowers_info并在使用之前取平均值。现在,矢量具有与Flowers_info相同的尺寸,但是使这些复数的多维数组的平均值非常困难。我自己无法解决这个问题,有人可以提出建议吗?

谢谢。

0 个答案:

没有答案