错误C2668:'boost :: bind':对重载函数的模棱两可的调用

害怕

我试图在VS2013上以Release x64模式构建Quantlib。

我使用Property Manager添加了Boost库,然后进入了解决方案资源管理器并单击Build。

最终输出为:构建:成功18个,失败1个。0个最新,跳过0个。

当我双击错误时,此文件打开了(convolvedstudentt.cpp)

 Copyright (C) 2014 Jose Aparicio

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <[email protected]>. The license is also available online at
 <http://quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

#include <ql/experimental/math/convolvedstudentt.hpp>
#include <ql/errors.hpp>
#include <ql/math/factorial.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <ql/math/solvers1d/brent.hpp>
#include <boost/function.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
#include <boost/bind.hpp>
#include <boost/math/distributions/students_t.hpp>
#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#endif

namespace QuantLib {

    CumulativeBehrensFisher::CumulativeBehrensFisher(
        const std::vector<Integer>& degreesFreedom,
        const std::vector<Real>& factors
        )
    : degreesFreedom_(degreesFreedom), factors_(factors),
      polyConvolved_(std::vector<Real>(1, 1.)), // value to start convolution
      a_(0.)
    {
        QL_REQUIRE(degreesFreedom.size() == factors.size(),
            "Incompatible sizes in convolution.");
        for(Size i=0; i<degreesFreedom.size(); i++) {
            QL_REQUIRE(degreesFreedom[i]%2 != 0,
                "Even degree of freedom not allowed");
            QL_REQUIRE(degreesFreedom[i] >= 0,
                "Negative degree of freedom not allowed");
        }
        for(Size i=0; i<degreesFreedom_.size(); i++)
            polynCharFnc_.push_back(polynCharactT((degreesFreedom[i]-1)/2));
        // adjust the polynomial coefficients by the factors in the linear
        //   combination:
        for(Size i=0; i<degreesFreedom_.size(); i++) {
            Real multiplier = 1.;
            for(Size k=1; k<polynCharFnc_[i].size(); k++) {
                multiplier *= std::abs(factors_[i]);
                polynCharFnc_[i][k] *= multiplier;
            }
        }
        //convolution, here it is a product of polynomials and exponentials
        for(Size i=0; i<polynCharFnc_.size(); i++)
            polyConvolved_ =
                convolveVectorPolynomials(polyConvolved_, polynCharFnc_[i]);
          // trim possible zeros that might have arised:
          std::vector<Real>::reverse_iterator it = polyConvolved_.rbegin();
          while(it != polyConvolved_.rend()) {
              if(*it == 0.) {
                polyConvolved_.pop_back();
                it = polyConvolved_.rbegin();
              }else{
                  break;
              }
          }
          // cache 'a' value (the exponent)
          for(Size i=0; i<degreesFreedom_.size(); i++)
              a_ += std::sqrt(static_cast<Real>(degreesFreedom_[i]))
                * std::abs(factors_[i]);
          a2_ = a_ * a_;
    }

    Disposable<std::vector<Real> >
    CumulativeBehrensFisher::polynCharactT(Natural n) const {
        Natural nu = 2 * n +1;
        std::vector<Real> low(1,1.), high(1,1.);
        high.push_back(std::sqrt(static_cast<Real>(nu)));
        if(n==0) return low;
        if(n==1) return high;

        for(Size k=1; k<n; k++) {
            std::vector<Real> recursionFactor(1,0.); // 0 coef
            recursionFactor.push_back(0.); // 1 coef
            recursionFactor.push_back(nu/((2.*k+1.)*(2.*k-1.))); // 2 coef
            std::vector<Real> lowUp =
                convolveVectorPolynomials(recursionFactor, low);
            //add them up:
            for(Size i=0; i<high.size(); i++)
                lowUp[i] += high[i];
            low = high;
            high = lowUp;
        }
        return high;
    }

    Disposable<std::vector<Real> >
    CumulativeBehrensFisher::convolveVectorPolynomials(
        const std::vector<Real>& v1,
        const std::vector<Real>& v2) const {
    #if defined(QL_EXTRA_SAFETY_CHECKS)
        QL_REQUIRE(!v1.empty() && !v2.empty(),
            "Incorrect vectors in polynomial.");
    #endif

        const std::vector<Real>& shorter = v1.size() < v2.size() ? v1 : v2;
        const std::vector<Real>& longer = (v1 == shorter) ? v2 : v1;

        Size newDegree = v1.size()+v2.size()-2;
        std::vector<Real> resultB(newDegree+1, 0.);
        for(Size polyOrdr=0; polyOrdr<resultB.size(); polyOrdr++) {
            for(Size i=std::max<Integer>(0, polyOrdr-longer.size()+1);
                i<=std::min(polyOrdr, shorter.size()-1); i++)
                resultB[polyOrdr] += shorter[i]*longer[polyOrdr-i];
        }
        return resultB;
    }

