void CVHFtimerev_adbak_iT(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { const int di = iend - istart; //const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pmat, *pmat1; if (tao[istart] < 0) { BeginTimeRevLoop(i, j); pblock = block + (i1-istart-1)+(j0-jstart)*di; pmat = mat + i0*nao + j0; pmat1 = pmat + nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j++) { pmat [i*nao+j] -= pblock[j*di-i ]; pmat1[i*nao+j] += pblock[j*di-i-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i1-istart-1)+(j0-jstart)*di; pmat = mat + i0*nao + j0; pmat1 = pmat + nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j++) { pmat [i*nao+j] += pblock[j*di-i ]; pmat1[i*nao+j] -= pblock[j*di-i-1]; } } EndTimeRevLoop(i, j); } }
void CVHFtimerev_adbak_jT(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { const int di = iend - istart; //const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pblock1, *pmat; if (tao[jstart] < 0) { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j1-jstart-1)*di; pblock1 = pblock - di; pmat = mat + i0*nao + j0; for (i = 0; i < i1-i0; i++) { for (j = 0; j < j1-j0; j+=2) { pmat[i*nao+j ] -= pblock [i-j*di]; pmat[i*nao+j+1] += pblock1[i-j*di]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j1-jstart-1)*di; pblock1 = pblock - di; pmat = mat + i0*nao + j0; for (i = 0; i < i1-i0; i++) { for (j = 0; j < j1-j0; j+=2) { pmat[i*nao+j ] += pblock [i-j*di]; pmat[i*nao+j+1] -= pblock1[i-j*di]; } } EndTimeRevLoop(i, j); } }
void CVHFtimerev_jT(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { const int di = iend - istart; //const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pblock1, *pmat; if (tao[jstart] < 0) { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j0-jstart)*di; pblock1 = pblock + di; pmat = mat + i0*nao+(j1-1); for (i = 0; i < i1-i0; i++) { for (j = 0; j < j1-j0; j+=2) { pblock [j*di+i] = pmat[i*nao-j ]; pblock1[j*di+i] =-pmat[i*nao-j-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j0-jstart)*di; pblock1 = pblock + di; pmat = mat + i0*nao+(j1-1); for (i = 0; i < i1-i0; i++) { for (j = 0; j < j1-j0; j+=2) { pblock [j*di+i] =-pmat[i*nao-j ]; pblock1[j*di+i] = pmat[i*nao-j-1]; } } EndTimeRevLoop(i, j); } }
void CVHFtimerev_iT(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { const int di = iend - istart; //const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pmat, *pmat1; if (tao[istart] < 0) { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j0-jstart)*di; pmat = mat + (i1-1)*nao+j0; pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j++) { pblock[j*di+i ] = pmat [-i*nao+j]; pblock[j*di+i+1] =-pmat1[-i*nao+j]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)+(j0-jstart)*di; pmat = mat + (i1-1)*nao+j0; pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j++) { pblock[j*di+i ] =-pmat [-i*nao+j]; pblock[j*di+i+1] = pmat1[-i*nao+j]; } } EndTimeRevLoop(i, j); } }
static void atimerev_mat(double complex *mat, int *tao, int *ao_loc, int nbas) { int nao = ao_loc[nbas]; int ish, jsh, istart, iend, jstart, jend; int i, j, i0, j0, i1, j1; double complex *pmat, *pmat1, *pbuf, *pbuf1; for (ish = 0; ish < nbas; ish++) { for (jsh = 0; jsh < ish; jsh++) { istart = ao_loc[ish ]; iend = ao_loc[ish+1]; jstart = ao_loc[jsh ]; jend = ao_loc[jsh+1]; if ((tao[jstart]<0) == (tao[istart]<0)) { BeginTimeRevLoop(i, j); pbuf = mat + j0 * nao + i0; pbuf1 = pbuf + nao; pmat = mat + (i1-1)*nao + (j1-1); pmat1 = pmat - nao; for (j = 0; j < j1-j0; j+=2) { for (i = 0; i < i1-i0; i+=2) { pbuf [j*nao+i ] =-pmat [-i*nao-j ]; pbuf1[j*nao+i ] = pmat [-i*nao-j-1]; pbuf [j*nao+i+1] = pmat1[-i*nao-j ]; pbuf1[j*nao+i+1] =-pmat1[-i*nao-j-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pbuf = mat + j0 * nao + i0; pbuf1 = pbuf + nao; pmat = mat + (i1-1)*nao + (j1-1); pmat1 = pmat - nao; for (j = 0; j < j1-j0; j+=2) { for (i = 0; i < i1-i0; i+=2) { pbuf [j*nao+i ] = pmat [-i*nao-j ]; pbuf1[j*nao+i ] =-pmat [-i*nao-j-1]; pbuf [j*nao+i+1] =-pmat1[-i*nao-j ]; pbuf1[j*nao+i+1] = pmat1[-i*nao-j-1]; } } EndTimeRevLoop(i, j); } } } }
/* * mat_{i,j} -= mat_{Tj,Ti} */ void CVHFtimerev_ijminus(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *mat0, *mat1; double complex *pblock, *pmat; double complex *pblock1, *pmat1; if ((tao[jstart]<0) == (tao[istart]<0)) { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)*dj + (j0-jstart); pblock1 = pblock + dj; mat0 = mat + i0*nao+j0; mat1 = mat0 + nao; pmat = mat + (j1-1)*nao + (i1-1); pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pblock [i*dj+j ] = mat0[i*nao+j ] - pmat [-j*nao-i ]; pblock [i*dj+j+1] = mat0[i*nao+j+1] + pmat1[-j*nao-i ]; pblock1[i*dj+j ] = mat1[i*nao+j ] + pmat [-j*nao-i-1]; pblock1[i*dj+j+1] = mat1[i*nao+j+1] - pmat1[-j*nao-i-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)*dj + (j0-jstart); pblock1 = pblock + dj; mat0 = mat + i0*nao+j0; mat1 = mat0 + nao; pmat = mat + (j1-1)*nao + (i1-1); pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pblock [i*dj+j ] = mat0[i*nao+j ] + pmat [-j*nao-i ]; pblock [i*dj+j+1] = mat0[i*nao+j+1] - pmat1[-j*nao-i ]; pblock1[i*dj+j ] = mat1[i*nao+j ] - pmat [-j*nao-i-1]; pblock1[i*dj+j+1] = mat1[i*nao+j+1] + pmat1[-j*nao-i-1]; } } EndTimeRevLoop(i, j); } }
/* * time reverse mat_{i,j} to block_{Tj,Ti} * mat[istart:iend,jstart:jend] -> block[:dj,:di] */ static void timerev_block_o1(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { //const int di = iend - istart; const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pmat; double complex *pblock1, *pmat1; if ((tao[jstart]<0) == (tao[istart]<0)) { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)*dj + (j0-jstart); pblock1 = pblock + dj; pmat = mat + (i1-1)*nao + (j1-1); pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pblock [i*dj+j ] = pmat [-i*nao-j ]; pblock [i*dj+j+1] =-pmat [-i*nao-j-1]; pblock1[i*dj+j ] =-pmat1[-i*nao-j ]; pblock1[i*dj+j+1] = pmat1[-i*nao-j-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i0-istart)*dj + (j0-jstart); pblock1 = pblock + dj; pmat = mat + (i1-1)*nao + (j1-1); pmat1 = pmat - nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pblock [i*dj+j ] =-pmat [-i*nao-j ]; pblock [i*dj+j+1] = pmat [-i*nao-j-1]; pblock1[i*dj+j ] = pmat1[-i*nao-j ]; pblock1[i*dj+j+1] =-pmat1[-i*nao-j-1]; } } EndTimeRevLoop(i, j); } }
void CVHFtimerev_adbak_block(double complex *block, double complex *mat, int *tao, int istart, int iend, int jstart, int jend, int nao) { //const int di = iend - istart; const int dj = jend - jstart; int i, j, i0, j0, i1, j1; double complex *pblock, *pmat; double complex *pblock1, *pmat1; if ((tao[jstart]<0) == (tao[istart]<0)) { BeginTimeRevLoop(i, j); pblock = block + (i1-istart-1)*dj + (j1-jstart-1); pblock1 = pblock - dj; pmat = mat + i0*nao + j0; pmat1 = pmat + nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pmat [i*nao+j ] += pblock [-i*dj-j ]; pmat [i*nao+j+1] -= pblock [-i*dj-j-1]; pmat1[i*nao+j ] -= pblock1[-i*dj-j ]; pmat1[i*nao+j+1] += pblock1[-i*dj-j-1]; } } EndTimeRevLoop(i, j); } else { BeginTimeRevLoop(i, j); pblock = block + (i1-istart-1)*dj + (j1-jstart-1); pblock1 = pblock - dj; pmat = mat + i0*nao + j0; pmat1 = pmat + nao; for (i = 0; i < i1-i0; i+=2) { for (j = 0; j < j1-j0; j+=2) { pmat [i*nao+j ] -= pblock [-i*dj-j ]; pmat [i*nao+j+1] += pblock [-i*dj-j-1]; pmat1[i*nao+j ] += pblock1[-i*dj-j ]; pmat1[i*nao+j+1] -= pblock1[-i*dj-j-1]; } } EndTimeRevLoop(i, j); } }