Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在VisualStudio项目中为以下.cpp文件制作Python包装器? #包括 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间QuantLib; 使用名称空间boost::python; 类插值 { 公众: 插值() { }; ~z~_C++_Python_Visual Studio 2010_Wrapper_Swig - Fatal编程技术网

C++ 如何在VisualStudio项目中为以下.cpp文件制作Python包装器? #包括 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间QuantLib; 使用名称空间boost::python; 类插值 { 公众: 插值() { }; ~z~

C++ 如何在VisualStudio项目中为以下.cpp文件制作Python包装器? #包括 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间QuantLib; 使用名称空间boost::python; 类插值 { 公众: 插值() { }; ~z~,c++,python,visual-studio-2010,wrapper,swig,C++,Python,Visual Studio 2010,Wrapper,Swig,如何在VisualStudio项目中为以下.cpp文件制作Python包装器? #包括 #包括 #包括 #包括 #包括 #包括 #包括 使用名称空间QuantLib; 使用名称空间boost::python; 类插值 { 公众: 插值() { }; ~z~插值() { }; 标准::向量线性化率(双**数据,整数日计数,字符*假日,字符*复合,整数大小) { int n=大小; std::vectorxvec(n),yVec(n); 对于(inti=0;iIs),这与您前面的问题相同:如果是这样

如何在VisualStudio项目中为以下.cpp文件制作Python包装器?
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间QuantLib;
使用名称空间boost::python;
类插值
{
公众:
插值()
{
};
~z~插值()
{
};
标准::向量线性化率(双**数据,整数日计数,字符*假日,字符*复合,整数大小)
{
int n=大小;
std::vectorxvec(n),yVec(n);

对于(inti=0;iIs),这与您前面的问题相同:如果是这样,我建议将两者结合为一(以及将代码转换为.Hi@jogojapan,这是一个与我上一个问题相关的问题。这几乎是一样的,只是不同的是,现在我已经尽我所能编写包装,急需帮助。然后这两个问题需要结合起来。你可以很容易地删除另一个问题,并在这里添加链接器错误消息。另外,我建议建议您将代码简化为一个最小的示例:可能是一个只有一个空函数或超简单函数的类。尝试构建该类并检查链接器所说的内容。@jogojapan,我已删除了旧问题。现在,如果您能提供一些关于如何解决该问题的更有用的提示,那将非常感谢您。下面是我得到的错误当我试图使用boost python编写包装时,ting.LINK:致命错误LNK1104:无法打开文件“boost_python-vc100-mt-gd-1_47.lib”
# include <boost/python.hpp>
# include <iostream>
# include <math.h>
# include <vector>
# include <D:\Users\212334548\Personal\QuantLib-1.2.1\ql\quantlib.hpp>
# include <ctime>
# include <stdlib.h>

using namespace QuantLib;
using namespace boost::python;

class interpolation
{
public:
    interpolation()
    {
    };
    ~interpolation()
    {
    };

    std::vector<std::vector<double>> linearonrates(double** data,int daycount,char* holiday,char* compounding,int size)
    {
        int n = size;
        std :: vector <double > xVec (n) , yVec (n);
        for (int i=0;i<n;i++)
        {
            xVec[i] = data[i][0];
            yVec[i] = data[i][1];
        }
        LinearInterpolation linInt ( xVec . begin (), xVec . end (), yVec . begin ());
        std::vector<std::vector<double>> vec;
        for(int i = xVec[0] ; i<=xVec[n-1] ; i+=1000)
        {
            //std :: cout << linInt (i) << std :: endl ;
            std::vector<double> row;
            row.push_back(i);
            row.push_back(linInt(i));
            vec.push_back(row);
        }
        return vec;
    };

    std::vector<std::vector<double>> linearonlogrates(double** data,int daycount,char* holiday,char* compounding,int size)
    {
        int n = size;
        std :: vector <double > xVec (n) , yVec (n);
        for (int i=0;i<n;i++)
        {
            xVec[i] = data[i][0];
            yVec[i] = std::log(data[i][1]);
        }
        LinearInterpolation linInt ( xVec . begin (), xVec . end (), yVec . begin ());
        std::vector<std::vector<double>> vec;
        for(int i = xVec[0] ; i<=xVec[n-1] ; i+=1000)
        {
            //std :: cout << linInt (i) << std :: endl ;
            std::vector<double> row;
            row.push_back(i);
            row.push_back(std::exp(linInt(i)));
            vec.push_back(row);
        }
        return vec;
    };

    std::vector<std::vector<double>> linearondiscountfactors(double** data,int daycount,char* holiday,char* compounding)
    {
        std::vector<std::vector<double>> vec;
        //code here
        return vec;
    };

    std::vector<std::vector<double>> linearonlogdiscountfactors(double** data,int daycount,char* holiday,char* compounding)
    {
        std::vector<std::vector<double>> vec;
        //code here
        return vec;
    };

    std::vector<std::vector<double>> cubiconrates(double** data,int daycount,char* holiday,char* compounding)
    {
        std::vector<std::vector<double>> vec;
        //code here
        return vec;
    };

    std::vector<std::vector<double>> cubiconlogrates(double** data,int daycount,char* holiday,char* compounding)
    {
        std::vector<std::vector<double>> vec;
        //code here
        return vec;
    };

};

int main()
{
    //code here ...
    ///*-------------------------------------------------------------------------------------------------
    double **data;//= {{0,3.4},{2000,4.5},{4000,6.0},{8000,7.8},{16000,9.6}};
    data = new double*[5];
    for(int i=0;i<5;i++)
    {
        data[i] = new double[2];
    }
    data[0][0] = 0.0;
    data[0][1] = 3.4;
    data[1][0] = 2000.0;
    data[1][1] = 4.5;
    data[2][0] = 4000.0;
    data[2][1] = 6.0;
    data[3][0] = 8000.0;
    data[3][1] = 7.8;
    data[4][0] = 16000.0;
    data[4][1] = 9.6;
    int daycount = 360;
    char* holiday = "None";
    char* compounding = "Continuous";
    interpolation *inter = new interpolation();
    std::vector<std::vector<double>> vec = inter->linearonlogrates(data,daycount,holiday,compounding,5);
    //std::copy(vec.begin(), vec.end(), std::ostream_iterator<double>(std::cout, "\n"));
    //std::cout <<"data : "<< vec;
    for(int i=0;i<vec.size();i++)
    {
        std::cout <<vec[i][0]<< "\t" << vec[i][1]<<"\n";
    }
    //-------------------------------------------------------------------------------------------------*/
    double tmp;
    std::cin >> tmp;

    return 0;

}

BOOST_PYTHON_MODULE(InterP)
{   
    class_<interpolation>("interpolation")
        .def("linearonrates", &interpolation::linearonrates)
    ;
}
>interpolation.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct boost::python::converter::registration const & __cdecl boost::python::converter::registry::lookup(struct boost::python::type_info)" (__imp_?lookup@registry@converter@python@boost@@YAABUregistration@234@Utype_info@34@@Z) referenced in function "struct boost::python::converter::registration const & __cdecl boost::python::converter::detail::registry_lookup2<class interpolation const volatile >(class interpolation const volatile & (__cdecl*)(void))" (??$registry_lookup2@$$CDVinterpolation@@@detail@converter@python@boost@@YAABUregistration@123@P6AADVinterpolation@@XZ@Z)
1>d:\users\212334548\documents\visual studio 2010\Projects\wrap_interpolation\Debug\wrap_interpolation.exe : fatal error LNK1120: 32 unresolved externals