    Probability CumulativeBehrensFisher::operator()(const Real x) const {
        // 1st & 0th terms with the table integration
        Real integral = polyConvolved_[0] * std::atan(x/a_);
        Real squared = a2_ + x*x;
        Real rootsqr = std::sqrt(squared);
        Real atan2xa = std::atan2(-x,a_);
        if(polyConvolved_.size()>1)
            integral += polyConvolved_[1] * x/squared;

        for(Size exponent = 2; exponent <polyConvolved_.size(); exponent++) {
            integral -= polyConvolved_[exponent] *
                Factorial::get(exponent-1) * std::sin((exponent)*atan2xa)
                    /std::pow(rootsqr, static_cast<Real>(exponent));
         }
        return .5 + integral / M_PI;
    }

    Probability
    CumulativeBehrensFisher::density(const Real x) const {
        Real squared = a2_ + x*x;
        Real integral = polyConvolved_[0] * a_ / squared;
        Real rootsqr = std::sqrt(squared);
        Real atan2xa = std::atan2(-x,a_);
        for(Size exponent=1; exponent <polyConvolved_.size(); exponent++) {
            integral += polyConvolved_[exponent] *
                Factorial::get(exponent) * std::cos((exponent+1)*atan2xa)
                    /std::pow(rootsqr, static_cast<Real>(exponent+1) );
        }
        return integral / M_PI;
    }



    InverseCumulativeBehrensFisher::InverseCumulativeBehrensFisher(
        const std::vector<Integer>& degreesFreedom,
        const std::vector<Real>& factors,
        Real accuracy)
    : normSqr_(std::inner_product(factors.begin(), factors.end(),
        factors.begin(), 0.)),
      accuracy_(accuracy), distrib_(degreesFreedom, factors) { }

    Real InverseCumulativeBehrensFisher::operator()(const Probability q) const {
        Probability effectiveq;
        Real sign;
        // since the distrib is symmetric solve only on the right side:
        if(q==0.5) {
            return 0.;
        }else if(q < 0.5) {
            sign = -1.;
            effectiveq = 1.-q;
        }else{
            sign = 1.;
            effectiveq = q;
        }
        Real xMin =
            InverseCumulativeNormal::standard_value(effectiveq) * normSqr_;
        // inversion will fail at the Brent's bounds-check if this is not enough
        // (q is very close to 1.), in a bad combination fails around 1.-1.e-7
        Real xMax = 1.e6;
        return sign *
            Brent().solve(boost::bind(std::bind2nd(std::minus<Real>(),
            effectiveq), boost::bind<Real>(
                &CumulativeBehrensFisher::operator (),
                distrib_, _1)), accuracy_, (xMin+xMax)/2., xMin, xMax);
    }

}

错误似乎在底部的第三行。那就是突出显示的那个。

        effectiveq), boost::bind<Real>(
            &CumulativeBehrensFisher::operator (),
            distrib_, _1)), accuracy_, (xMin+xMax)/2., xMin, xMax);

当我将鼠标悬停在上面时,它说

错误:重载函数“ boost :: bind”的多个实例与参数列表匹配:函数模板“ boost_bi :: bind_t”等。请参见所附的屏幕截图

在此处输入图片说明

我怎样才能解决这个问题?请帮忙。

路易吉·巴拉比奥(Luigi Ballabio)

最近,这在QuantLib邮件列表中出现了很多次。简而言之,该代码可与Boost 1.57(QuantLib 1.5发行时的最新版本)一起使用,但与Boost 1.58无关。

GitHub上QuantLib master分支中已对此进行了修复,但尚未将其发布。如果您想要(或必须)使用Boost 1.58,则可以从那里签出最新的代码。如果要使用已发布的QuantLib版本,则解决方法是将其降级为Boost 1.57。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

错误:对重载函数的模棱两可的调用

来自分类Dev

MSVC-C2668对重载函数的模棱两可的调用-它是编译器错误吗?

来自分类Dev

(C++) 构造函数,默认参数,“调用重载...模棱两可”

来自分类Dev

