added code, README and Makefile
authorLucas K <lkocia@s3miclassical.com>
Tue, 22 Dec 2020 19:33:26 +0000 (11:33 -0800)
committerLucas K <lkocia@s3miclassical.com>
Tue, 22 Dec 2020 19:33:26 +0000 (11:33 -0800)
Makefile [new file with mode: 0644]
README.txt [new file with mode: 0644]
gausssums_multipleof1.c [new file with mode: 0644]
gausssums_multipleof12.c [new file with mode: 0644]
gausssums_multipleof2.c [new file with mode: 0644]
gausssums_multipleof3.c [new file with mode: 0644]
gausssums_multipleof6.c [new file with mode: 0644]
hilbertspace_vector.c [new file with mode: 0644]
randommultipleinputPaulis.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0000000..b46b4c9
--- /dev/null
@@ -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 (file)
index 0000000..3986ee0
--- /dev/null
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++)
+    //      printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]);
+
+    sum = 1.0 + 0.0*I;
+
+    for(i=0; i<N; i++) {
+      summand = 0.0*I;
+      summand += 0.5*(Kroneck(gamma[i]+delta[i]) + pow(-1,beta[i])*Kroneck(gamma[i]+delta[i])
+                          +csqrt(I)*cpow(-I,delta[i])*Kroneck(alpha[i]+beta[i]) + csqrt(-I)*cpow(I,delta[i])*Kroneck(alpha[i]+beta[i]));
+      sum *= summand;
+    }
+    //printf("%lf+%lfI\n", creal(sum), cimag(sum));
+    printf("%lf\n", cabs(creal(sum))); 
+
+
+  }
+
+  return 0;
+}
+
+complex double Kroneck(int arg)
+{
+  arg = (arg+1)%2; // output 1 if argument is 0 mod 2 and 0 otherwise
+  return ((complex double)arg);
+}
+
+complex double Gausssum1d(int quadraticcoeff, int linearcoeff)
+{
+  // we assume coeffs are either 0 or 1
+  quadraticcoeff %= 2;
+  linearcoeff %= 2;
+    
+  if(quadraticcoeff == 0)
+    if(linearcoeff == 0)
+      return 2.0+0.0*I;
+    else
+      return 0.0*I;
+  else
+    if(linearcoeff == 0)
+      return 1.0+1.0*I;
+    else
+      return 1.0-1.0*I;
+
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/gausssums_multipleof12.c b/gausssums_multipleof12.c
new file mode 100644 (file)
index 0000000..adcdf64
--- /dev/null
@@ -0,0 +1,1344 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++) */
+    /*   printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]); */
+
+    sum = 1.0+0.0*I;
+    for(i=0; i<N; i+=12) {
+      summand = 0.0*I;
+
+      j = i + 6; // index of second tensored primitive t=6
+      
+      
+      // first term
+      for(y=0; y<=1; y++) {
+       //**for(x=0;x<=(y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+       for(x=y*(beta[i]+alpha[i+1]+beta[i+1])%2;x<=(y*(beta[i]+alpha[i+1]+beta[i+1])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+         for(yp=((gamma[i+3]+delta[i+4])*x)%2; yp<=(1+(gamma[i+3]+gamma[i+4])*x)%2; yp++) {
+         //****for(yp=((gamma[i+3]+delta[i+4])*x*(1+alpha[i]+beta[i]))%2; yp<=(1+(gamma[i+3]+gamma[i+4])*x*(1+alpha[i]+beta[i]))%2; yp++) {
+           //**for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+
+             
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=((gamma[j]+delta[j+1])*(x+xp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x+xp))%2;ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(x+xp+xpp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x+xp+xpp))%2; yppp++) {
+                   //****for(yppp=((gamma[j+3]+delta[j+4])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                          //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                          + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                                   + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(x+xp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x+xp))%2;ypp++) {
+             //****for(ypp=((gamma[j]+delta[j+1])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=xpp; yppp<=1; yppp++) {
+                 //**for(yppp=(x+xp+xpp)%2; yppp<=1; yppp++) {
+                 for(yppp=(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j]))%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+(x+xp+xpp))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(x+xp+xpp))%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; xppp++) {
+                     //summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                          //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                          + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(x+xp)%2; ypp<=1; ypp++) {
+             for(ypp=(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+x+xp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x+xp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(x+xp+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x+xp+ypp))%2; yppp++) {
+                 //****for(yppp=((gamma[j+3]+delta[j+4])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+ypp))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                          + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                                   + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(x+xp)%2; ypp<=1; ypp++) {
+             for(ypp=(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+x+xp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x+xp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp++) {
+                 //for(yppp=ypp; yppp<=1; yppp++) {
+                 //**for(yppp=(x+xp+ypp)%2; yppp<=1; yppp++) {
+                 for(yppp=(x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+x+xp+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+x+xp+ypp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+x*(1+alpha[i]+beta[i])+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+      
+      
+      // second term
+      for(y=0; y<=1; y++) {
+       //**for(x=0;x<=(y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+       for(x=y*(beta[i]+alpha[i+1]+beta[i+1])%2;x<=(y*(beta[i]+alpha[i+1]+beta[i+1])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                             + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 //**for(yppp=xpp; yppp<=1; yppp++) {
+                 for(yppp=xpp*(1+alpha[j]+beta[j])%2; yppp<=1; yppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp*(1+alpha[j]+beta[j]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp*(1+alpha[j]+beta[j]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                     + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=ypp; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                     summand += ((0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+      
+      // third term
+      for(y=0; y<=1; y++) {
+       //**for(x=0;x<=(y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+       for(x=y*(beta[i]+alpha[i+1]+beta[i+1])%2;x<=(y*(beta[i]+alpha[i+1]+beta[i+1])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+         //**for(yp=x; yp<=1; yp++) {
+         for(yp=x*(1+alpha[i]+beta[i])%2; yp<=1; yp++) {
+           //**for(xp=(yp*(delta[i+3]+delta[i+4])+x)%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+x)%2; xp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4])+x*(1+alpha[i]+beta[i]))%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+x*(1+alpha[i]+beta[i]))%2; xp++) {
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(x+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x+yp))%2;ypp++) {
+             //****for(ypp=((gamma[j]+delta[j+1])*(x*(1+alpha[i]+beta[i])+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x*(1+alpha[i]+beta[i])+yp))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(x+yp+xpp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x+yp+xpp))%2; yppp++) {
+                 //****for(yppp=((gamma[j+3]+delta[j+4])*(x*(1+alpha[i]+beta[i])+yp+xpp*(1+alpha[j]+beta[j])))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x*(1+alpha[i]+beta[i])+yp+xpp*(1+alpha[j]+beta[j])))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                             + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(x+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x+yp))%2;ypp++) {
+             //****for(ypp=((gamma[j]+delta[j+1])*(x*(1+alpha[i]+beta[i])+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(x*(1+alpha[i]+beta[i])+yp))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=xpp; yppp<=1; yppp++) {
+                 //**for(yppp=(x+yp+xpp)%2; yppp<=1; yppp++) {
+                 for(yppp=(x*(1+alpha[i]+beta[i])+yp+xpp*(1+alpha[j]+beta[j]))%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+(x+yp+xpp))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(x+yp+xpp))%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+(x*(1+alpha[i]+beta[i])+yp+xpp*(1+alpha[j]+beta[j])))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(x*(1+alpha[i]+beta[i])+yp+xpp*(1+alpha[j]+beta[j])))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                          + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(x+yp)%2; ypp<=1; ypp++) {
+             for(ypp=(x*(1+alpha[i]+beta[i])+yp)%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+x+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x+yp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+x*(1+alpha[i]+beta[i])+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x*(1+alpha[i]+beta[i])+yp)%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(x+yp+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x+yp+ypp))%2; yppp++) {
+                 //****for(yppp=((gamma[j+3]+delta[j+4])*(x*(1+alpha[i]+beta[i])+yp+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(x*(1+alpha[i]+beta[i])+yp+ypp))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(x+yp)%2; ypp<=1; ypp++) {
+             for(ypp=(x*(1+alpha[i]+beta[i])+yp)%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+x+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x+yp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+x*(1+alpha[i]+beta[i])+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+x*(1+alpha[i]+beta[i])+yp)%2; xpp++) {
+                 //for(yppp=ypp; yppp<=1; yppp++) {
+                 //**for(yppp=(x+yp+ypp)%2; yppp<=1; yppp++) {
+                 for(yppp=(x*(1+alpha[i]+beta[i])+yp+ypp)%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+x+yp+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+x+yp+ypp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+x*(1+alpha[i]+beta[i])+yp+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+x*(1+alpha[i]+beta[i])+yp+ypp)%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                                      //+ 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                      + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+      
+      
+      // fourth term
+      for(y=0; y<=(1+alpha[i+2])%2; y++) {
+       for(x=0; x<=(1+beta[i+2])%2; x++) {
+         for(yp=0; yp<=1; yp++) {
+           //**for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                             + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 //**for(yppp=xpp; yppp<=1; yppp++) {
+                 for(yppp=xpp*(1+alpha[j]+beta[j])%2; yppp<=1; yppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp*(1+alpha[j]+beta[j]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp*(1+alpha[j]+beta[j]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                     + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=ypp; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+
+      // fifth term
+      for(y=0; y<=(1+alpha[i+2])%2; y++) {
+       for(x=0; x<=(1+beta[i+2])%2; x++) {
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                             + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 //**for(yppp=xpp; yppp<=1; yppp++) {
+                 for(yppp=xpp*(1+alpha[j]+beta[j])%2; yppp<=1; yppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp*(1+alpha[j]+beta[j]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp*(1+alpha[j]+beta[j]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                     + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=ypp; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+      
+      // sixth term
+      for(y=0; y<=(1+alpha[i+2])%2; y++) {
+       for(x=0; x<=(1+beta[i+2])%2; x++) {
+         for(yp=0; yp<=1; yp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4]))%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4]))%2; xp++) {
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                             + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 //**for(yppp=xpp; yppp<=1; yppp++) {
+                 for(yppp=xpp*(1+alpha[j]+beta[j])%2; yppp<=1; yppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp*(1+alpha[j]+beta[j]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp*(1+alpha[j]+beta[j]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                     + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=ypp; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                     summand += ((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+                                 *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+      
+      // seventh term
+      for(y=0; y<=1; y++) {
+       for(x=(y*(delta[i]+delta[i+1]))%2; x<=(1+y*(gamma[i]+gamma[i+1]))%2; x++) {
+         for(yp=((gamma[i+3]+delta[i+4])*y)%2; yp<=(1+(gamma[i+3]+gamma[i+4])*y)%2; yp++) {
+           //**for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(y+xp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+xp))%2;ypp++) {
+               //****for(ypp=((gamma[j]+delta[j+1])*(y+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(y+xp+xpp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+xp+xpp))%2; yppp++) {
+                 //****for(yppp=((gamma[j+3]+delta[j+4])*(y+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                             + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(y+xp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+xp))%2;ypp++) {
+             //****for(ypp=((gamma[j]+delta[j+1])*(y+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+xp*(1+alpha[i+3]+beta[i+3])))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=xpp; yppp<=1; yppp++) {
+                 //**for(yppp=(y+xp+xpp)%2; yppp<=1; yppp++) {
+                 for(yppp=(y+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j]))%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+(y+xp+xpp))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(y+xp+xpp))%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+(y+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(y+xp*(1+alpha[i+3]+beta[i+3])+xpp*(1+alpha[j]+beta[j])))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(y+xp)%2; ypp<=1; ypp++) {
+             for(ypp=(y+xp*(1+alpha[i+3]+beta[i+3]))%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+y+xp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+xp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+y+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(y+xp+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+xp+ypp))%2; yppp++) {
+                   //****for(yppp=((gamma[j+3]+delta[j+4])*(y+xp*(1+alpha[i+3]+beta[i+3])+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+xp*(1+alpha[i+3]+beta[i+3])+ypp))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             //**for(ypp=(y+xp)%2; ypp<=1; ypp++) {
+             for(ypp=(y+xp*(1+alpha[i+3]+beta[i+3]))%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               //**for(xpp=(ypp*(delta[j]+delta[j+1])+y+xp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+xp)%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+y+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+xp*(1+alpha[i+3]+beta[i+3]))%2; xpp++) {
+                 //for(yppp=ypp; yppp<=1; yppp++) {
+                 //**for(yppp=(y+xp+ypp)%2; yppp<=1; yppp++) {
+                 for(yppp=(y+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+y+xp+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+y+xp+ypp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+y+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+y+xp*(1+alpha[i+3]+beta[i+3])+ypp)%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+      
+      // eighth term
+      for(y=0; y<=1; y++) {
+       for(x=(y*(delta[i]+delta[i+1]))%2; x<=(1+y*(gamma[i]+gamma[i+1]))%2; x++) {
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                             + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 //**for(yppp=xpp; yppp<=1; yppp++) {
+                 for(yppp=xpp*(1+alpha[j]+beta[j])%2; yppp<=1; yppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp*(1+alpha[j]+beta[j]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp*(1+alpha[j]+beta[j]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                     + 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=ypp; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                     summand += ((0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5])))
+                       *(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+
+
+      // ninth term
+      for(y=0; y<=1; y++) {
+       for(x=(y*(delta[i]+delta[i+1]))%2; x<=(1+y*(gamma[i]+gamma[i+1]))%2; x++) {
+         for(yp=y; yp<=1; yp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4])+y)%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+y)%2; xp++) {
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(y+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+yp))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*xpp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*xpp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(y+yp+xpp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+yp+xpp))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                         + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                                 + 0.125*pow(2.0,1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=((gamma[j]+delta[j+1])*(y+yp))%2;ypp<=(1+(gamma[j]+gamma[j+1])*(y+yp))%2;ypp++) {
+               //**for(xpp=0;xpp<=(ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+               for(xpp=ypp*(beta[j]+alpha[j+1]+beta[j+1])%2;xpp<=(ypp*(beta[j]+alpha[j+1]+beta[j+1])+ypp*(gamma[j]+gamma[j+1])+(ypp+1)*(gamma[j]+delta[j+1]))%2; xpp++) {
+                 //for(yppp=xpp; yppp<=1; yppp++) {
+                 //**for(yppp=(y+yp+xpp)%2; yppp<=1; yppp++) {
+                 for(yppp=(y+yp+xpp*(1+alpha[j]+beta[j]))%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+xpp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+xpp)%2; xppp++) {
+                   //**for(xppp=(yppp*(delta[j+3]+delta[j+4])+(y+yp+xpp))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(y+yp+xpp))%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+(y+yp+xpp*(1+alpha[j]+beta[j])))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+(y+yp+xpp*(1+alpha[j]+beta[j])))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                       *(2.0*(0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*Gausssum1d(0.0,beta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(gamma[j+2]+delta[j+2]) 
+                              //+ 0.125*pow(2.0,(1-ypp*pow(gamma[j]-gamma[j+1],2)-pow(ypp-1,2)*pow(gamma[j]-delta[j+1],2))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                              + 0.125*cexp(M_PI*I/2.0*((delta[j+1]-gamma[j])*pow(ypp+1,2)+2.0*(beta[j]+beta[j+1]+gamma[j]+delta[j+1])*xpp*pow(ypp+1,2)+2.0*(delta[j]+delta[j+1]+beta[j]+beta[j+1])*xpp*ypp+(2.0*beta[j]+3.0*delta[j]+delta[j+1])*ypp))*csqrt(-I)*Gausssum1d(gamma[j+2]+delta[j+2],0)*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1])*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             for(ypp=0; ypp<=(1+alpha[j+2])%2; ypp++) {
+               for(xpp=0; xpp<=(1+beta[j+2])%2; xpp++) {
+                 for(yppp=0; yppp<=1; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*pow(2.0,1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2))*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+                 for(yppp=0; yppp<=1; yppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4]))%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4]))%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+2]*ypp+pow(xpp+1,2)*(delta[j]+gamma[j+1]+2.0*beta[j+1])+xpp*(delta[j]+delta[j+1])))*Gausssum1d(1,beta[j]+beta[j+1]+delta[j]+(xpp+1)*gamma[j+1]+xpp*delta[j+1])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(gamma[j+2]+delta[j+2]))
+                         *(0.125*(-I)*pow(2.0,(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=(y+yp)%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+y+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+yp)%2; xpp++) {
+                 //for(yppp=((gamma[j+3]+delta[j+4])*ypp)%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*ypp)%2; yppp++) {
+                 for(yppp=((gamma[j+3]+delta[j+4])*(y+yp+ypp))%2; yppp<=(1+(gamma[j+3]+gamma[j+4])*(y+yp+ypp))%2; yppp++) {
+                   //**for(xppp=0;xppp<=(yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                   for(xppp=yppp*(beta[j+3]+alpha[j+4]+beta[j+4])%2;xppp<=(yppp*(beta[j+3]+alpha[j+4]+beta[j+4])+yppp*(gamma[j+3]+gamma[j+4])+(yppp+1)*(gamma[j+3]+delta[j+4]))%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(1-yppp*pow(gamma[j+3]-gamma[j+4],2)-pow(yppp-1,2)*pow(gamma[j+3]-delta[j+4],2)))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*Gausssum1d(0.0,beta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(gamma[j+5]+delta[j+5]) 
+                           + 0.125*cexp(M_PI*I/2.0*((delta[j+4]-gamma[j+3])*pow(yppp+1,2)+2.0*(beta[j+3]+beta[j+4]+gamma[j+3]+delta[j+4])*xppp*pow(yppp+1,2)+2.0*(delta[j+3]+delta[j+4]+beta[j+3]+beta[j+4])*xppp*yppp+(2.0*beta[j+3]+3.0*delta[j+3]+delta[j+4])*yppp))*csqrt(-I)*Gausssum1d(gamma[j+5]+delta[j+5],0)*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4])*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+             for(ypp=0; ypp<=1; ypp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+                 for(yppp=0; yppp<=(1+alpha[j+5])%2; yppp++) {
+                   for(xppp=0;xppp<=(1+beta[j+5])%2; xppp++) {
+                     summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       *((0.125*pow(2.0,pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[j+5]*yppp+pow(xppp+1,2)*(delta[j+3]+gamma[j+4]+2.0*beta[j+4])+xppp*(delta[j+3]+delta[j+4])))*Gausssum1d(1,beta[j+3]+beta[j+4]+delta[j+3]+(xppp+1)*gamma[j+4]+xppp*delta[j+4])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(gamma[j+5]+delta[j+5])));
+                   }
+                 }
+               }
+             }
+             //for(ypp=0; ypp<=1; ypp++) {
+             for(ypp=(y+yp)%2; ypp<=1; ypp++) {
+               //for(xpp=(ypp*(delta[j]+delta[j+1]))%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1]))%2; xpp++) {
+               for(xpp=(ypp*(delta[j]+delta[j+1])+y+yp)%2; xpp<=(1+ypp*(gamma[j]+gamma[j+1])+y+yp)%2; xpp++) {
+                 //for(yppp=ypp; yppp<=1; yppp++) {
+                 for(yppp=(y+yp+ypp)%2; yppp<=1; yppp++) {
+                   //for(xppp=(yppp*(delta[j+3]+delta[j+4])+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+ypp)%2; xppp++) {
+                   for(xppp=(yppp*(delta[j+3]+delta[j+4])+y+yp+ypp)%2;xppp<=(1+yppp*(gamma[j+3]+gamma[j+4])+y+yp+ypp)%2; xppp++) {
+                     //summand += (2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                     summand += 2.0*(2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3])))*(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+                                 *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5])))
+                       //*(2.0*(0.125*pow(2.0,(pow(ypp-1,2)*(pow(xpp,2)*(gamma[j]+delta[j+1])+pow(xpp-1,2)*(gamma[j+1]+delta[j])))*(pow(yppp-1,2)*(pow(xppp,2)*(gamma[j+3]+delta[j+4])+pow(xppp-1,2)*(gamma[j+4]+delta[j+3]))))*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                       *(2.0*(0.125*(-I)*cexp(M_PI*I/2.0*(ypp*(delta[j]+delta[j+1])+pow(ypp+1,2)*(delta[j]+gamma[j+1]+2*beta[j+1])+pow(xpp,2)+2*(beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp)*xpp))*Gausssum1d(0,xpp+beta[j]+beta[j+1]+delta[j]+gamma[j+1]*(ypp+1)+delta[j+1]*ypp+gamma[j+2]+delta[j+2])*Kroneck(gamma[j]+delta[j]-gamma[j+1]-delta[j+1]+1)*Kroneck(alpha[j+2]+beta[j+2]))
+                         *(0.125*(-I)*cexp(M_PI*I/2.0*(yppp*(delta[j+3]+delta[j+4])+pow(yppp+1,2)*(delta[j+3]+gamma[j+4]+2*beta[j+4])+pow(xppp,2)+2*(beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp)*xppp))*Gausssum1d(0,xppp+beta[j+3]+beta[j+4]+delta[j+3]+gamma[j+4]*(yppp+1)+delta[j+4]*yppp+gamma[j+5]+delta[j+5])*Kroneck(gamma[j+3]+delta[j+3]-gamma[j+4]-delta[j+4]+1)*Kroneck(alpha[j+5]+beta[j+5])));
+                   }
+                 }
+               }
+             }
+           }
+         }
+       }
+      }
+      
+      
+      sum *= summand;
+    }
+    //printf("%lf+%lfI\n", creal(sum), cimag(sum));
+    printf("%lf\n", cabs(creal(sum))); 
+
+
+  }
+
+  return 0;
+}
+
+complex double Kroneck(int arg)
+{
+  arg = (arg+1)%2; // output 1 if argument is 0 mod 2 and 0 otherwise
+  return ((complex double)arg);
+}
+
+complex double Gausssum1d(int quadraticcoeff, int linearcoeff)
+{
+  /*****************************************
+  /* NOTE! we assume coeffs are either 0 or 1
+  /* (So you cannot pass off a linear coeff as a quadratic coeff by multiplying it by a factor of 2 (and considering it as mod 4)!)
+  *****************************************/
+  
+  quadraticcoeff %= 2;
+  linearcoeff %= 2;
+    
+  if(quadraticcoeff == 0)
+    if(linearcoeff == 0)
+      return 2.0+0.0*I;
+    else
+      return 0.0*I;
+  else
+    if(linearcoeff == 0)
+      return 1.0+1.0*I;
+    else
+      return 1.0-1.0*I;
+
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/gausssums_multipleof2.c b/gausssums_multipleof2.c
new file mode 100644 (file)
index 0000000..2098e23
--- /dev/null
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++)
+    //      printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]);
+
+    sum = 1.0 + 0.0*I;
+
+    for(i=0; i<N; i+=2) {
+      summand = 0.0*I;
+      summand += 0.25*((cpow(I,delta[i+1]-gamma[i])*Gausssum1d(0,beta[i]+beta[i+1]+gamma[i]+delta[i+1])
+                   +cpow(-1.0,beta[i]+delta[i])*cpow(I,delta[i]+delta[i+1])*Gausssum1d(0,beta[i]+beta[i+1]+delta[i]+delta[i+1]))
+                  *Kroneck(gamma[i]+delta[i]+gamma[i+1]+delta[i+1])
+                  +(csqrt(-I)*cpow(I,delta[i]+delta[i+1])*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+delta[i+1])
+                    +csqrt(I)*cpow(-1.0,beta[i+1]+gamma[i+1])*cpow(I,delta[i]-gamma[i+1])*(-I)*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+gamma[i+1]))
+                  *Kroneck(gamma[i]+delta[i]+gamma[i+1]+delta[i+1]+1));
+      sum *= summand;
+    }
+    //printf("%lf+%lfI\n", creal(sum), cimag(sum));
+    printf("%lf\n", cabs(creal(sum))); 
+
+
+  }
+
+  return 0;
+}
+
+complex double Kroneck(int arg)
+{
+  arg = (arg+1)%2; // output 1 if argument is 0 mod 2 and 0 otherwise
+  return ((complex double)arg);
+}
+
+complex double Gausssum1d(int quadraticcoeff, int linearcoeff)
+{
+  // we assume coeffs are either 0 or 1
+  quadraticcoeff %= 2;
+  linearcoeff %= 2;
+    
+  if(quadraticcoeff == 0)
+    if(linearcoeff == 0)
+      return 2.0+0.0*I;
+    else
+      return 0.0*I;
+  else
+    if(linearcoeff == 0)
+      return 1.0+1.0*I;
+    else
+      return 1.0-1.0*I;
+
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/gausssums_multipleof3.c b/gausssums_multipleof3.c
new file mode 100644 (file)
index 0000000..5cba378
--- /dev/null
@@ -0,0 +1,113 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++) */
+    /*   printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]); */
+
+    sum = 1.0+0.0*I;
+    for(i=0; i<N; i+=3) {
+      summand = 0.0*I;
+      for(y=0; y<=1; y++) {
+       //for(x=0;x<=(y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+       for(x=y*(beta[i]+alpha[i+1]+beta[i+1])%2;x<=(y*(beta[i]+alpha[i+1]+beta[i+1])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+         summand += 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]);
+         summand += 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]);
+         //summand += 0.125*pow(2.0,gamma[i]+delta[i]+x*y*(beta[i]+alpha[i])*alpha[i+1]+pow(x-1,2)*y*(alpha[i]+beta[i])*beta[i+1]-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]);
+         //}
+       //for(x=((y+1)*(alpha[i]+beta[i]))%2;x<=((beta[i]+alpha[i])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {              
+         //summand += 0.125*pow(2.0,gamma[i]+delta[i]+x*y*(beta[i]+alpha[i])*alpha[i+1]+pow(x-1,2)*y*(alpha[i]+beta[i])*beta[i+1]-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]);         
+       }
+      }
+      for(y=0; y<=(1+alpha[i+2])%2; y++) {
+       for(x=0;x<=(1+beta[i+2])%2; x++) {
+         summand += 0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]);
+       }
+      }
+      for(y=0; y<=1; y++) {
+       for(x=(y*(delta[i]+delta[i+1]))%2;x<=(1+y*(gamma[i]+gamma[i+1]))%2; x++) {
+         summand += 0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]);
+       }
+      }
+      sum *= summand;
+    }
+    //printf("%lf+%lfI\n", creal(sum), cimag(sum));
+    printf("%lf\n", cabs(creal(sum))); 
+
+
+  }
+
+  return 0;
+}
+
+complex double Kroneck(int arg)
+{
+  arg = (arg+1)%2; // output 1 if argument is 0 mod 2 and 0 otherwise
+  return ((complex double)arg);
+}
+
+complex double Gausssum1d(int quadraticcoeff, int linearcoeff)
+{
+  /*****************************************
+  /* NOTE! we assume coeffs are either 0 or 1
+  /* (So you cannot pass off a linear coeff as a quadratic coeff by multiplying it by a factor of 2 (and considering it as mod 4)!)
+  *****************************************/
+  
+  quadraticcoeff %= 2;
+  linearcoeff %= 2;
+    
+  if(quadraticcoeff == 0)
+    if(linearcoeff == 0)
+      return 2.0+0.0*I;
+    else
+      return 0.0*I;
+  else
+    if(linearcoeff == 0)
+      return 1.0+1.0*I;
+    else
+      return 1.0-1.0*I;
+
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/gausssums_multipleof6.c b/gausssums_multipleof6.c
new file mode 100644 (file)
index 0000000..b86aa4b
--- /dev/null
@@ -0,0 +1,176 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++) */
+    /*   printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]); */
+
+    sum = 1.0+0.0*I;
+    for(i=0; i<N; i+=6) {
+      summand = 0.0*I;
+      for(y=0; y<=1; y++) {
+       //for(x=0;x<=(y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+       for(x=y*(beta[i]+alpha[i+1]+beta[i+1])%2;x<=(y*(beta[i]+alpha[i+1]+beta[i+1])+y*(gamma[i]+gamma[i+1])+(y+1)*(gamma[i]+delta[i+1]))%2; x++) {
+         for(yp=((gamma[i+3]+delta[i+4])*x)%2; yp<=(1+(gamma[i+3]+gamma[i+4])*x)%2; yp++) {
+           //strange that I don't need the following modification to x
+         //****for(yp=((gamma[i+3]+delta[i+4])*x*(1+alpha[i]+beta[i]))%2; yp<=(1+(gamma[i+3]+gamma[i+4])*x*(1+alpha[i]+beta[i]))%2; yp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+         //for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             summand += 2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                             + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             summand += (0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5]));
+           }
+         }
+         //for(yp=x; yp<=1; yp++) {
+         for(yp=x*(1+alpha[i]+beta[i])%2; yp<=1; yp++) {
+           //for(xp=(yp*(delta[i+3]+delta[i+4])+x)%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+x)%2; xp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4])+x*(1+alpha[i]+beta[i]))%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+x*(1+alpha[i]+beta[i]))%2; xp++) {
+             summand += 2.0*(0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*Gausssum1d(0.0,beta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(gamma[i+2]+delta[i+2]) 
+                         + 0.125*pow(2.0,(1-y*pow(gamma[i]-gamma[i+1],2)-pow(y-1,2)*pow(gamma[i]-delta[i+1],2))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*((delta[i+1]-gamma[i])*pow(y+1,2)+2.0*(beta[i]+beta[i+1]+gamma[i]+delta[i+1])*x*pow(y+1,2)+2.0*(delta[i]+delta[i+1]+beta[i]+beta[i+1])*x*y+(2.0*beta[i]+3.0*delta[i]+delta[i+1])*y))*csqrt(-I)*Gausssum1d(gamma[i+2]+delta[i+2],0)*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1])*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+       }
+      }
+
+      for(y=0; y<=(1+alpha[i+2])%2; y++) {
+       for(x=0; x<=(1+beta[i+2])%2; x++) {
+         for(yp=0; yp<=1; yp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             //for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             summand += (0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*pow(2.0,1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2))*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             summand += (0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5]));
+           }
+         }
+         for(yp=0; yp<=1; yp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4]))%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4]))%2; xp++) {
+             summand += (0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+2]*y+pow(x+1,2)*(delta[i]+gamma[i+1]+2.0*beta[i+1])+x*(delta[i]+delta[i+1])))*Gausssum1d(1,beta[i]+beta[i+1]+delta[i]+(x+1)*gamma[i+1]+x*delta[i+1])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(gamma[i+2]+delta[i+2]))
+               *(0.125*(-I)*pow(2.0,(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+       }
+      }
+
+      for(y=0; y<=1; y++) {
+       for(x=(y*(delta[i]+delta[i+1]))%2; x<=(1+y*(gamma[i]+gamma[i+1]))%2; x++) {
+         for(yp=((gamma[i+3]+delta[i+4])*y)%2; yp<=(1+(gamma[i+3]+gamma[i+4])*y)%2; yp++) {
+           for(xp=yp*(beta[i+3]+alpha[i+4]+beta[i+4])%2;xp<=(yp*(beta[i+3]+alpha[i+4]+beta[i+4])+yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             //for(xp=0;xp<=(yp*(gamma[i+3]+gamma[i+4])+(yp+1)*(gamma[i+3]+delta[i+4]))%2; xp++) {
+             summand += 2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(1-yp*pow(gamma[i+3]-gamma[i+4],2)-pow(yp-1,2)*pow(gamma[i+3]-delta[i+4],2)))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*Gausssum1d(0.0,beta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(gamma[i+5]+delta[i+5]) 
+                 + 0.125*cexp(M_PI*I/2.0*((delta[i+4]-gamma[i+3])*pow(yp+1,2)+2.0*(beta[i+3]+beta[i+4]+gamma[i+3]+delta[i+4])*xp*pow(yp+1,2)+2.0*(delta[i+3]+delta[i+4]+beta[i+3]+beta[i+4])*xp*yp+(2.0*beta[i+3]+3.0*delta[i+3]+delta[i+4])*yp))*csqrt(-I)*Gausssum1d(gamma[i+5]+delta[i+5],0)*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4])*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+         for(yp=0; yp<=(1+alpha[i+5])%2; yp++) {
+           for(xp=0;xp<=(1+beta[i+5])%2; xp++) {
+             summand += (0.125*pow(2.0,pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*2.0*csqrt(-I)*cexp(M_PI*I/2.0*(2.0*beta[i+5]*yp+pow(xp+1,2)*(delta[i+3]+gamma[i+4]+2.0*beta[i+4])+xp*(delta[i+3]+delta[i+4])))*Gausssum1d(1,beta[i+3]+beta[i+4]+delta[i+3]+(xp+1)*gamma[i+4]+xp*delta[i+4])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(gamma[i+5]+delta[i+5]));
+           }
+         }
+         for(yp=y; yp<=1; yp++) {
+           for(xp=(yp*(delta[i+3]+delta[i+4])+y)%2;xp<=(1+yp*(gamma[i+3]+gamma[i+4])+y)%2; xp++) {
+             summand += 2.0*(0.125*pow(2.0,(pow(y-1,2)*(pow(x,2)*(gamma[i]+delta[i+1])+pow(x-1,2)*(gamma[i+1]+delta[i])))*(pow(yp-1,2)*(pow(xp,2)*(gamma[i+3]+delta[i+4])+pow(xp-1,2)*(gamma[i+4]+delta[i+3]))))*(-I)*cexp(M_PI*I/2.0*(y*(delta[i]+delta[i+1])+pow(y+1,2)*(delta[i]+gamma[i+1]+2*beta[i+1])+pow(x,2)+2*(beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y)*x))*Gausssum1d(0,x+beta[i]+beta[i+1]+delta[i]+gamma[i+1]*(y+1)+delta[i+1]*y+gamma[i+2]+delta[i+2])*Kroneck(gamma[i]+delta[i]-gamma[i+1]-delta[i+1]+1)*Kroneck(alpha[i+2]+beta[i+2]))
+               *(0.125*(-I)*cexp(M_PI*I/2.0*(yp*(delta[i+3]+delta[i+4])+pow(yp+1,2)*(delta[i+3]+gamma[i+4]+2*beta[i+4])+pow(xp,2)+2*(beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp)*xp))*Gausssum1d(0,xp+beta[i+3]+beta[i+4]+delta[i+3]+gamma[i+4]*(yp+1)+delta[i+4]*yp+gamma[i+5]+delta[i+5])*Kroneck(gamma[i+3]+delta[i+3]-gamma[i+4]-delta[i+4]+1)*Kroneck(alpha[i+5]+beta[i+5]));
+           }
+         }
+       }
+      }
+
+      sum *= summand;
+    }
+    //printf("%lf+%lfI\n", creal(sum), cimag(sum));
+    printf("%lf\n", cabs(creal(sum))); 
+
+
+  }
+
+  return 0;
+}
+
+complex double Kroneck(int arg)
+{
+  arg = (arg+1)%2; // output 1 if argument is 0 mod 2 and 0 otherwise
+  return ((complex double)arg);
+}
+
+complex double Gausssum1d(int quadraticcoeff, int linearcoeff)
+{
+  /*****************************************
+  /* NOTE! we assume coeffs are either 0 or 1
+  /* (So you cannot pass off a linear coeff as a quadratic coeff by multiplying it by a factor of 2 (and considering it as mod 4)!)
+  *****************************************/
+  
+  quadraticcoeff %= 2;
+  linearcoeff %= 2;
+    
+  if(quadraticcoeff == 0)
+    if(linearcoeff == 0)
+      return 2.0+0.0*I;
+    else
+      return 0.0*I;
+  else
+    if(linearcoeff == 0)
+      return 1.0+1.0*I;
+    else
+      return 1.0-1.0*I;
+
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/hilbertspace_vector.c b/hilbertspace_vector.c
new file mode 100644 (file)
index 0000000..15d143d
--- /dev/null
@@ -0,0 +1,243 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <complex.h>
+#include <math.h>
+
+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<N; i++) 
+    psiN = outerMatrix(psiN, psi, pow(2,i), 1, 2, 1);
+  
+  int alpha[N], beta[N], gamma[N], delta[N];
+
+  complex double **P1[N];
+
+  complex double tr;
+  
+  /* printf("psiN:\n"); */
+  /* for(i=0; i<pow(2,N); i++) { */
+  /*   printf("%d: %lf+%lfI\n", i, creal(psiN[i][0]), cimag(psiN[i][0])); */
+  /* } */
+
+  while(readPaulicoeffs(alpha, beta, gamma, delta, N)) {
+
+    for(i=0; i<N; i++) {
+      //printf("%d %d %d %d\n", alpha[i], beta[i], gamma[i], delta[i]);
+      P1[i] = addMatrix(addMatrix(addMatrix(scalarmultMatrix(alpha[i],I2,2,2),scalarmultMatrix(beta[i],Z,2,2),2,2),scalarmultMatrix(gamma[i],X,2,2),2,2),scalarmultMatrix(delta[i],Y,2,2),2,2);
+    }
+
+    complex double **P = P1[0];
+    for(i=1; i<N; i++)
+      P = outerMatrix(P,P1[i],pow(2,i),pow(2,i),2,2);
+
+    complex double **psiNfinal = multMatrix(P,psiN,pow(2,N),pow(2,N),pow(2,N),1);
+
+    /* printf("psiNfinal:\n"); */
+    /* for(i=0; i<pow(2,N); i++) { */
+    /*   printf("%d: %lf+%lfI\n", i, creal(psiNfinal[i][0]), cimag(psiNfinal[i][0])); */
+    /* } */
+
+    tr = 0.0 + 0.0*I;
+    //printf("tr:\n");
+    for(i=0; i<pow(2,N); i++) {
+      tr += conj(psiN[i][0])*psiNfinal[i][0];
+      //printf("%d: %lf+%lfI\n", i, creal(tr), cimag(tr));
+    }
+
+    //    printf("%lf+%lfI\n", cabs(creal(tr)), cimag(tr));
+    printf("%lf\n", cabs(creal(tr)));
+    /* cabs the creal part because it's always positive, but sometimes the 0.0 gets a minus sign which is annoying to see when comparing outputs */
+
+    deallocate_mem(&P, pow(2,N));
+    deallocate_mem(&psiNfinal, pow(2,N));
+
+  }
+
+  //  deallocate_mem(&psiN, pow(2,N));
+
+  return 0;
+}
+
+
+complex double** addMatrix(complex double **A, complex double **B, int rows, int cols)
+{
+  int i, j;
+
+  complex double** C;
+
+  C = calloc(cols, sizeof(complex double*));
+  for(i=0; i<cols; i++)
+    C[i] = calloc(rows, sizeof(complex double));
+
+  for(i=0; i<rows; i++)
+    for(j=0; j<cols; j++)
+      C[i][j] = A[i][j] + B[i][j];
+
+  return C;
+}
+
+complex double** scalarmultMatrix(complex double scalar, complex double **a, int rows, int cols)
+{
+  int i, j;
+
+  complex double** C;
+
+  C = calloc(cols, sizeof(complex double*));
+  for(i=0; i<cols; i++)
+    C[i] = calloc(rows, sizeof(complex double));
+
+  for(i=0; i<rows; i++)
+    for(j=0; j<cols; j++)
+      C[i][j] = scalar*a[i][j];
+
+  return C;
+}
+
+complex double trace(complex double **a, int rows, int cols)
+{
+  int i;
+  complex double tr = 0.0*I;
+
+  for(i=0; i<rows; i++)
+    tr += a[i][i];
+
+  return tr;
+}
+
+complex double** transp(complex double **a, int rows, int cols)
+{
+  int i, j;
+  complex double** C;
+
+  C = calloc(cols, sizeof(complex double*));
+  for(i=0; i<cols; i++)
+    C[i] = calloc(rows, sizeof(complex double));
+  
+  for(i=0; i<cols; i++)
+    for(j=0; j<rows; j++) {
+      C[i][j] = a[j][i];
+    }
+
+  return C;
+}
+
+complex double** conjtransp(complex double **a, int rows, int cols)
+{
+  int i, j;
+  complex double** C;
+
+  C = calloc(cols, sizeof(complex double*));
+  for(i=0; i<cols; i++)
+    C[i] = calloc(rows, sizeof(complex double));
+  
+  for(i=0; i<cols; i++)
+    for(j=0; j<rows; j++) {
+      C[i][j] = conj(a[j][i]);
+    }
+
+  return C;
+}
+
+void printMatrix(complex double** a, int rows, int cols)
+{
+  int i, j;
+  printf("Matrix[%d][%d]\n", rows, cols);
+  for(i=0; i<rows; i++) {
+    for(j=0; j<cols; j++) {
+      printf("%lf+%lfI ", creal(a[i][j]), cimag(a[i][j]));
+    }
+    printf("\n");
+  }
+}
+
+complex double** multMatrix(complex double **A, complex double **B, int ro1, int co1, int ro2, int co2)
+{
+  int i, j, k;
+  complex double **C;
+  C = calloc(ro1, sizeof(complex double*));
+  for(i=0; i<ro1; i++)
+    C[i] = calloc(co2, sizeof(complex double));
+  
+  for(i=0; i<ro1; i++) {
+    for(j=0; j<co2; j++) {
+      C[i][j] = 0;
+      for(k=0; k<co1; k++)
+        C[i][j] += A[i][k] * B[k][j];
+    }
+  }
+
+  return C;
+}
+
+complex double** outerMatrix(complex double **A, complex double **B, int ro1, int co1, int ro2, int co2)
+{
+  int i, j, k, l;
+  complex double **C;
+  C = calloc(ro1*ro2, sizeof(complex double*));
+  for(i=0; i<ro1*ro2; i++)
+    C[i] = calloc(co1*co2, sizeof(complex double));
+
+  for(i=0; i<ro1; i++)
+    for(j=0; j<ro2; j++)
+      for(k=0; k<co1; k++)
+       for(l=0; l<co2; l++) {
+         C[j+ro2*i][l+co2*k] = A[i][k]* B[j][l];
+       }
+
+  return C;
+}
+
+
+
+void deallocate_mem(complex double ***arr, int rows)
+{
+  int i;
+  for(i=0; i<rows; i++)
+    free((*arr)[i]);
+  free(*arr);
+}
+
+int readPaulicoeffs(int *alpha, int *beta, int *gamma, int *delta, int numqubits)
+{
+
+  int i;
+
+  if(scanf("%d %d %d %d", &alpha[0], &beta[0], &gamma[0], &delta[0]) != EOF) {
+    for(i=1; i<numqubits; i++) {
+      scanf("%d %d %d %d", &alpha[i], &beta[i], &gamma[i], &delta[i]);
+    }
+    return 1;
+  } else
+    return 0;
+
+}
+
+
+
diff --git a/randommultipleinputPaulis.c b/randommultipleinputPaulis.c
new file mode 100644 (file)
index 0000000..d49feec
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+// 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<numPaulis; i++) {
+    
+    //r = rand()%4; printf("%d\n",r); // omega
+    
+    for(j=0; j<N; j++) {
+      r = rand()%4;
+      printf("%d %d %d %d\n", r==0, r==1, r==2, r==3);
+    }
+  }
+
+}