0

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.

  • If you're so new that you think C++ can use Python syntax (like in `int A,(B,C,D)=pywt.dwt2(Matrix,'haar', mode='symmetric')`) or use Python modules directly, then you're way to far ahead of where you should be. Take several steps back, get [some good books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282), take some classes, learn how to use other libraries with your programs. There's just to much wrong with your code for this site to help you with all of them in one go. In short: Start over from the very beginning to learn C++. – Some programmer dude Jun 03 '20 at 13:54
  • @Someprogrammerdude thank for you answer sir, do you meen that it is just impossible to have that syntax working in c ++? – RoseDevStack Jun 03 '20 at 14:36
  • C++ isn't Python. Syntax that works in one language won't work in another. Just like you can't expect Chinese to work in Finland (or Finish to work in China). – Some programmer dude Jun 03 '20 at 15:02
  • What language is this written in? – Hoppo Jun 03 '20 at 15:04
  • @Someprogrammerdude yes you are right but I thought that importing libraries allows you to use this syntax! – RoseDevStack Jun 03 '20 at 15:11
  • @Hoppo thank you so much for your help, I have to completely redo the code – RoseDevStack Jun 04 '20 at 08:59

1 Answers1

0

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

andrei81
  • 68
  • 6
  • Thank you for your answer, I'm using Dev C++, but I will install CodeBlocks and will try to follow the steps you gave me, the code you gave displays only the matrix and does not calculate the dwt, isn't it ? – RoseDevStack Jun 03 '20 at 14:40
  • I think that for this library won't work, because is not for c++. To do that you should use python and I reccomend you to read more about c++, even on internet. – andrei81 Jun 03 '20 at 15:15
  • thank you so much for your help, you are very kind ! – RoseDevStack Jun 04 '20 at 09:01