forked from ProjectQ-Framework/ProjectQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_source_matrix.cpp
More file actions
45 lines (39 loc) · 901 Bytes
/
gen_source_matrix.cpp
File metadata and controls
45 lines (39 loc) · 901 Bytes
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
#include<stdlib.h> //rand,srand
#include<vector>
#include<fstream>
#include <iostream>
#include<complex>
#define SEED 1234
#define FILENAME "source_matrix.txt"
typedef std::complex<float> complex;
#define C(r, i) complex(r, i)
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "Input args wrong. Needs exactly one input arg which is the number of qubit ids" << std::endl;
exit(1);
}
int MATDIM = 1<<atoi(argv[1]);
srand(SEED);
std::ofstream f;
f.open(FILENAME);
for (unsigned long i = 0; i < MATDIM; i++){
for (unsigned long j = 0; j < MATDIM; j++){
float real = ((float) rand() / (RAND_MAX));
float imag = ((float) rand() / (RAND_MAX));
/*
if (i == j) {
real = 1.0f;
imag = 0.0f;
}
else {
real = 0.0f;
imag = 0.0f;
}
*/
complex val = C(real, imag);
f << val << "\n";
}
}
f.close();
return 0;
}