I'm trying to run this code which was picked up by someone I can't reach anymore, the code calculates the dwt2 and idwt2 of a square matrix
#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;
}
Link For Numpy Library: https://github.com/numpy/numpy Link For pywt library: https://github.com/PyWavelets/pywt
and he said that these libraries use for both python and c++, and I just have to put them in the same folder as C ++ code, but I am new to C++ and I have tried many ways to make it work and to include libraries in C:\Program Files (x86)\Dev-Cpp\MinGW64
but I still get the same error, [Error] pywt: No such file or directory
, I can't import the libraries and make the code work, can you help me please.
Thank you so much.
I saw that you are using MinGW64, therefore I think you are using CodeBlocks IDE. To add a library in CodeBlocks, go to Settings->Compiler->Global compiler settings-> Search Directories-> and add the include directory from the downloaded folder. Then, do to Linker settings and then add the libraries you need.
You can read an useful article here !
By the way, you can do that using just c++. I think that is more easier to do. That's the code:
#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';
}
}
That's an image with the result: result