我正在试着运行这段代码,这段代码是我联系不到的人提取的, 该代码计算平方矩阵的dwt2和idwt2
#include <iostream>
#include <pywt>
#include <numpy>
using namespace std;
int main() {
int Matrix=numpy.array([[1.0,2.0,3.0,4.0,],[5.0,6.0,7.0,8.0,],[9.0,10.0,11.0,12.0,],[13.0,14.0,15.0,16.0,],])
cout << "-----------------------------------------------------------------";
cout << "Matrix : \n";
cout << Matrix[0];
int A,(B,C,D)=pywt.dwt2(Matrix,'haar', mode='symmetric')
cout << "-----------------------------------------------------------------";
cout << "A : \n";
cout << A[0];
cout << "-----------------------------------------------------------------";
cout << "B : \n";
cout << B[0];
cout << "-----------------------------------------------------------------";
cout << "C : \n";
cout << C[0];
cout << "-----------------------------------------------------------------";
cout << "D : \n";
cout << D[0];
int newMatrix=pywt.idwt2((A,(B,C,D)),'haar',mode='symmetric')
cout << "-----------------------------------------------------------------";
cout << "newMatrix : \n";
cout << newMatrix;
return 0;
}
Numpy库的链接:https://github.com/numpy/numpy pywt库的链接:https://github.com/PyWavelets/pywt
他说这些库既用于Python和C++,也只是把它们放在与C++代码相同的文件夹中,但我是C++的新手,我尝试了很多方法来工作,并在^ {CD1>}中包含库,但我仍然得到相同的错误,^ {CD2>},我不能导入库并使代码工作,请您帮助我。p>非常感谢你
我看到您使用的是MinGW64,因此我认为您使用的是IDE代码块。要在代码块中添加库,请转到设置->;编译器->;全局编译器设置->;搜索目录->;并从下载的文件夹中添加include目录。然后,执行链接器设置,然后添加所需的库
你可以读一篇有用的文章here
顺便说一下,你可以用C++来做。我认为这更容易做到。这就是代码:这是一幅带有结果的图像: result
相关问题 更多 >
编程相关推荐