0

我正在尝试运行此代码,该代码被我无法再联系的人捡起,该代码计算方阵的 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++ 新手,我尝试了很多方法来使其工作并包含库在C:\Program Files (x86)\Dev-Cpp\MinGW64但我仍然遇到同样的错误,[Error] pywt: No such file or directory我无法导入库并使代码工作,请你帮帮我。

太感谢了。

4

1 回答 1

0

我看到您使用的是 MinGW64,因此我认为您使用的是 CodeBlocks IDE。要在 CodeBlocks 中添加库,请转到设置->编译器->全局编译器设置->搜索目录->并从下载的文件夹中添加包含目录。然后,执行链接器设置,然后添加您需要的库。

您可以在这里阅读有用的文章!

顺便说一句,你可以只使用 c++ 来做到这一点。我认为这样做更容易。那是代码:

#include <iostream>

using namespace std;

int main()
{
    //this is the declared matrix
    float matrix[4][4]={{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}};

    //this is the equivalent of the following line from your code
    //cout << "----------------------------------------------------";
    //I used a for loop to print 65 - characters
     for(int i=0;i<65;i++)cout<<'-';

    cout<<"\nMatrix:\n";

    //That's how basically we print a matrix, using 2 for loops
    //one for each row, and one for each column
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<4;j++)cout<<matrix[i][j]<<' ';

        cout<<'\n';

        for(int i=0;i<65;i++)cout<<'-';

        cout<<'\n';
    }

}

这是带有结果的图像: 结果

于 2020-06-03T13:07:28.033 回答