X-Git-Url: https://s3miclassical.com/gitweb/?p=strong_simulation_stabilizer_rank.git;a=blobdiff_plain;f=strongsim6_relerr.c;fp=strongsim6_relerr.c;h=31bfb1cb9820740fc6936f076b1b978fafb29931;hp=0000000000000000000000000000000000000000;hb=f36d60f8c85e0879a7d2b52e816638d2b4fdf86a;hpb=a85d4d567fc589503c5e263e1520295c8d433a45 diff --git a/strongsim6_relerr.c b/strongsim6_relerr.c new file mode 100644 index 0000000..31bfb1c --- /dev/null +++ b/strongsim6_relerr.c @@ -0,0 +1,432 @@ +#include +#include +#include +#include +#include +#include +#include "matrix.h" +#include "exponentialsum.h" +#include "shrinkstar.h" +#include "extend.h" +#include "measurepauli.h" +#include "innerproduct.h" +#include "randomstabilizerstate.h" + +#define ZEROTHRESHOLD (0.00000001) + +int readPaulicoeffs(int *omega, int *alpha, int *beta, int *gamma, int *delta, int numqubits); + +// order of matrix elements is [row][column]!!! + +int main(int argc, char *argv[]) +{ + + if(argc != 2) { + printf("strongsim6_rellerr argument: \"number of stabilizer state samples\"\n"); + exit(0); + } + + int NUMSTABSTATESAMPLES = atoi(argv[1]); // number of stabilizer state samples + + int N; // number of qubits + scanf("%d", &N); + + if(N%6 != 0) { + printf("'N' needs to be a multiple of 6 for a k=6 tensor factor decomposition!\n"); + return 1; + } + + 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[N]; // max of N measurements + int alpha[N][N], beta[N][N], gamma[N][N], delta[N][N]; // max of N measurements of N Paulis + int Paulicounter = 0; + + int i, j, k, l, m; + + FILE *fp; + char buff[255]; + + srand((unsigned)time(NULL)); // seeding the random number generator for randomstabilizerstate() + + fp = fopen("Pd.txt", "r"); + + if(fscanf(fp, "%s", buff) == EOF) { + printf("Error: Pd.txt should start with the number N of P(d) of values tabulated."); + return 1; + } + + double** Pd; + + int PdN = atoi(buff); + + Pd = calloc(PdN, sizeof(double*)); + for(i=0; i 0) { + J[j] = calloc(K[j], sizeof(int*)); D[j] = calloc(K[j], sizeof(int)); + for(k=0; k 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("%.10lf %c %.10lf I\n", cabs(creal(amplitude)), cimag(amplitude+ZEROTHRESHOLD)>0?'+':'-' , cabs(cimag(amplitude))); + else + printf("%.10lf %c %.10lf I\n", creal(amplitude), cimag(amplitude+ZEROTHRESHOLD)>0?'+':'-' , cabs(cimag(amplitude))); + + + + 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; + +}