-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwavefunction.c
More file actions
41 lines (33 loc) · 844 Bytes
/
Copy pathwavefunction.c
File metadata and controls
41 lines (33 loc) · 844 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
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "error.h"
#include "sbcl_librarian.h"
#include "libquil.h"
void die(char *msg) {
printf("%s\n", msg);
exit(1);
}
int main(int argc, char **argv) {
quil_program program;
if (quilc_parse_quil("X 0; I 1", &program) != LISP_ERR_SUCCESS) {
LIBQUIL_ERROR("failed to parse quil");
exit(1);
}
int wavefunction_len;
double *wavefunction;
int seed = 0;
if (qvm_wavefunction(program, &seed, &wavefunction, &wavefunction_len) !=
LISP_ERR_SUCCESS) {
LIBQUIL_ERROR("failed to call qvm_wavefunction");
exit(1);
}
int n_amplitudes = 4;
for (int i = 0; i < n_amplitudes; i++) {
printf("|%d> = %f + i%f\n", i, wavefunction[i * 2],
wavefunction[i * 2 + 1]);
}
lisp_release_handle(program);
return 0;
}