X-Git-Url: https://s3miclassical.com/gitweb/?p=strong_simulation_stabilizer_rank.git;a=blobdiff_plain;f=strongsim1.c;fp=strongsim1.c;h=227779956616e36d8a6f41ced4b199c0031ab8ec;hp=0000000000000000000000000000000000000000;hb=f36d60f8c85e0879a7d2b52e816638d2b4fdf86a;hpb=a85d4d567fc589503c5e263e1520295c8d433a45 diff --git a/strongsim1.c b/strongsim1.c new file mode 100644 index 0000000..2277799 --- /dev/null +++ b/strongsim1.c @@ -0,0 +1,186 @@ +#include +#include +#include +#include +#include +#include "matrix.h" +#include "exponentialsum.h" +#include "shrink.h" +#include "extend.h" +#include "measurepauli.h" +#include "innerproduct.h" + +int readPaulicoeffs(int *omega, int *alpha, int *beta, int *gamma, int *delta, int numqubits); + +// order of matrix elements is [row][column]!!! + +int main() +{ + + int N; // number of qubits + scanf("%d", &N); + + int T; // 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) + scanf("%d", &T); + + int omega; + int alpha[N], beta[N], gamma[N], delta[N]; + int Paulicounter = 0; + + int i, j, k, l; + + + int n1 = 1; int k1 = 0; int (*(G1[])) = { (int[]) {1} }; int (*(GBar1[])) = { (int[]) {1} }; int h1[] = {0}; int Q1 = 0; int D1[] = {0}; int (*(J1[])) = { (int[]) {0} }; + int n2 = 1; int k2 = 0; int (*(G2[])) = { (int[]) {1} }; int (*(GBar2[])) = { (int[]) {1} }; int h2[] = {1}; int Q2 = 0; int D2[] = {0}; int (*(J2[])) = { (int[]) {0} }; + + int *K; int ***G; int ***GBar; int **h; int *Q; int **D; int ***J; + double complex Gamma[(int)pow(2,N)]; // prefactor in front of resultant state + G = calloc(pow(2,N),sizeof(int*)); GBar = calloc(pow(2,N),sizeof(int*)); + h = calloc(pow(2,N),sizeof(int*)); + + J = calloc(pow(2,N),sizeof(int*)); D = calloc(pow(2,N),sizeof(int*)); Q = calloc(pow(2,N),sizeof(int)); + + K = calloc(pow(2,N), sizeof(int)); + + double complex origGamma[(int)pow(2,N)]; + int *origK, *origQ, **origD, ***origJ; + int ***origG, ***origGBar, **origh; + + origG = calloc(pow(2,N),sizeof(int*)); origGBar = calloc(pow(2,N),sizeof(int*)); + origh = calloc(pow(2,N),sizeof(int*)); + + origJ = calloc(pow(2,N),sizeof(int*)); origD = calloc(pow(2,N),sizeof(int*)); origQ = calloc(pow(2,N),sizeof(int)); + + origK = calloc(pow(2,N), sizeof(int)); + + int combination; // a particular combination from the linear combo of stabilizer states making up the tensor factors multiplied together + + + for(j=0; j 0) { + + J[j] = calloc(K[j], sizeof(int*)); D[j] = calloc(K[j], sizeof(int)); + } + + origG[j] = calloc(N, sizeof(int*)); origGBar[j] = calloc(N, sizeof(int*)); + origh[j] = calloc(N, sizeof(int)); + + if(K[j] > 0) { + origJ[j] = calloc(K[j], sizeof(int*)); origD[j] = calloc(K[j], sizeof(int)); + } + + for(k=0; k 0) + J[j] = calloc(K[j], sizeof(int*)); + + origG[j][k] = calloc(N, sizeof(int*)); origGBar[j][k] = calloc(N, sizeof(int*)); + + if(K[j] > 0) + origJ[j] = calloc(K[j], sizeof(int*)); + + h[j][k] = (combination & 0x1)*h2[0] + (~combination & 0x1)*h1[0]; + for(l=0; l N) { + printf("Error: Number of Paulis is greater than N!\n"); + return 1; + } + + // Let's break up the Ys into Xs and Zs in the order Z X, as required to pass to measurepauli() + // Y_i = -I*Z*X + for(i=0; i0) + printf("%lf %c %lf I\n", cabs(creal(amplitude)), cimag(amplitude)>0?'+':'-' , cabs(cimag(amplitude))); + else + printf("%lf %c %lf I\n", creal(amplitude), cimag(amplitude)>0?'+':'-' , cabs(cimag(amplitude))); + + return 0; + +} + + + +int readPaulicoeffs(int *omega, int *alpha, int *beta, int *gamma, int *delta, int numqubits) +{ + + int newomega, newalpha, newbeta, newgamma, newdelta; + int i; + + if(scanf("%d", &newomega) != EOF) { + *omega = newomega; + for(i=0; i 1) { + printf("Error: Too many coefficients are non-zero at Pauli %d!\n", i); + exit(0); + } + alpha[i] = newalpha; beta[i] = newbeta; gamma[i] = newgamma; delta[i] = newdelta; + } + return 1; + } else + return 0; + +} + + + + + + +