Ejemplo n.º 1
0
Archivo: evolve.c Proyecto: jzrake/m2
void check_symmetry(m2sim *m2, char *msg)
{
#if DEBUG_SYMMETRY
#define NOTZERO(a) (fabs(a)>1e-12)
  int *L = m2->local_grid_size;
  int i,j,k;

  for (i=0; i<L[1]-1; ++i) {
    for (j=1; j<L[2]-1; ++j) {
      /*for (k=1; k<L[3]-1; ++k) {*/
      for (k=0; k<1; ++k) {
        m2vol *V0 = M2_VOL(i,        j, k);
        m2vol *V1 = M2_VOL(i, L[2] - j, k);

        if (NOTZERO(V0->emf2 - V1->emf2) ||
            NOTZERO(V0->prim.d - V1->prim.d) ||
            NOTZERO(V0->prim.p - V1->prim.p) ||
            NOTZERO(V0->flux1[B33] - V1->flux1[B33]) ||
            NOTZERO(V0->Bflux1A - V1->Bflux1A)) {
          printf("%s [%d %d %d]: "
              "p = (%+14.12e %+14.12e) "
              "d = (%+14.12e %+14.12e) "
              "flux1[B3] = (%+14.12e %+14.12e) "
              "emf1 = (%+14.12e %+14.12e) "
              "emf2 = (%+14.12e %+14.12e)\n",
              msg, V0->global_index[1], V0->global_index[2], V0->global_index[3],
              V0->flux1[B33], V1->flux1[B33],
              V0->prim.p, V1->prim.p,
              V0->prim.d, V1->prim.d,
              V0->emf2, V1->emf2,
              V0->emf3, V1->emf3);
        }
      }
    }
  }


  for (i=0; i<L[1]; ++i) {
    for (j=0; j<L[2]; ++j) {

      m2vol *V0 = M2_VOL(i,        j  , 0);
      m2vol *V1 = M2_VOL(i, L[2] - j-1, 0);

      if (NOTZERO(V0->emf1 + V1->emf1)) {
        printf("%s [%d %d] / [%d %d]: emf1 = (%+14.12e %+14.12e)\n",
               msg,
               V0->global_index[1], V0->global_index[2],
               V1->global_index[1], V1->global_index[2],
               V0->emf1, V1->emf1);
      }
    }
  }
#undef NOTZERO
#endif
}
Ejemplo n.º 2
0
// pre-contracted grid AO evaluator
// contracted factors = \sum c_{i} exp(-a_i*r_i**2)
void GTOshell_eval_grid_cart(double *gto, double *ri, double *exps,
                             double *coord, double *alpha, double *coeff,
                             int l, int np, int nc, int blksize)
{
        int lx, ly, lz, i, k;
        double ce[3];
        double xpows[8*blksize];
        double ypows[8*blksize];
        double zpows[8*blksize];
        double *gridx = coord;
        double *gridy = coord+blksize;
        double *gridz = coord+blksize*2;
        double        *gto1, *gto2, *gto3, *gto4,
               *gto5, *gto6, *gto7, *gto8, *gto9;

        switch (l) {
        case 0:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                gto[i] = exps[i];
                        }
                        exps += blksize;
                        gto += blksize;
                }
                break;
        case 1:
                for (k = 0; k < nc; k++) {
                        gto1 = gto + blksize*1;
                        gto2 = gto + blksize*2;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        gto [i] = gridx[i] * exps[i];
                                        gto1[i] = gridy[i] * exps[i];
                                        gto2[i] = gridz[i] * exps[i];
                                } else {
                                        gto [i] = 0;
                                        gto1[i] = 0;
                                        gto2[i] = 0;
                                }
                        }
                        exps += blksize;
                        gto += blksize * 3;
                }
                break;
        case 2:
                for (k = 0; k < nc; k++) {
                        gto1 = gto + blksize*1;
                        gto2 = gto + blksize*2;
                        gto3 = gto + blksize*3;
                        gto4 = gto + blksize*4;
                        gto5 = gto + blksize*5;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        ce[0] = gridx[i] * exps[i];
                                        ce[1] = gridy[i] * exps[i];
                                        ce[2] = gridz[i] * exps[i];
                                        gto [i] = ce[0] * gridx[i]; // xx
                                        gto1[i] = ce[0] * gridy[i]; // xy
                                        gto2[i] = ce[0] * gridz[i]; // xz
                                        gto3[i] = ce[1] * gridy[i]; // yy
                                        gto4[i] = ce[1] * gridz[i]; // yz
                                        gto5[i] = ce[2] * gridz[i]; // zz
                                } else {
                                        gto [i] = 0;
                                        gto1[i] = 0;
                                        gto2[i] = 0;
                                        gto3[i] = 0;
                                        gto4[i] = 0;
                                        gto5[i] = 0;
                                }
                        }
                        exps += blksize;
                        gto += blksize * 6;
                }
                break;
        case 3:
                for (k = 0; k < nc; k++) {
                        gto1 = gto + blksize*1;
                        gto2 = gto + blksize*2;
                        gto3 = gto + blksize*3;
                        gto4 = gto + blksize*4;
                        gto5 = gto + blksize*5;
                        gto6 = gto + blksize*6;
                        gto7 = gto + blksize*7;
                        gto8 = gto + blksize*8;
                        gto9 = gto + blksize*9;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        ce[0] = gridx[i] * gridx[i] * exps[i];
                                        ce[1] = gridy[i] * gridy[i] * exps[i];
                                        ce[2] = gridz[i] * gridz[i] * exps[i];
                                        gto [i] = ce[0] * gridx[i]; // xxx
                                        gto1[i] = ce[0] * gridy[i]; // xxy
                                        gto2[i] = ce[0] * gridz[i]; // xxz
                                        gto3[i] = gridx[i] * ce[1]; // xyy
                                        gto4[i] = gridx[i]*gridy[i]*gridz[i] * exps[i]; // xyz
                                        gto5[i] = gridx[i] * ce[2]; // xzz
                                        gto6[i] = ce[1] * gridy[i]; // yyy
                                        gto7[i] = ce[1] * gridz[i]; // yyz
                                        gto8[i] = gridy[i] * ce[2]; // yzz
                                        gto9[i] = gridz[i] * ce[2]; // zzz
                                } else {
                                        gto [i] = 0;
                                        gto1[i] = 0;
                                        gto2[i] = 0;
                                        gto3[i] = 0;
                                        gto4[i] = 0;
                                        gto5[i] = 0;
                                        gto6[i] = 0;
                                        gto7[i] = 0;
                                        gto8[i] = 0;
                                        gto9[i] = 0;
                                }
                        }
                        exps += blksize;
                        gto += blksize * 10;
                }
                break;
        default:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        xpows[i*8+0] = 1;
                                        ypows[i*8+0] = 1;
                                        zpows[i*8+0] = 1;
                                        for (lx = 1; lx < l+1; lx++) {
                                                xpows[i*8+lx] = xpows[i*8+lx-1] * gridx[i];
                                                ypows[i*8+lx] = ypows[i*8+lx-1] * gridy[i];
                                                zpows[i*8+lx] = zpows[i*8+lx-1] * gridz[i];
                                        }
                                }
                        }
                        for (lx = l; lx >= 0; lx--) {
                        for (ly = l - lx; ly >= 0; ly--) {
                                lz = l - lx - ly;
                                for (i = 0; i < blksize; i++) {
                                        if (NOTZERO(exps[i])) {
                                                gto[i] = xpows[i*8+lx]
                                                       * ypows[i*8+ly]
                                                       * zpows[i*8+lz]*exps[i];
                                        } else {
                                                gto[i] = 0;
                                        }
                                }
                                gto += blksize;
                        } }
                        exps += blksize;
                }
        }
}
Ejemplo n.º 3
0
void GTOshell_eval_grid_ip_cart(double *gto, double *ri, double *exps,
                                double *coord, double *alpha, double *coeff,
                                int l, int np, int nc, int blksize)
{
        const int degen = _len_cart[l];
        const int gtosize = nc*degen*blksize;
        int lx, ly, lz, i, k, n;
        double ax, ay, az, tmp;
        double ce[6];
        double rre[10];
        double xpows_1less_in_power[64];
        double ypows_1less_in_power[64];
        double zpows_1less_in_power[64];
        double *xpows = xpows_1less_in_power + 1;
        double *ypows = ypows_1less_in_power + 1;
        double *zpows = zpows_1less_in_power + 1;
        double *gridx = coord;
        double *gridy = coord+blksize;
        double *gridz = coord+blksize*2;
        double *gtox = gto;
        double *gtoy = gto + gtosize;
        double *gtoz = gto + gtosize * 2;
        double *exps_2a = exps + NPRIMAX*blksize;
        double         *gtox1, *gtox2, *gtox3, *gtox4,
               *gtox5, *gtox6, *gtox7, *gtox8, *gtox9;
        double         *gtoy1, *gtoy2, *gtoy3, *gtoy4,
               *gtoy5, *gtoy6, *gtoy7, *gtoy8, *gtoy9;
        double         *gtoz1, *gtoz2, *gtoz3, *gtoz4,
               *gtoz5, *gtoz6, *gtoz7, *gtoz8, *gtoz9;
        switch (l) {
        case 0:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        gtox[i] = exps_2a[i] * gridx[i];
                                        gtoy[i] = exps_2a[i] * gridy[i];
                                        gtoz[i] = exps_2a[i] * gridz[i];
                                } else {
                                        gtox[i] = 0;
                                        gtoy[i] = 0;
                                        gtoz[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize;
                        gtoy += blksize;
                        gtoz += blksize;
                }
                break;
        case 1:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        ax = exps_2a[i] * gridx[i];
                                        ay = exps_2a[i] * gridy[i];
                                        az = exps_2a[i] * gridz[i];
                                        gtox [i] = ax * gridx[i] + exps[i];
                                        gtox1[i] = ax * gridy[i];
                                        gtox2[i] = ax * gridz[i];
                                        gtoy [i] = ay * gridx[i];
                                        gtoy1[i] = ay * gridy[i] + exps[i];
                                        gtoy2[i] = ay * gridz[i];
                                        gtoz [i] = az * gridx[i];
                                        gtoz1[i] = az * gridy[i];
                                        gtoz2[i] = az * gridz[i] + exps[i];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 3;
                        gtoy += blksize * 3;
                        gtoz += blksize * 3;
                }
                break;
        case 2:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        gtox3 = gtox + blksize*3;
                        gtoy3 = gtoy + blksize*3;
                        gtoz3 = gtoz + blksize*3;
                        gtox4 = gtox + blksize*4;
                        gtoy4 = gtoy + blksize*4;
                        gtoz4 = gtoz + blksize*4;
                        gtox5 = gtox + blksize*5;
                        gtoy5 = gtoy + blksize*5;
                        gtoz5 = gtoz + blksize*5;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        tmp = exps_2a[i]/(exps[i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * exps[i];
                                        ce[1] = gridy[i] * exps[i];
                                        ce[2] = gridz[i] * exps[i];
                                        rre[0] = gridx[i] * ce[0]; // xx
                                        rre[1] = gridx[i] * ce[1]; // xy
                                        rre[2] = gridx[i] * ce[2]; // xz
                                        rre[3] = gridy[i] * ce[1]; // yy
                                        rre[4] = gridy[i] * ce[2]; // yz
                                        rre[5] = gridz[i] * ce[2]; // zz
                                        gtox [i] = ax * rre[0] + 2 * ce[0];
                                        gtox1[i] = ax * rre[1] +     ce[1];
                                        gtox2[i] = ax * rre[2] +     ce[2];
                                        gtox3[i] = ax * rre[3];
                                        gtox4[i] = ax * rre[4];
                                        gtox5[i] = ax * rre[5];
                                        gtoy [i] = ay * rre[0];
                                        gtoy1[i] = ay * rre[1] +     ce[0];
                                        gtoy2[i] = ay * rre[2];
                                        gtoy3[i] = ay * rre[3] + 2 * ce[1];
                                        gtoy4[i] = ay * rre[4] +     ce[2];
                                        gtoy5[i] = ay * rre[5];
                                        gtoz [i] = az * rre[0];
                                        gtoz1[i] = az * rre[1];
                                        gtoz2[i] = az * rre[2] +     ce[0];
                                        gtoz3[i] = az * rre[3];
                                        gtoz4[i] = az * rre[4] +     ce[1];
                                        gtoz5[i] = az * rre[5] + 2 * ce[2];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtox3[i] = 0;
                                        gtox4[i] = 0;
                                        gtox5[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoy3[i] = 0;
                                        gtoy4[i] = 0;
                                        gtoy5[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                        gtoz3[i] = 0;
                                        gtoz4[i] = 0;
                                        gtoz5[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 6;
                        gtoy += blksize * 6;
                        gtoz += blksize * 6;
                }
                break;
        case 3:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        gtox3 = gtox + blksize*3;
                        gtoy3 = gtoy + blksize*3;
                        gtoz3 = gtoz + blksize*3;
                        gtox4 = gtox + blksize*4;
                        gtoy4 = gtoy + blksize*4;
                        gtoz4 = gtoz + blksize*4;
                        gtox5 = gtox + blksize*5;
                        gtoy5 = gtoy + blksize*5;
                        gtoz5 = gtoz + blksize*5;
                        gtox6 = gtox + blksize*6;
                        gtoy6 = gtoy + blksize*6;
                        gtoz6 = gtoz + blksize*6;
                        gtox7 = gtox + blksize*7;
                        gtoy7 = gtoy + blksize*7;
                        gtoz7 = gtoz + blksize*7;
                        gtox8 = gtox + blksize*8;
                        gtoy8 = gtoy + blksize*8;
                        gtoz8 = gtoz + blksize*8;
                        gtox9 = gtox + blksize*9;
                        gtoy9 = gtoy + blksize*9;
                        gtoz9 = gtoz + blksize*9;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        tmp = exps_2a[i]/(exps[i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * gridx[i] * exps[i];
                                        ce[1] = gridx[i] * gridy[i] * exps[i];
                                        ce[2] = gridx[i] * gridz[i] * exps[i];
                                        ce[3] = gridy[i] * gridy[i] * exps[i];
                                        ce[4] = gridy[i] * gridz[i] * exps[i];
                                        ce[5] = gridz[i] * gridz[i] * exps[i];
                                        rre[0] = gridx[i] * ce[0]; // xxx
                                        rre[1] = gridx[i] * ce[1]; // xxy
                                        rre[2] = gridx[i] * ce[2]; // xxz
                                        rre[3] = gridx[i] * ce[3]; // xyy
                                        rre[4] = gridx[i] * ce[4]; // xyz
                                        rre[5] = gridx[i] * ce[5]; // xzz
                                        rre[6] = gridy[i] * ce[3]; // yyy
                                        rre[7] = gridy[i] * ce[4]; // yyz
                                        rre[8] = gridy[i] * ce[5]; // yzz
                                        rre[9] = gridz[i] * ce[5]; // zzz
                                        gtox [i] = ax * rre[0] + 3 * ce[0];
                                        gtox1[i] = ax * rre[1] + 2 * ce[1];
                                        gtox2[i] = ax * rre[2] + 2 * ce[2];
                                        gtox3[i] = ax * rre[3] +     ce[3];
                                        gtox4[i] = ax * rre[4] +     ce[4];
                                        gtox5[i] = ax * rre[5] +     ce[5];
                                        gtox6[i] = ax * rre[6];
                                        gtox7[i] = ax * rre[7];
                                        gtox8[i] = ax * rre[8];
                                        gtox9[i] = ax * rre[9];
                                        gtoy [i] = ay * rre[0];
                                        gtoy1[i] = ay * rre[1] +     ce[0];
                                        gtoy2[i] = ay * rre[2];
                                        gtoy3[i] = ay * rre[3] + 2 * ce[1];
                                        gtoy4[i] = ay * rre[4] +     ce[2];
                                        gtoy5[i] = ay * rre[5];
                                        gtoy6[i] = ay * rre[6] + 3 * ce[3];
                                        gtoy7[i] = ay * rre[7] + 2 * ce[4];
                                        gtoy8[i] = ay * rre[8] +     ce[5];
                                        gtoy9[i] = ay * rre[9];
                                        gtoz [i] = az * rre[0];
                                        gtoz1[i] = az * rre[1];
                                        gtoz2[i] = az * rre[2] +     ce[0];
                                        gtoz3[i] = az * rre[3];
                                        gtoz4[i] = az * rre[4] +     ce[1];
                                        gtoz5[i] = az * rre[5] + 2 * ce[2];
                                        gtoz6[i] = az * rre[6];
                                        gtoz7[i] = az * rre[7] +     ce[3];
                                        gtoz8[i] = az * rre[8] + 2 * ce[4];
                                        gtoz9[i] = az * rre[9] + 3 * ce[5];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtox3[i] = 0;
                                        gtox4[i] = 0;
                                        gtox5[i] = 0;
                                        gtox6[i] = 0;
                                        gtox7[i] = 0;
                                        gtox8[i] = 0;
                                        gtox9[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoy3[i] = 0;
                                        gtoy4[i] = 0;
                                        gtoy5[i] = 0;
                                        gtoy6[i] = 0;
                                        gtoy7[i] = 0;
                                        gtoy8[i] = 0;
                                        gtoy9[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                        gtoz3[i] = 0;
                                        gtoz4[i] = 0;
                                        gtoz5[i] = 0;
                                        gtoz6[i] = 0;
                                        gtoz7[i] = 0;
                                        gtoz8[i] = 0;
                                        gtoz9[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 10;
                        gtoy += blksize * 10;
                        gtoz += blksize * 10;
                }
                break;
        default:
                xpows_1less_in_power[0] = 0;
                ypows_1less_in_power[0] = 0;
                zpows_1less_in_power[0] = 0;
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        xpows[0] = 1;
                                        ypows[0] = 1;
                                        zpows[0] = 1;
                                        for (lx = 1; lx <= l; lx++) {
                                                xpows[lx] = xpows[lx-1] *gridx[i];
                                                ypows[lx] = ypows[lx-1] *gridy[i];
                                                zpows[lx] = zpows[lx-1] *gridz[i];
                                        }
                                        for (lx = l, n = 0; lx >= 0; lx--) {
                                        for (ly = l - lx; ly >= 0; ly--, n++) {
                                                lz = l - lx - ly;
                                                tmp = xpows[lx] * ypows[ly] * zpows[lz];
                                                gtox[n*blksize+i] = exps_2a[i] * gridx[i] * tmp;
                                                gtoy[n*blksize+i] = exps_2a[i] * gridy[i] * tmp;
                                                gtoz[n*blksize+i] = exps_2a[i] * gridz[i] * tmp;
                                                gtox[n*blksize+i] += exps[i] * lx * xpows[lx-1] * ypows[ly] * zpows[lz];
                                                gtoy[n*blksize+i] += exps[i] * ly * xpows[lx] * ypows[ly-1] * zpows[lz];
                                                gtoz[n*blksize+i] += exps[i] * lz * xpows[lx] * ypows[ly] * zpows[lz-1];
                                        } }
                                } else {
                                        for (n = 0; n < degen; n++) {
                                                gtox[n*blksize+i] = 0;
                                                gtoy[n*blksize+i] = 0;
                                                gtoz[n*blksize+i] = 0;
                                        }
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox    += blksize * degen;
                        gtoy    += blksize * degen;
                        gtoz    += blksize * degen;
                }
        }
}
Ejemplo n.º 4
0
// pre-contracted grid AO evaluator
// contracted factors = \sum c_{i} exp(-a_i*r_i**2)
void GTOshell_eval_grid_cart(double *gto, double *ri, double *exps,
                             double *coord, double *alpha, double *coeff,
                             double *env, int l, int np, int nc,
                             size_t nao, size_t ngrids, size_t blksize)
{
        int lx, ly, lz;
        size_t i, k;
        double ce[3];
        double xpows[8*blksize];
        double ypows[8*blksize];
        double zpows[8*blksize];
        double *gridx = coord;
        double *gridy = coord+BLKSIZE;
        double *gridz = coord+BLKSIZE*2;

        switch (l) {
        case 0:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                gto[k*ngrids+i] = exps[k*BLKSIZE+i];
                        }
                }
                break;
        case 1:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                gto[         i] = gridx[i] * exps[k*BLKSIZE+i];
                                gto[1*ngrids+i] = gridy[i] * exps[k*BLKSIZE+i];
                                gto[2*ngrids+i] = gridz[i] * exps[k*BLKSIZE+i];
                        }
                        gto += ngrids * 3;
                }
                break;
        case 2:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        ce[0] = gridx[i] * exps[k*BLKSIZE+i];
                                        ce[1] = gridy[i] * exps[k*BLKSIZE+i];
                                        ce[2] = gridz[i] * exps[k*BLKSIZE+i];
                                        gto[         i] = ce[0] * gridx[i]; // xx
                                        gto[1*ngrids+i] = ce[0] * gridy[i]; // xy
                                        gto[2*ngrids+i] = ce[0] * gridz[i]; // xz
                                        gto[3*ngrids+i] = ce[1] * gridy[i]; // yy
                                        gto[4*ngrids+i] = ce[1] * gridz[i]; // yz
                                        gto[5*ngrids+i] = ce[2] * gridz[i]; // zz
                                } else {
                                        gto[         i] = 0;
                                        gto[1*ngrids+i] = 0;
                                        gto[2*ngrids+i] = 0;
                                        gto[3*ngrids+i] = 0;
                                        gto[4*ngrids+i] = 0;
                                        gto[5*ngrids+i] = 0;
                                }
                        }
                        gto += ngrids * 6;
                }
                break;
        case 3:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        ce[0] = gridx[i] * gridx[i] * exps[k*BLKSIZE+i];
                                        ce[1] = gridy[i] * gridy[i] * exps[k*BLKSIZE+i];
                                        ce[2] = gridz[i] * gridz[i] * exps[k*BLKSIZE+i];
                                        gto[         i] = ce[0] * gridx[i]; // xxx
                                        gto[1*ngrids+i] = ce[0] * gridy[i]; // xxy
                                        gto[2*ngrids+i] = ce[0] * gridz[i]; // xxz
                                        gto[3*ngrids+i] = gridx[i] * ce[1]; // xyy
                                        gto[4*ngrids+i] = gridx[i]*gridy[i]*gridz[i] * exps[k*BLKSIZE+i]; // xyz
                                        gto[5*ngrids+i] = gridx[i] * ce[2]; // xzz
                                        gto[6*ngrids+i] = ce[1] * gridy[i]; // yyy
                                        gto[7*ngrids+i] = ce[1] * gridz[i]; // yyz
                                        gto[8*ngrids+i] = gridy[i] * ce[2]; // yzz
                                        gto[9*ngrids+i] = gridz[i] * ce[2]; // zzz
                                } else {
                                        gto[         i] = 0;
                                        gto[1*ngrids+i] = 0;
                                        gto[2*ngrids+i] = 0;
                                        gto[3*ngrids+i] = 0;
                                        gto[4*ngrids+i] = 0;
                                        gto[5*ngrids+i] = 0;
                                        gto[6*ngrids+i] = 0;
                                        gto[7*ngrids+i] = 0;
                                        gto[8*ngrids+i] = 0;
                                        gto[9*ngrids+i] = 0;
                                }
                        }
                        gto += ngrids * 10;
                }
                break;
        default:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                xpows[i] = 1;
                                ypows[i] = 1;
                                zpows[i] = 1;
                        }
                        for (lx = 1; lx < l+1; lx++) {
                                for (i = 0; i < blksize; i++) {
                                        xpows[lx*blksize+i] = xpows[(lx-1)*blksize+i] * gridx[i];
                                        ypows[lx*blksize+i] = ypows[(lx-1)*blksize+i] * gridy[i];
                                        zpows[lx*blksize+i] = zpows[(lx-1)*blksize+i] * gridz[i];
                                }
                        }
                        for (lx = l; lx >= 0; lx--) {
                        for (ly = l - lx; ly >= 0; ly--) {
                                lz = l - lx - ly;
                                for (i = 0; i < blksize; i++) {
                                        gto[i] = xpows[lx*blksize+i]
                                               * ypows[ly*blksize+i]
                                               * zpows[lz*blksize+i]*exps[k*BLKSIZE+i];
                                }
                                gto += ngrids;
                        } }
                }
        }
}
Ejemplo n.º 5
0
void GTOshell_eval_grid_ip_cart(double *gto, double *ri, double *exps,
                                double *coord, double *alpha, double *coeff,
                                double *env, int l, int np, int nc,
                                size_t nao, size_t ngrids, size_t blksize)
{
        const size_t degen = (l+1)*(l+2)/2;
        int lx, ly, lz;
        size_t i, k, n;
        double ax, ay, az, tmp;
        double ce[6];
        double rre[10];
        double xpows_1less_in_power[64];
        double ypows_1less_in_power[64];
        double zpows_1less_in_power[64];
        double *xpows = xpows_1less_in_power + 1;
        double *ypows = ypows_1less_in_power + 1;
        double *zpows = zpows_1less_in_power + 1;
        double *gridx = coord;
        double *gridy = coord+BLKSIZE;
        double *gridz = coord+BLKSIZE*2;
        double *gtox = gto;
        double *gtoy = gto + nao * ngrids;
        double *gtoz = gto + nao * ngrids * 2;
        double *exps_2a = exps + NPRIMAX*BLKSIZE;

        switch (l) {
        case 0:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                gtox[i] = exps_2a[k*BLKSIZE+i] * gridx[i];
                                gtoy[i] = exps_2a[k*BLKSIZE+i] * gridy[i];
                                gtoz[i] = exps_2a[k*BLKSIZE+i] * gridz[i];
                        }
                        gtox += ngrids;
                        gtoy += ngrids;
                        gtoz += ngrids;
                }
                break;
        case 1:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        ax = exps_2a[k*BLKSIZE+i] * gridx[i];
                                        ay = exps_2a[k*BLKSIZE+i] * gridy[i];
                                        az = exps_2a[k*BLKSIZE+i] * gridz[i];
                                        gtox[         i] = ax * gridx[i] + exps[k*BLKSIZE+i];
                                        gtox[1*ngrids+i] = ax * gridy[i];
                                        gtox[2*ngrids+i] = ax * gridz[i];
                                        gtoy[         i] = ay * gridx[i];
                                        gtoy[1*ngrids+i] = ay * gridy[i] + exps[k*BLKSIZE+i];
                                        gtoy[2*ngrids+i] = ay * gridz[i];
                                        gtoz[         i] = az * gridx[i];
                                        gtoz[1*ngrids+i] = az * gridy[i];
                                        gtoz[2*ngrids+i] = az * gridz[i] + exps[k*BLKSIZE+i];
                                } else {
                                        gtox[         i] = 0;
                                        gtox[1*ngrids+i] = 0;
                                        gtox[2*ngrids+i] = 0;
                                        gtoy[         i] = 0;
                                        gtoy[1*ngrids+i] = 0;
                                        gtoy[2*ngrids+i] = 0;
                                        gtoz[         i] = 0;
                                        gtoz[1*ngrids+i] = 0;
                                        gtoz[2*ngrids+i] = 0;
                                }
                        }
                        gtox += ngrids * 3;
                        gtoy += ngrids * 3;
                        gtoz += ngrids * 3;
                }
                break;
        case 2:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        tmp = exps_2a[k*BLKSIZE+i]/(exps[k*BLKSIZE+i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * exps[k*BLKSIZE+i];
                                        ce[1] = gridy[i] * exps[k*BLKSIZE+i];
                                        ce[2] = gridz[i] * exps[k*BLKSIZE+i];
                                        rre[0] = gridx[i] * ce[0]; // xx
                                        rre[1] = gridx[i] * ce[1]; // xy
                                        rre[2] = gridx[i] * ce[2]; // xz
                                        rre[3] = gridy[i] * ce[1]; // yy
                                        rre[4] = gridy[i] * ce[2]; // yz
                                        rre[5] = gridz[i] * ce[2]; // zz
                                        gtox[         i] = ax * rre[0] + 2 * ce[0];
                                        gtox[1*ngrids+i] = ax * rre[1] +     ce[1];
                                        gtox[2*ngrids+i] = ax * rre[2] +     ce[2];
                                        gtox[3*ngrids+i] = ax * rre[3];
                                        gtox[4*ngrids+i] = ax * rre[4];
                                        gtox[5*ngrids+i] = ax * rre[5];
                                        gtoy[         i] = ay * rre[0];
                                        gtoy[1*ngrids+i] = ay * rre[1] +     ce[0];
                                        gtoy[2*ngrids+i] = ay * rre[2];
                                        gtoy[3*ngrids+i] = ay * rre[3] + 2 * ce[1];
                                        gtoy[4*ngrids+i] = ay * rre[4] +     ce[2];
                                        gtoy[5*ngrids+i] = ay * rre[5];
                                        gtoz[         i] = az * rre[0];
                                        gtoz[1*ngrids+i] = az * rre[1];
                                        gtoz[2*ngrids+i] = az * rre[2] +     ce[0];
                                        gtoz[3*ngrids+i] = az * rre[3];
                                        gtoz[4*ngrids+i] = az * rre[4] +     ce[1];
                                        gtoz[5*ngrids+i] = az * rre[5] + 2 * ce[2];
                                } else {
                                        gtox[         i] = 0;
                                        gtox[1*ngrids+i] = 0;
                                        gtox[2*ngrids+i] = 0;
                                        gtox[3*ngrids+i] = 0;
                                        gtox[4*ngrids+i] = 0;
                                        gtox[5*ngrids+i] = 0;
                                        gtoy[         i] = 0;
                                        gtoy[1*ngrids+i] = 0;
                                        gtoy[2*ngrids+i] = 0;
                                        gtoy[3*ngrids+i] = 0;
                                        gtoy[4*ngrids+i] = 0;
                                        gtoy[5*ngrids+i] = 0;
                                        gtoz[         i] = 0;
                                        gtoz[1*ngrids+i] = 0;
                                        gtoz[2*ngrids+i] = 0;
                                        gtoz[3*ngrids+i] = 0;
                                        gtoz[4*ngrids+i] = 0;
                                        gtoz[5*ngrids+i] = 0;
                                }
                        }
                        gtox += ngrids * 6;
                        gtoy += ngrids * 6;
                        gtoz += ngrids * 6;
                }
                break;
        case 3:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        tmp = exps_2a[k*BLKSIZE+i]/(exps[k*BLKSIZE+i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * gridx[i] * exps[k*BLKSIZE+i];
                                        ce[1] = gridx[i] * gridy[i] * exps[k*BLKSIZE+i];
                                        ce[2] = gridx[i] * gridz[i] * exps[k*BLKSIZE+i];
                                        ce[3] = gridy[i] * gridy[i] * exps[k*BLKSIZE+i];
                                        ce[4] = gridy[i] * gridz[i] * exps[k*BLKSIZE+i];
                                        ce[5] = gridz[i] * gridz[i] * exps[k*BLKSIZE+i];
                                        rre[0] = gridx[i] * ce[0]; // xxx
                                        rre[1] = gridx[i] * ce[1]; // xxy
                                        rre[2] = gridx[i] * ce[2]; // xxz
                                        rre[3] = gridx[i] * ce[3]; // xyy
                                        rre[4] = gridx[i] * ce[4]; // xyz
                                        rre[5] = gridx[i] * ce[5]; // xzz
                                        rre[6] = gridy[i] * ce[3]; // yyy
                                        rre[7] = gridy[i] * ce[4]; // yyz
                                        rre[8] = gridy[i] * ce[5]; // yzz
                                        rre[9] = gridz[i] * ce[5]; // zzz
                                        gtox[         i] = ax * rre[0] + 3 * ce[0];
                                        gtox[1*ngrids+i] = ax * rre[1] + 2 * ce[1];
                                        gtox[2*ngrids+i] = ax * rre[2] + 2 * ce[2];
                                        gtox[3*ngrids+i] = ax * rre[3] +     ce[3];
                                        gtox[4*ngrids+i] = ax * rre[4] +     ce[4];
                                        gtox[5*ngrids+i] = ax * rre[5] +     ce[5];
                                        gtox[6*ngrids+i] = ax * rre[6];
                                        gtox[7*ngrids+i] = ax * rre[7];
                                        gtox[8*ngrids+i] = ax * rre[8];
                                        gtox[9*ngrids+i] = ax * rre[9];
                                        gtoy[         i] = ay * rre[0];
                                        gtoy[1*ngrids+i] = ay * rre[1] +     ce[0];
                                        gtoy[2*ngrids+i] = ay * rre[2];
                                        gtoy[3*ngrids+i] = ay * rre[3] + 2 * ce[1];
                                        gtoy[4*ngrids+i] = ay * rre[4] +     ce[2];
                                        gtoy[5*ngrids+i] = ay * rre[5];
                                        gtoy[6*ngrids+i] = ay * rre[6] + 3 * ce[3];
                                        gtoy[7*ngrids+i] = ay * rre[7] + 2 * ce[4];
                                        gtoy[8*ngrids+i] = ay * rre[8] +     ce[5];
                                        gtoy[9*ngrids+i] = ay * rre[9];
                                        gtoz[         i] = az * rre[0];
                                        gtoz[1*ngrids+i] = az * rre[1];
                                        gtoz[2*ngrids+i] = az * rre[2] +     ce[0];
                                        gtoz[3*ngrids+i] = az * rre[3];
                                        gtoz[4*ngrids+i] = az * rre[4] +     ce[1];
                                        gtoz[5*ngrids+i] = az * rre[5] + 2 * ce[2];
                                        gtoz[6*ngrids+i] = az * rre[6];
                                        gtoz[7*ngrids+i] = az * rre[7] +     ce[3];
                                        gtoz[8*ngrids+i] = az * rre[8] + 2 * ce[4];
                                        gtoz[9*ngrids+i] = az * rre[9] + 3 * ce[5];
                                } else {
                                        gtox[         i] = 0;
                                        gtox[1*ngrids+i] = 0;
                                        gtox[2*ngrids+i] = 0;
                                        gtox[3*ngrids+i] = 0;
                                        gtox[4*ngrids+i] = 0;
                                        gtox[5*ngrids+i] = 0;
                                        gtox[6*ngrids+i] = 0;
                                        gtox[7*ngrids+i] = 0;
                                        gtox[8*ngrids+i] = 0;
                                        gtox[9*ngrids+i] = 0;
                                        gtoy[         i] = 0;
                                        gtoy[1*ngrids+i] = 0;
                                        gtoy[2*ngrids+i] = 0;
                                        gtoy[3*ngrids+i] = 0;
                                        gtoy[4*ngrids+i] = 0;
                                        gtoy[5*ngrids+i] = 0;
                                        gtoy[6*ngrids+i] = 0;
                                        gtoy[7*ngrids+i] = 0;
                                        gtoy[8*ngrids+i] = 0;
                                        gtoy[9*ngrids+i] = 0;
                                        gtoz[         i] = 0;
                                        gtoz[1*ngrids+i] = 0;
                                        gtoz[2*ngrids+i] = 0;
                                        gtoz[3*ngrids+i] = 0;
                                        gtoz[4*ngrids+i] = 0;
                                        gtoz[5*ngrids+i] = 0;
                                        gtoz[6*ngrids+i] = 0;
                                        gtoz[7*ngrids+i] = 0;
                                        gtoz[8*ngrids+i] = 0;
                                        gtoz[9*ngrids+i] = 0;
                                }
                        }
                        gtox += ngrids * 10;
                        gtoy += ngrids * 10;
                        gtoz += ngrids * 10;
                }
                break;
        default:
                xpows_1less_in_power[0] = 0;
                ypows_1less_in_power[0] = 0;
                zpows_1less_in_power[0] = 0;
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[k*BLKSIZE+i])) {
                                        xpows[0] = 1;
                                        ypows[0] = 1;
                                        zpows[0] = 1;
                                        for (lx = 1; lx <= l; lx++) {
                                                xpows[lx] = xpows[lx-1] *gridx[i];
                                                ypows[lx] = ypows[lx-1] *gridy[i];
                                                zpows[lx] = zpows[lx-1] *gridz[i];
                                        }
                                        for (lx = l, n = 0; lx >= 0; lx--) {
                                        for (ly = l - lx; ly >= 0; ly--, n++) {
                                                lz = l - lx - ly;
                                                tmp = xpows[lx] * ypows[ly] * zpows[lz];
                                                gtox[n*ngrids+i] = exps_2a[k*BLKSIZE+i] * gridx[i] * tmp;
                                                gtoy[n*ngrids+i] = exps_2a[k*BLKSIZE+i] * gridy[i] * tmp;
                                                gtoz[n*ngrids+i] = exps_2a[k*BLKSIZE+i] * gridz[i] * tmp;
                                                gtox[n*ngrids+i] += exps[k*BLKSIZE+i] * lx * xpows[lx-1] * ypows[ly] * zpows[lz];
                                                gtoy[n*ngrids+i] += exps[k*BLKSIZE+i] * ly * xpows[lx] * ypows[ly-1] * zpows[lz];
                                                gtoz[n*ngrids+i] += exps[k*BLKSIZE+i] * lz * xpows[lx] * ypows[ly] * zpows[lz-1];
                                        } }
                                } else {
                                        for (n = 0; n < degen; n++) {
                                                gtox[n*ngrids+i] = 0;
                                                gtoy[n*ngrids+i] = 0;
                                                gtoz[n*ngrids+i] = 0;
                                        }
                                }
                        }
                        gtox += ngrids * degen;
                        gtoy += ngrids * degen;
                        gtoz += ngrids * degen;
                }
        }
}
Ejemplo n.º 6
0
static void shell_eval_grid_ip_cart(double *gto, double *ri, double *exps,
                double *coord, double *alpha, double *coeff,
                int l, int np, int nc, int blksize)
{
        const int degen = _len_cart[l];
        const int gtosize = nc*degen*blksize;
        int lx, ly, lz, i, j, k, n;
        char mask[blksize+16];
        int *imask = (int *)mask;
        double xinv, yinv, zinv;
        double ax, ay, az, tmp, tmp1;
        double ce[6];
        double rre[10];
        double xpows[64];
        double ypows[64];
        double zpows[64];
        double *gridx = coord;
        double *gridy = coord+blksize;
        double *gridz = coord+blksize*2;
        double *gtox = gto;
        double *gtoy = gto + gtosize;
        double *gtoz = gto + gtosize * 2;
        double *exps_2a = exps + NPRIMAX*blksize;
        double         *gtox1, *gtox2, *gtox3, *gtox4,
               *gtox5, *gtox6, *gtox7, *gtox8, *gtox9;
        double         *gtoy1, *gtoy2, *gtoy3, *gtoy4,
               *gtoy5, *gtoy6, *gtoy7, *gtoy8, *gtoy9;
        double         *gtoz1, *gtoz2, *gtoz3, *gtoz4,
               *gtoz5, *gtoz6, *gtoz7, *gtoz8, *gtoz9;
        switch (l) {
        case 0:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        gtox[i] = exps_2a[i] * gridx[i];
                                        gtoy[i] = exps_2a[i] * gridy[i];
                                        gtoz[i] = exps_2a[i] * gridz[i];
                                } else {
                                        gtox[i] = 0;
                                        gtoy[i] = 0;
                                        gtoz[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize;
                        gtoy += blksize;
                        gtoz += blksize;
                }
                break;
        case 1:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        ax = exps_2a[i] * gridx[i];
                                        ay = exps_2a[i] * gridy[i];
                                        az = exps_2a[i] * gridz[i];
                                        gtox [i] = ax * gridx[i] + exps[i];
                                        gtox1[i] = ax * gridy[i];
                                        gtox2[i] = ax * gridz[i];
                                        gtoy [i] = ay * gridx[i];
                                        gtoy1[i] = ay * gridy[i] + exps[i];
                                        gtoy2[i] = ay * gridz[i];
                                        gtoz [i] = az * gridx[i];
                                        gtoz1[i] = az * gridy[i];
                                        gtoz2[i] = az * gridz[i] + exps[i];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 3;
                        gtoy += blksize * 3;
                        gtoz += blksize * 3;
                }
                break;
        case 2:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        gtox3 = gtox + blksize*3;
                        gtoy3 = gtoy + blksize*3;
                        gtoz3 = gtoz + blksize*3;
                        gtox4 = gtox + blksize*4;
                        gtoy4 = gtoy + blksize*4;
                        gtoz4 = gtoz + blksize*4;
                        gtox5 = gtox + blksize*5;
                        gtoy5 = gtoy + blksize*5;
                        gtoz5 = gtoz + blksize*5;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        tmp = exps_2a[i]/(exps[i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * exps[i];
                                        ce[1] = gridy[i] * exps[i];
                                        ce[2] = gridz[i] * exps[i];
                                        rre[0] = gridx[i] * ce[0]; // xx
                                        rre[1] = gridx[i] * ce[1]; // xy
                                        rre[2] = gridx[i] * ce[2]; // xz
                                        rre[3] = gridy[i] * ce[1]; // yy
                                        rre[4] = gridy[i] * ce[2]; // yz
                                        rre[5] = gridz[i] * ce[2]; // zz
                                        gtox [i] = ax * rre[0] + 2 * ce[0];
                                        gtox1[i] = ax * rre[1] +     ce[1];
                                        gtox2[i] = ax * rre[2] +     ce[2];
                                        gtox3[i] = ax * rre[3];
                                        gtox4[i] = ax * rre[4];
                                        gtox5[i] = ax * rre[5];
                                        gtoy [i] = ay * rre[0];
                                        gtoy1[i] = ay * rre[1] +     ce[0];
                                        gtoy2[i] = ay * rre[2];
                                        gtoy3[i] = ay * rre[3] + 2 * ce[1];
                                        gtoy4[i] = ay * rre[4] +     ce[2];
                                        gtoy5[i] = ay * rre[5];
                                        gtoz [i] = az * rre[0];
                                        gtoz1[i] = az * rre[1];
                                        gtoz2[i] = az * rre[2] +     ce[0];
                                        gtoz3[i] = az * rre[3];
                                        gtoz4[i] = az * rre[4] +     ce[1];
                                        gtoz5[i] = az * rre[5] + 2 * ce[2];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtox3[i] = 0;
                                        gtox4[i] = 0;
                                        gtox5[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoy3[i] = 0;
                                        gtoy4[i] = 0;
                                        gtoy5[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                        gtoz3[i] = 0;
                                        gtoz4[i] = 0;
                                        gtoz5[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 6;
                        gtoy += blksize * 6;
                        gtoz += blksize * 6;
                }
                break;
        case 3:
                for (k = 0; k < nc; k++) {
                        gtox1 = gtox + blksize*1;
                        gtoy1 = gtoy + blksize*1;
                        gtoz1 = gtoz + blksize*1;
                        gtox2 = gtox + blksize*2;
                        gtoy2 = gtoy + blksize*2;
                        gtoz2 = gtoz + blksize*2;
                        gtox3 = gtox + blksize*3;
                        gtoy3 = gtoy + blksize*3;
                        gtoz3 = gtoz + blksize*3;
                        gtox4 = gtox + blksize*4;
                        gtoy4 = gtoy + blksize*4;
                        gtoz4 = gtoz + blksize*4;
                        gtox5 = gtox + blksize*5;
                        gtoy5 = gtoy + blksize*5;
                        gtoz5 = gtoz + blksize*5;
                        gtox6 = gtox + blksize*6;
                        gtoy6 = gtoy + blksize*6;
                        gtoz6 = gtoz + blksize*6;
                        gtox7 = gtox + blksize*7;
                        gtoy7 = gtoy + blksize*7;
                        gtoz7 = gtoz + blksize*7;
                        gtox8 = gtox + blksize*8;
                        gtoy8 = gtoy + blksize*8;
                        gtoz8 = gtoz + blksize*8;
                        gtox9 = gtox + blksize*9;
                        gtoy9 = gtoy + blksize*9;
                        gtoz9 = gtoz + blksize*9;
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        tmp = exps_2a[i]/(exps[i]+1e-200);
                                        ax = tmp * gridx[i];
                                        ay = tmp * gridy[i];
                                        az = tmp * gridz[i];
                                        ce[0] = gridx[i] * gridx[i] * exps[i];
                                        ce[1] = gridx[i] * gridy[i] * exps[i];
                                        ce[2] = gridx[i] * gridz[i] * exps[i];
                                        ce[3] = gridy[i] * gridy[i] * exps[i];
                                        ce[4] = gridy[i] * gridz[i] * exps[i];
                                        ce[5] = gridz[i] * gridz[i] * exps[i];
                                        rre[0] = gridx[i] * ce[0]; // xxx
                                        rre[1] = gridx[i] * ce[1]; // xxy
                                        rre[2] = gridx[i] * ce[2]; // xxz
                                        rre[3] = gridx[i] * ce[3]; // xyy
                                        rre[4] = gridx[i] * ce[4]; // xyz
                                        rre[5] = gridx[i] * ce[5]; // xzz
                                        rre[6] = gridy[i] * ce[3]; // yyy
                                        rre[7] = gridy[i] * ce[4]; // yyz
                                        rre[8] = gridy[i] * ce[5]; // yzz
                                        rre[9] = gridz[i] * ce[5]; // zzz
                                        gtox [i] = ax * rre[0] + 3 * ce[0];
                                        gtox1[i] = ax * rre[1] + 2 * ce[1];
                                        gtox2[i] = ax * rre[2] + 2 * ce[2];
                                        gtox3[i] = ax * rre[3] +     ce[3];
                                        gtox4[i] = ax * rre[4] +     ce[4];
                                        gtox5[i] = ax * rre[5] +     ce[5];
                                        gtox6[i] = ax * rre[6];
                                        gtox7[i] = ax * rre[7];
                                        gtox8[i] = ax * rre[8];
                                        gtox9[i] = ax * rre[9];
                                        gtoy [i] = ay * rre[0];
                                        gtoy1[i] = ay * rre[1] +     ce[0];
                                        gtoy2[i] = ay * rre[2];
                                        gtoy3[i] = ay * rre[3] + 2 * ce[1];
                                        gtoy4[i] = ay * rre[4] +     ce[2];
                                        gtoy5[i] = ay * rre[5];
                                        gtoy6[i] = ay * rre[6] + 3 * ce[3];
                                        gtoy7[i] = ay * rre[7] + 2 * ce[4];
                                        gtoy8[i] = ay * rre[8] +     ce[5];
                                        gtoy9[i] = ay * rre[9];
                                        gtoz [i] = az * rre[0];
                                        gtoz1[i] = az * rre[1];
                                        gtoz2[i] = az * rre[2] +     ce[0];
                                        gtoz3[i] = az * rre[3];
                                        gtoz4[i] = az * rre[4] +     ce[1];
                                        gtoz5[i] = az * rre[5] + 2 * ce[2];
                                        gtoz6[i] = az * rre[6];
                                        gtoz7[i] = az * rre[7] +     ce[3];
                                        gtoz8[i] = az * rre[8] + 2 * ce[4];
                                        gtoz9[i] = az * rre[9] + 3 * ce[5];
                                } else {
                                        gtox [i] = 0;
                                        gtox1[i] = 0;
                                        gtox2[i] = 0;
                                        gtox3[i] = 0;
                                        gtox4[i] = 0;
                                        gtox5[i] = 0;
                                        gtox6[i] = 0;
                                        gtox7[i] = 0;
                                        gtox8[i] = 0;
                                        gtox9[i] = 0;
                                        gtoy [i] = 0;
                                        gtoy1[i] = 0;
                                        gtoy2[i] = 0;
                                        gtoy3[i] = 0;
                                        gtoy4[i] = 0;
                                        gtoy5[i] = 0;
                                        gtoy6[i] = 0;
                                        gtoy7[i] = 0;
                                        gtoy8[i] = 0;
                                        gtoy9[i] = 0;
                                        gtoz [i] = 0;
                                        gtoz1[i] = 0;
                                        gtoz2[i] = 0;
                                        gtoz3[i] = 0;
                                        gtoz4[i] = 0;
                                        gtoz5[i] = 0;
                                        gtoz6[i] = 0;
                                        gtoz7[i] = 0;
                                        gtoz8[i] = 0;
                                        gtoz9[i] = 0;
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox += blksize * 10;
                        gtoy += blksize * 10;
                        gtoz += blksize * 10;
                }
                break;
        default:
                for (k = 0; k < nc; k++) {
                        for (i = 0; i < blksize; i++) {
                                if (NOTZERO(exps[i])) {
                                        mask[i] = 1;
                                } else {
                                        mask[i] = 0;
                                }
                        }
                        for (i = 0; i < blksize/4; i++) {
                                if (imask[i]) {
        for (j = 0; j < 4; j++) {
                xpows[j] = 1;
                ypows[j] = 1;
                zpows[j] = 1;
        }
        for (lx = 1; lx <= l; lx++) {
                for (j = 0; j < 4; j++) {
                        xpows[lx*4+j] = xpows[(lx-1)*4+j] * gridx[i*4+j];
                        ypows[lx*4+j] = ypows[(lx-1)*4+j] * gridy[i*4+j];
                        zpows[lx*4+j] = zpows[(lx-1)*4+j] * gridz[i*4+j];
                }
        }
        for (lx = l, n = 0; lx >= 0; lx--) {
        for (ly = l - lx; ly >= 0; ly--, n++) {
                lz = l - lx - ly;
                for (j = 0; j < 4; j++) {
                        xinv = lx/(gridx[i*4+j]+1e-200);
                        yinv = ly/(gridy[i*4+j]+1e-200);
                        zinv = lz/(gridz[i*4+j]+1e-200);
                        tmp = exps_2a[i*4+j]/(exps[i*4+j]+1e-200);
                        tmp1 = xpows[lx*4+j] * ypows[ly*4+j]
                             * zpows[lz*4+j] * exps[i*4+j];
                        gtox[n*blksize+i*4+j] = (xinv + tmp*gridx[i*4+j]) * tmp1;
                        gtoy[n*blksize+i*4+j] = (yinv + tmp*gridy[i*4+j]) * tmp1;
                        gtoz[n*blksize+i*4+j] = (zinv + tmp*gridz[i*4+j]) * tmp1;
                }
        } }
                                } else {
        for (n = 0; n < degen; n++) {
                for (j = 0; j < 4; j++) {
                        gtox[n*blksize+i*4+j] = 0;
                        gtoy[n*blksize+i*4+j] = 0;
                        gtoz[n*blksize+i*4+j] = 0;
                }
        }
                                }
                        }
                        for (i = i*4; i < blksize; i++) {
                                if (mask[i]) {
                                        xpows[0] = 1;
                                        ypows[0] = 1;
                                        zpows[0] = 1;
                                        for (lx = 1; lx <= l; lx++) {
                                                xpows[lx] = xpows[lx-1] *gridx[i];
                                                ypows[lx] = ypows[lx-1] *gridy[i];
                                                zpows[lx] = zpows[lx-1] *gridz[i];
                                        }
                                        for (lx = l, n = 0; lx >= 0; lx--) {
                                        for (ly = l - lx; ly >= 0; ly--, n++) {
                                                lz = l - lx - ly;
                                                xinv = lx/(gridx[i]+1e-200);
                                                yinv = ly/(gridy[i]+1e-200);
                                                zinv = lz/(gridz[i]+1e-200);
                                                tmp = exps_2a[i]/(exps[i]+1e-200);
                                                tmp1 = xpows[lx] * ypows[ly]
                                                     * zpows[lz] * exps[i];
                                                gtox[n*blksize+i] = (xinv + tmp*gridx[i]) * tmp1;
                                                gtoy[n*blksize+i] = (yinv + tmp*gridy[i]) * tmp1;
                                                gtoz[n*blksize+i] = (zinv + tmp*gridz[i]) * tmp1;
                                        } }
                                } else {
                                        for (n = 0; n < degen; n++) {
                                                gtox[n*blksize+i] = 0;
                                                gtoy[n*blksize+i] = 0;
                                                gtoz[n*blksize+i] = 0;
                                        }
                                }
                        }
                        exps    += blksize;
                        exps_2a += blksize;
                        gtox    += blksize * degen;
                        gtoy    += blksize * degen;
                        gtoz    += blksize * degen;
                }
        }
}