2016-06-14 3 views
0

I 오류 메시지가 무엇입니까에 대한 일치 기능 :오류 님의 전화 '접속사 (CArray &)'

iterDelayEst.cpp:32:21: error: no matching function for call to ‘conj(CArray&)’ 
auto nf1= ((x*conj(x)) * (x2*conj(x2))) 
        ^
iterDelayEst.cpp:32:21: note: candidates are: 
In file included from myfft.cpp:1:0: 
/usr/include/c++/4.9/complex:669:5: note: template<class _Tp> std::complex<_Tp> std::conj(const std::complex<_Tp>&) 
    conj(const complex<_Tp>& __z) 
    ^
/usr/include/c++/4.9/complex:669:5: note: template argument deduction/substitution failed: 
In file included from myfft.cpp:16:0: 
iterDelayEst.cpp:32:21: note: ‘CArray {aka std::valarray<std::complex<double> >}’ is not derived from ‘const std::complex<_Tp>’ 
auto nf1= ((x*conj(x)) * (x2*conj(x2))) 
        ^
In file included from myfft.cpp:1:0: 
/usr/include/c++/4.9/complex:1924:5: note: template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::conj(_Tp) 
    conj(_Tp __x) 
    ^
/usr/include/c++/4.9/complex:1924:5: note: template argument deduction/substitution failed: 
/usr/include/c++/4.9/complex: In substitution of ‘template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::conj(_Tp) [with _Tp = std::valarray<std::complex<double> >]’: 
iterDelayEst.cpp:32:21: required from here 
/usr/include/c++/4.9/complex:1924:5: error: no type named ‘__type’ in ‘struct __gnu_cxx::__promote<std::valarray<std::complex<double> >, false>’ 
In file included from myfft.cpp:16:0: 
iterDelayEst.cpp:32:37: error: no matching function for call to ‘conj(CArray&)’ 
auto nf1= ((x*conj(x)) * (x2*conj(x2))) 
            ^

내 프로그램에서 다음 함수를 실행하는 동안

//iterDelayEst.cpp 
    #include <complex> 
    #include "binFreq.cpp" 
    #include <valarray> 

    typedef std::complex<double> Complex; 
    typedef std::valarray<Complex> CArray; 

    double iterDelayEst(int n,CArray& x, CArray& x2) 
    { 


      /****************************constants*********************/ 
    //exit if uncertainty below threshold 
    double thr_samples = 1e-7; 

    //exit after fixed number of iterations 
    double nIter = 25; 
    fft(x); 
    fft(x2); 
    //frequency domain representation of signals 
    std::vector<double> tau; 

    auto f = binFreq(n); 

    std::vector<double> e; 


    int j; 
    for (j = 0 ; j < n ; j++){ 

    auto nf1= ((x*std::conj(x) * (x2*std::conj(x2)); 
    nf1 +=nf1; 
    auto nf2 =std::sqrt(nf1); 
    auto nf =nf2/(double)n; 

    } 

    } 

I 그것은 conj 인수 유형과 관련이있을 것이라고 추측하지만이를 해결하는 방법을 알아낼 수 있습니다. 도움을 주셔서 감사 드리며 무엇이든 명확히 해달라고 요청하십시오.

답변

0

std::valarray은 수학 연산의 하위 집합을 오버로드하여 각 요소에 독립적으로 적용되도록합니다. std::conj은 그들 중 하나가 아닙니다. std::valarray 과부하되지 않은 사람들을 위해, 하나는 std::valarray<T>::apply(F) 멤버 함수를 사용할 수 있습니다

auto op = [](CArray::value_type v) { return std::conj(v); }; 

auto nf1 = ((x * x.apply(op)) * (x2 * x2.apply(op))); 
//     ~~~~~~~~^    ~~~~~~~~^ 
+1

감사 표트르, 그것을 작동하는 것 같다을 !!!! – Serge