forked from AMSC-24-25/amsc-24-25-classroom-20-fft-FFT
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhaar_wavelet_transform_2d.cpp
More file actions
38 lines (30 loc) · 1.04 KB
/
haar_wavelet_transform_2d.cpp
File metadata and controls
38 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <vector>
#include <random>
#include <cmath>
#include "signal_processing/signal_processing.hpp"
int main() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> power_dist(2, 5); // N = 4 ... 32
std::uniform_real_distribution<> val_dist(-10.0, 10.0);
int N = std::pow(2, power_dist(gen));
std::vector<std::vector<double>> matrix(N, std::vector<double>(N));
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
matrix[i][j] = val_dist(gen);
std::cout << "Input matrix (" << N << "x" << N << "):\n";
for (const auto& row : matrix) {
for (double val : row) std::cout << val << "\t";
std::cout << "\n";
}
sp::hwt::solver::HaarWaveletTransform2D transform(matrix);
transform.compute();
auto result = transform.getSolution();
std::cout << "\nHaar Transform matrix:\n";
for (const auto& row : result) {
for (double val : row) std::cout << val << "\t";
std::cout << "\n";
}
return 0;
}