-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.cpp
65 lines (57 loc) · 1.17 KB
/
matrix.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* matrix.cpp */
#include "matrix.h"
#include "iostream"
#include "fstream"
#include <cstdio>
#include <cmath>
#include "image2D.h"
#include "complex"
#include <iterator>
void test1() {
typedef complex<int> cx;
Matrix<double> C(4,1);
for (int i=0; i<4; i++) C(i) = i;
Matrix< complex<double> > D = fft(C);
Matrix< complex<double> > E = ifft(D);
cout << C << endl;
cout << D << endl;
cout << E << endl;
}
void test2() {
typedef complex<int> cx;
ifstream ifs("dat");
Matrix<double> C(ifs);
ifs.close();
cout << C << endl;
cout << fft(C) << endl;
cout << fft(fft(C),-1) << endl;
}
void test3() {
bool a[] = { 0, 1, 0, 1, 0, 0, 1, 1, 1 };
Matrix<bool> A(a, 3,3);
bool b[] = { 0, 0, 0, 0, 1, 0, 0, 1, 0 };
Matrix<bool> B(b, 3,3);
Matrix<bool> C = erosion(A, B);
cout << A << endl;
cout << B << endl;
cout << C << endl;
bool x = 0;
bool y = 1;
bool z = x && y;
cout << z;
}
void test4() {
double a[] = { 25.5, 1, 5, 50, 80, 100, 0, 3, 200 };
Matrix<double> A(a, 3,3);
//savePNM(A, "test.pgm", true);
cout << A << endl;
Matrix<int> B = A;
cout << B << endl;
}
int main(int argc, char* argv[]) {
//test1();
//test2();
//test3();
test4();
return 0;
}