为什么传递值和传递右值重载c ++函数调用是模棱两可的?

来自分类Dev

错误:“运算符==”的模棱两可的重载

来自分类Dev

编译时错误:调用重载方法时模棱两可。为什么?

来自分类Dev

编译时错误:调用重载方法时模棱两可。为什么?

来自分类Dev

C ++模板,模棱两可的重载

来自分类Dev

C ++ libconfig模棱两可的重载

来自分类Dev

C ++ libconfig模棱两可的重载

来自分类Dev

C ++中的重载函数为unsigned char和unsigned int导致模棱两可

来自分类Dev

C ++中的重载函数为unsigned char和unsigned int导致模棱两可

来自分类Dev

我正在尝试在C ++ 03中嵌套boost的“ map_list_of”,但显然构造是模棱两可的吗?

来自分类Dev

重载采用通用类型的方法会导致模棱两可的方法调用编译错误

来自分类Dev

Extensiong模棱两可的错误

来自分类Dev

Extensiong模棱两可的错误

来自分类Dev

具有依赖类型的c ++ 11可变函数模板重载是否模棱两可?

来自分类Dev

对成员函数set_value的错误调用是模棱两可的(在使用pugixml库的xcode中)

来自分类Dev

C ++ 11/14 make_unique std :: string的模棱两可的重载

来自分类Dev

ISO C ++说这些是模棱两可的,运算符重载

来自分类Dev

当我添加头文件“ boost / function”时,使用“ bind”对重载函数进行歧义调用

来自分类Dev

C ++编译错误:无法从B转换为A,没有构造函数,或者构造函数重载模棱两可

来自分类Dev

C ++继承错误:模棱两可的错误

来自分类Dev

C ++ const mysqlpp :: String模棱两可的错误

来自分类Dev

通用方法,获得模棱两可的调用错误

来自分类Dev

为什么编译器会给出模棱两可的方法调用错误?

来自分类Dev

泛型方法的调用是模棱两可的错误

来自分类Dev

删除的默认构造函数被标识为模棱两可的错误中的候选者

来自分类Dev

使用memset函数时对数组的引用是模棱两可的错误

Related 相关文章

  1. 1

    错误:对重载函数的模棱两可的调用

  2. 2

    MSVC-C2668对重载函数的模棱两可的调用-它是编译器错误吗?

  3. 3

    (C++) 构造函数,默认参数,“调用重载...模棱两可”

  4. 4

    为什么传递值和传递右值重载c ++函数调用是模棱两可的?

  5. 5

    错误:“运算符==”的模棱两可的重载

  6. 6

    编译时错误:调用重载方法时模棱两可。为什么?

  7. 7

    编译时错误:调用重载方法时模棱两可。为什么?

  8. 8

    C ++模板,模棱两可的重载

  9. 9

    C ++ libconfig模棱两可的重载

  10. 10

    C ++ libconfig模棱两可的重载

  11. 11

    C ++中的重载函数为unsigned char和unsigned int导致模棱两可

  12. 12

    C ++中的重载函数为unsigned char和unsigned int导致模棱两可

  13. 13

    我正在尝试在C ++ 03中嵌套boost的“ map_list_of”,但显然构造是模棱两可的吗?

  14. 14

    重载采用通用类型的方法会导致模棱两可的方法调用编译错误

  15. 15

    Extensiong模棱两可的错误

  16. 16

    Extensiong模棱两可的错误

  17. 17

    具有依赖类型的c ++ 11可变函数模板重载是否模棱两可?

  18. 18

    对成员函数set_value的错误调用是模棱两可的(在使用pugixml库的xcode中)

  19. 19

    C ++ 11/14 make_unique std :: string的模棱两可的重载

  20. 20

    ISO C ++说这些是模棱两可的,运算符重载

  21. 21

    当我添加头文件“ boost / function”时,使用“ bind”对重载函数进行歧义调用

  22. 22

    C ++编译错误:无法从B转换为A,没有构造函数,或者构造函数重载模棱两可

  23. 23

    C ++继承错误:模棱两可的错误

  24. 24

    C ++ const mysqlpp :: String模棱两可的错误

  25. 25

    通用方法,获得模棱两可的调用错误

  26. 26

    为什么编译器会给出模棱两可的方法调用错误?

  27. 27

    泛型方法的调用是模棱两可的错误

  28. 28

    删除的默认构造函数被标识为模棱两可的错误中的候选者

  29. 29

    使用memset函数时对数组的引用是模棱两可的错误

热门标签

归档