From: Lucas K Date: Tue, 22 Dec 2020 19:33:26 +0000 (-0800) Subject: added code, README and Makefile X-Git-Url: https://s3miclassical.com/gitweb/?a=commitdiff_plain;h=41acfb8cfb426c10f7a16e8cb04337012b25e3fb;p=strong_simulation_gauss_sum_rank.git added code, README and Makefile --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..676bdcb --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ + +CC=gcc +CFLAGS= +LIBS=-lm + +gausssums_multipleof1: gausssums_multipleof1.c + $(CC) -o $@ gausssums_multipleof1.c $(CFLAGS) $(LIBS) + +gausssums_multipleof2: gausssums_multipleof2.c + $(CC) -o $@ gausssums_multipleof2.c $(CFLAGS) $(LIBS) + +gausssums_multipleof3: gausssums_multipleof3.c + $(CC) -o $@ gausssums_multipleof3.c $(CFLAGS) $(LIBS) + +gausssums_multipleof6: gausssums_multipleof6.c + $(CC) -o $@ gausssums_multipleof6.c $(CFLAGS) $(LIBS) + +gausssums_multipleof12: gausssums_multipleof12.c + $(CC) -o $@ gausssums_multipleof12.c $(CFLAGS) $(LIBS) + +hilbertspace_vector: hilbertspace_vector.c + $(CC) -o $@ hilbertspace_vector.c $(CFLAGS) $(LIBS) + +randommultipleinputPaulis: randommultipleinputPaulis.c + $(CC) -o $@ randommultipleinputPaulis.c $(CFLAGS) $(LIBS) + +.PHONY: clean + +clean: + rm ./gausssums_multipleof1 ./gausssums_multipleof2 ./gausssums_multipleof3 ./gausssums_multipleof6 ./gausssums_multipleof12 ./randommultipleinputPaulis ./hilbertspace_vector + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..b46b4c9 --- /dev/null +++ b/README.txt @@ -0,0 +1,27 @@ +Strong simulation of single-Pauli measurements using Gauss sums +--------------------------------------------------------------- + +BUILD: + +1. Build code for Gauss sum tensor multiple you'd like to use. Here we choose k=6. +$ make gausssums_multipleof6 + +2. Build code for generating random Pauli inputs. +$ make randommultipleinputPaulis + +3. Build Hilbert vector space code to check our results. +$ make hilbertspace_vector + + +TEST CODE: +1. Run test diagonositic +$ bash ./test.bash + + + +Info on source code: +gausssums_multipleof*c need Pauli inputs which can be generated with randommultipleinputPaulis.c. + +NOTE: current gausssums_multipleof*c only support the same number of T gates as number of qubits! + +Output from gausssums_multipleof*c can be verified with hilbertspace_vector.c. diff --git a/gausssums_multipleof1.c b/gausssums_multipleof1.c new file mode 100644 index 0000000..3986ee0 --- /dev/null +++ b/gausssums_multipleof1.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include + +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); +complex double Gausssum1d(int quadraticcoeff, int linearcoeff); +complex double Kroneck(int arg); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int i; + + int N; // number of qubits + scanf("%d", &N); + + int alpha[N], beta[N], gamma[N], delta[N]; + + double complex summand, sum; + + while(readPaulicoeffs(alpha, beta, gamma, delta, N)) { + + // for(i=0; i +#include +#include +#include + +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); +complex double Gausssum1d(int quadraticcoeff, int linearcoeff); +complex double Kroneck(int arg); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int i, j; + int x, y, xp, yp, xpp, ypp, xppp, yppp; + + int N; // number of qubits + scanf("%d", &N); + if(N%12!=0) { + printf("Error: N must be a multiple of 12!\n"); + return 1; + } + + int alpha[N], beta[N], gamma[N], delta[N]; + + double complex summand, sum; + + while(readPaulicoeffs(alpha, beta, gamma, delta, N)) { + + /* for(i=0; i +#include +#include +#include + +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); +complex double Gausssum1d(int quadraticcoeff, int linearcoeff); +complex double Kroneck(int arg); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int i; + + int N; // number of qubits + scanf("%d", &N); + + int alpha[N], beta[N], gamma[N], delta[N]; + + double complex summand, sum; + + while(readPaulicoeffs(alpha, beta, gamma, delta, N)) { + + // for(i=0; i +#include +#include +#include + +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); +complex double Gausssum1d(int quadraticcoeff, int linearcoeff); +complex double Kroneck(int arg); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int i, x, y; + + int N; // number of qubits + scanf("%d", &N); + if(N%3!=0) { + printf("Error: N must be a multiple of 3!\n"); + return 1; + } + + int alpha[N], beta[N], gamma[N], delta[N]; + + double complex summand, sum; + + while(readPaulicoeffs(alpha, beta, gamma, delta, N)) { + + /* for(i=0; i +#include +#include +#include + +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); +complex double Gausssum1d(int quadraticcoeff, int linearcoeff); +complex double Kroneck(int arg); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int i; + int x, y, xp, yp; + + int N; // number of qubits + scanf("%d", &N); + if(N%6!=0) { + printf("Error: N must be a multiple of 6!\n"); + return 1; + } + + int alpha[N], beta[N], gamma[N], delta[N]; + + double complex summand, sum; + + while(readPaulicoeffs(alpha, beta, gamma, delta, N)) { + + /* for(i=0; i +#include +#include +#include + +void deallocate_mem(complex double ***arr, int rows); +void printMatrix(complex double** a, int rows, int cols); +complex double** multMatrix(complex double **A, complex double **B, int ro1, int co1, int ro2, int co2); +complex double** outerMatrix(complex double **A, complex double **B, int ro1, int co1, int ro2, int co2); +complex double** transp(complex double **a, int rows, int cols); +complex double** conjtransp(complex double **a, int rows, int cols); +complex double trace(complex double **a, int rows, int cols); +complex double** scalarmultMatrix(complex double scalar, complex double **a, int rows, int cols); +complex double** addMatrix(complex double **A, complex double **B, int rows, int cols); +int readPaulicoeffs(int* alpha, int* beta, int* gamma, int* delta, int numqubits); + +// order of matrix elements is [row][column]!!! + +static complex double (*(I2[])) = { (double complex[]) {1.0+0.0*I, 0.0+0.0*I}, (double complex[]) {0.0+0.0*I, 1.0+0.0*I} }; +static complex double (*(X[])) = { (double complex[]) {0.0*I, 1.0+0.0*I}, (double complex[]) {1.0+0.0*I, 0.0*I} }; +static complex double (*(Y[])) = { (double complex[]) {0.0*I, 0.0-1.0*I}, (double complex[]) {0.0+1.0*I, 0.0*I} }; +static complex double (*(Z[])) = { (double complex[]) {1.0+0.0*I, 0.0+0.0*I}, (double complex[]) {0.0+0.0*I, -1.0+0.0*I} }; + +int main() +{ + + int i; + + int N; // number of qubits + scanf("%d", &N); + + complex double (*(psi[])) = { (double complex[]) {1.0/sqrt(2.0)}, (double complex[]) {0.5*(1.0+1.0*I)}}; // T gate magic state + + complex double **psiN = psi; + for(i=1; i +#include +#include + +// order of matrix elements is [row][column]!!! + +int main( int argc, char *argv[]) +{ + + if(argc != 4) { + printf("randommultipleinputPaulis arguments: \"number of qubits\" \"number of T gates\" \"number of Paulis\"\n"); + exit(0); + } + + int N = atoi(argv[1]); // number of qubits + int T = atoi(argv[2]); // number of T gate magic states (set to the first 'K' of the 'N' qubits -- the rest are set to the '0' computational basis state) + int numPaulis = atoi(argv[3]); + + printf("%d\n", N); + //printf("%d\n", T); + + int r; + srand((unsigned)time(NULL)); + + + int i, j; + + for(i=0; i