コード例 #1
0
ファイル: time_rev.c プロジェクト: chrinide/pyscf
/* index start from 1 */
void CVHFtimerev_map(int *tao, int *bas, int nbas)
{
        int k, l, n, m, k0, dj, ib, kpa;

        k0 = 0;
        k = 0;
        for (ib = 0; ib < nbas; ib++) {
                l = bas(ANG_OF,ib);
                kpa = bas(KAPPA_OF,ib);
                if (l%2 == 0) {
                        for (n = 0; n < bas(NCTR_OF,ib); n++) {
                                if (kpa >= 0) {
                                        dj = 2 * l;
                                        k0 = k;
                                        for (m = 0; m < dj; m+=2) {
                                                tao[k  ] =-(k0+dj-m);
                                                tao[k+1] = (k0+dj-m-1);
                                                k += 2;
                                        }
                                }
                                if (kpa <= 0) {
                                        dj = 2 * l + 2;
                                        k0 = k;
                                        for (m = 0; m < dj; m+=2) {
                                                tao[k  ] =-(k0+dj-m);
                                                tao[k+1] = (k0+dj-m-1);
                                                k += 2;
                                        }
                                }
                        }
                } else {
                        for (n = 0; n < bas(NCTR_OF,ib); n++) {
                                if (kpa >= 0) {
                                        dj = 2 * l;
                                        k0 = k;
                                        for (m = 0; m < dj; m+=2) {
                                                tao[k  ] = (k0+dj-m);
                                                tao[k+1] =-(k0+dj-m-1);
                                                k += 2;
                                        }
                                }
                                if (kpa <= 0) {
                                        dj = 2 * l + 2;
                                        k0 = k;
                                        for (m = 0; m < dj; m+=2) {
                                                tao[k  ] = (k0+dj-m);
                                                tao[k+1] =-(k0+dj-m-1);
                                                k += 2;
                                        }
                                }
                        }
                }
        }
}
コード例 #2
0
ファイル: g1e.c プロジェクト: sunqm/libcint
void CINTinit_int1e_EnvVars(CINTEnvVars *envs, FINT *ng, FINT *shls,
                           FINT *atm, FINT natm,
                           FINT *bas, FINT nbas, double *env)
{
        envs->natm = natm;
        envs->nbas = nbas;
        envs->atm = atm;
        envs->bas = bas;
        envs->env = env;
        envs->shls = shls;

        const FINT i_sh = shls[0];
        const FINT j_sh = shls[1];
        envs->i_l = bas(ANG_OF, i_sh);
        envs->j_l = bas(ANG_OF, j_sh);
        envs->x_ctr[0] = bas(NCTR_OF, i_sh);
        envs->x_ctr[1] = bas(NCTR_OF, j_sh);
        envs->nfi = (envs->i_l+1)*(envs->i_l+2)/2;
        envs->nfj = (envs->j_l+1)*(envs->j_l+2)/2;
        envs->nf = envs->nfi * envs->nfj;

        envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh));
        envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh));
        envs->common_factor = 1;

        envs->gbits = ng[GSHIFT];
        envs->ncomp_e1 = ng[POS_E1];
        envs->ncomp_tensor = ng[TENSOR];

        envs->li_ceil = envs->i_l + ng[IINC];
        envs->lj_ceil = envs->j_l + ng[JINC];
        envs->nrys_roots =(envs->li_ceil + envs->lj_ceil)/2 + 1;

        assert(i_sh < SHLS_MAX);
        assert(j_sh < SHLS_MAX);
        assert(envs->i_l < ANG_MAX);
        assert(envs->j_l < ANG_MAX);
        assert(bas(ATOM_OF,i_sh) >= 0);
        assert(bas(ATOM_OF,j_sh) >= 0);
        assert(bas(ATOM_OF,i_sh) < natm);
        assert(bas(ATOM_OF,j_sh) < natm);
        assert(envs->nrys_roots < MXRYSROOTS);

        FINT dli = envs->li_ceil + envs->lj_ceil + 1;
        FINT dlj = envs->lj_ceil + 1;
        envs->g_stride_i = 1;
        envs->g_stride_j = dli;
        envs->g_stride_k = dli * dlj;
        envs->g_size     = dli * dlj;
}
コード例 #3
0
ファイル: llcorehttputil.cpp プロジェクト: Belxjander/Kirito
HttpHandle requestPostWithLLSD(HttpRequest * request,
							   HttpRequest::policy_t policy_id,
							   HttpRequest::priority_t priority,
							   const std::string & url,
							   const LLSD & body,
							   HttpOptions * options,
							   HttpHeaders * headers,
							   HttpHandler * handler)
{
	HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);

	BufferArray * ba = new BufferArray();
	BufferArrayStream bas(ba);
	LLSDSerialize::toXML(body, bas);

	handle = request->requestPost(policy_id,
								  priority,
								  url,
								  ba,
								  options,
								  headers,
								  handler);
	ba->release();
	return handle;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: rstancioiu/France-ioi
int main()
{
   for(int i=0;i<9;++i)
      haut();
   droite();
   for(int j=0;j<5;++j)
   {
      for(int i=0;i<8;++i)
         droite();
      bas();
      for(int i=0;i<8;++i)
         gauche();
      if(j!=4)
         bas();
   }
   gauche();
}
コード例 #5
0
ファイル: snake_graph.c プロジェクト: TacOS-team/tacos
void thread_input() {
    char c;
    int r;
    c = getchar();
    switch(c) {
    case 'z':
        haut();
        break;
    case 's':
        bas();
        break;
    case 'd':
        droite();
        break;
    case 'q':
        gauche();
        break;
    case 27:
        r = 1;
        while ((c = getchar()) != -1) {
            if (c == 27) {
                r = 1;
                continue;
            }
            r = r * 128 + c;
        }
        switch (r) {
        case 28097:
            haut();
            break;
        case 28098:
            bas();
            break;
        case 28099:
            droite();
            break;
        case 28100:
            gauche();
            break;
        }

    }
}
コード例 #6
0
ファイル: optimizer.c プロジェクト: sunqm/libcint
void CINTOpt_set_non0coeff(CINTOpt *opt, FINT *atm, FINT natm,
                           FINT *bas, FINT nbas, double *env)
{
        FINT i, j, k, ip, io;
        if (opt->prim_offset == NULL) {
                opt->prim_offset = (FINT *)malloc(sizeof(FINT) * nbas);
                opt->tot_prim = 0;
                for (i = 0; i < nbas; i++) {
                        opt->prim_offset[i] = opt->tot_prim;
                        opt->tot_prim += bas(NPRIM_OF, i);
                }
        }

        FINT iprim, ictr;
        double *ci;
        double *non0coeff;
        FINT *non0idx;
        opt->non0ctr = (FINT *)malloc(sizeof(FINT) * opt->tot_prim);
        opt->non0idx = (FINT **)malloc(sizeof(FINT *) * opt->tot_prim);
        opt->non0coeff = (double **)malloc(sizeof(double *) * opt->tot_prim);
        for (i = 0; i < nbas; i++) {
                io = opt->prim_offset[i];
                iprim = bas(NPRIM_OF,i);
                ictr = bas(NCTR_OF,i);
                ci = env + bas(PTR_COEFF,i);
                for (ip = 0; ip < bas(NPRIM_OF,i); ip++) {
                        non0idx = (FINT *)malloc(sizeof(FINT) * ictr);
                        non0coeff = (double *)malloc(sizeof(double) * ictr);
                        opt->non0idx[io+ip] = non0idx;
                        opt->non0coeff[io+ip] = non0coeff;

                        for (j = 0, k = 0; j < ictr; j++) {
                                if (ci[iprim*j+ip] != 0) {
                                        non0coeff[k] = ci[iprim*j+ip];
                                        non0idx[k] = j;
                                        k++;
                                }
                        }
                        opt->non0ctr[io+ip] = k;
                }
        }
}
コード例 #7
0
ファイル: parcours.c プロジェクト: Kuroshiiba/prep-etna1
void	second_letter_one(t_grille grille, t_mots *mot, int i, int j)
{
  if ((j < grille.y) && (mot->word[1] == grille.tab[i][j + 1] && mot->trouve != 1))
    droite(grille, mot, i ,j);
 if ((j > 0) && (mot->word[1] == grille.tab[i][j - 1] && mot->trouve != 1))
    gauche(grille, mot, i ,j);
if ((i > 0) && (mot->word[1] == grille.tab[i - 1][j] && mot->trouve != 1))
      haut(grille, mot, i ,j);
if ((i < grille.x) && (mot->word[1] == grille.tab[i + 1][j] && mot->trouve != 1))
    bas(grille, mot, i ,j);
}
コード例 #8
0
ファイル: common.c プロジェクト: Albatroce/epita
int	nbr_cmp(t_nbr *n1, t_nbr *n2, int frac)
{
  int	i;
  int	len1, len2;
  char	*nbr1, *nbr2;

  check_zero(n1, frac);
  check_zero(n2, frac);
  nbr1 = frac ? n1->frac : n1->nbr;
  len1 = frac ? n1->frac_len : n1->nbr_len;
  nbr2 = frac ? n2->frac : n2->nbr;
  len2 = frac ? n2->frac_len : n2->nbr_len;
  if (len1 > len2)
    return 1;
  if (len1 < len2)
    return -1;
  for (i = 0; i < len1; i++)
    if (bas(nbr1[i], n1->base) > bas(nbr2[i], n2->base))
      return 1;
    else
      if (bas(nbr2[i], n2->base) > bas(nbr1[i], n1->base))
	return -1;
  return 0;
}
コード例 #9
0
ファイル: optimizer.c プロジェクト: BB-Goldstein/qcint
/* len(ng) = 8. The first 4 items are the increment adding to envs.li_ceil
 * ... envs.ll_ceil for shell i, j, k, l */
void
CINTOpt_set_index_xyz(CINTOpt *opt, FINT *ng,
                      const FINT *atm, const FINT natm,
                      const FINT *bas, const FINT nbas, const double *env)
{
        FINT i, j, k, l, ptr;
        FINT n = ANG_MAX*ANG_MAX*ANG_MAX*ANG_MAX;
        opt->index_xyz_array = (FINT **)malloc(sizeof(FINT *) * n);
        for (i = 0; i < n; i++) {
                opt->index_xyz_array[i] = NULL;
        }

        FINT max_l = 0;
        for (i = 0; i < nbas; i++) {
                max_l = MAX(max_l, bas(ANG_OF,i));
        }

        FINT fakenbas = max_l+1;
        FINT fakebas[BAS_SLOTS*fakenbas];
        memset(fakebas, 0, sizeof(FINT)*BAS_SLOTS*fakenbas);
        // fakebas only initializes ANG_OF, since the others does not
        // affect index_xyz
        for (i = 0; i <= max_l; i++) {
                fakebas[BAS_SLOTS*i+ANG_OF] = i;
        }

        CINTEnvVars envs;
        FINT shls[4];
        for (i = 0; i <= max_l; i++) {
        for (j = 0; j <= max_l; j++) {
        for (k = 0; k <= max_l; k++) {
        for (l = 0; l <= max_l; l++) {
                shls[0] = i; shls[1] = j; shls[2] = k; shls[3] = l;
                CINTinit_int2e_EnvVars(&envs, ng, shls,
                                       atm, natm, fakebas, fakenbas, env);

                ptr = i*ANG_MAX*ANG_MAX*ANG_MAX
                    + j*ANG_MAX*ANG_MAX
                    + k*ANG_MAX
                    + l;
                opt->index_xyz_array[ptr] = 
                        (FINT *)malloc(sizeof(FINT)*envs.nf*3);
                CINTg2e_index_xyz(opt->index_xyz_array[ptr], &envs);
        } } } }
}
コード例 #10
0
ファイル: llcorehttputil.cpp プロジェクト: Belxjander/Kirito
// *TODO:  Currently converts only from XML content.  A mode
// to convert using fromBinary() might be useful as well.  Mesh
// headers could use it.
bool responseToLLSD(HttpResponse * response, bool log, LLSD & out_llsd)
{
	// Convert response to LLSD
	BufferArray * body(response->getBody());
	if (! body || ! body->size())
	{
		return false;
	}

	LLCore::BufferArrayStream bas(body);
	LLSD body_llsd;
	S32 parse_status(LLSDSerialize::fromXML(body_llsd, bas, log));
	if (LLSDParser::PARSE_FAILURE == parse_status){
		return false;
	}
	out_llsd = body_llsd;
	return true;
}
コード例 #11
0
ファイル: ASMs1D.C プロジェクト: OPM/IFEM
void ASMs1D::extractBasis (double u, Vector& N, Matrix& dNdu,
			   Matrix3D& d2Ndu2) const
{
  int p1 = curv->order();

  RealArray bas(p1*3);
  curv->basis().computeBasisValues(u,&bas.front(),2);

  N.resize(p1);
  dNdu.resize(p1,1);
  d2Ndu2.resize(p1,1,1);
  for (int i = 1; i <= p1; i++)
  {
      N(i)        = bas[3*i-3];
     dNdu(i,1)    = bas[3*i-2];
    d2Ndu2(i,1,1) = bas[3*i-1];
  }
}
コード例 #12
0
ファイル: optimizer.c プロジェクト: sunqm/libcint
static FINT _make_fakebas(FINT *fakebas, FINT *bas, FINT nbas, double *env)
{
        FINT i;
        FINT max_l = 0;
        for (i = 0; i < nbas; i++) {
                max_l = MAX(max_l, bas(ANG_OF,i));
        }

        FINT fakenbas = max_l + 1;
        for (i = 0; i < BAS_SLOTS*fakenbas; i++) {
                fakebas[i] = 0;
        }
        // fakebas only initializes ANG_OF, since the others does not
        // affect index_xyz
        for (i = 0; i <= max_l; i++) {
                fakebas[BAS_SLOTS*i+ANG_OF] = i;
        }
        return max_l;
}
コード例 #13
0
ファイル: g3c1e.c プロジェクト: wu82/libcint
FINT CINTinit_int3c1e_EnvVars(CINTEnvVars *envs, const FINT *ng, const FINT *shls,
                             const FINT *atm, const FINT natm,
                             const FINT *bas, const FINT nbas, const double *env)
{
        envs->natm = natm;
        envs->nbas = nbas;
        envs->atm = atm;
        envs->bas = bas;
        envs->env = env;
        envs->shls = shls;

        const FINT i_sh = shls[0];
        const FINT j_sh = shls[1];
        const FINT k_sh = shls[2];
        envs->i_l = bas(ANG_OF, i_sh);
        envs->j_l = bas(ANG_OF, j_sh);
        envs->k_l = bas(ANG_OF, k_sh);
        envs->i_prim = bas(NPRIM_OF, i_sh);
        envs->j_prim = bas(NPRIM_OF, j_sh);
        envs->k_prim = bas(NPRIM_OF, k_sh);
        envs->i_ctr = bas(NCTR_OF, i_sh);
        envs->j_ctr = bas(NCTR_OF, j_sh);
        envs->k_ctr = bas(NCTR_OF, k_sh);
        envs->nfi = CINTlen_cart(envs->i_l);
        envs->nfj = CINTlen_cart(envs->j_l);
        envs->nfk = CINTlen_cart(envs->k_l);
        envs->nf = envs->nfi * envs->nfj * envs->nfk;

        envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh));
        envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh));
        envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh));

        envs->gbits = ng[GSHIFT];
        envs->ncomp_e1 = ng[POS_E1];
        envs->ncomp_tensor = ng[TENSOR];

        envs->li_ceil = envs->i_l + ng[IINC];
        envs->lj_ceil = envs->j_l + ng[JINC];
        envs->lk_ceil = envs->k_l + ng[KINC];

        envs->common_factor = SQRTPI * M_PI
                * CINTcommon_fac_sp(envs->i_l) * CINTcommon_fac_sp(envs->j_l)
                * CINTcommon_fac_sp(envs->k_l);

        FINT dli = envs->li_ceil + 1;
        FINT dlj = envs->lj_ceil + envs->lk_ceil + 1;
        FINT dlk = envs->lk_ceil + 1;
        envs->g_stride_i = 1;
        envs->g_stride_j = dli;
        envs->g_stride_k = dli * dlj;
        FINT nmax = envs->li_ceil + dlj;
        envs->g_size     = MAX(dli*dlj*dlk, dli*nmax);

        envs->rirj[0] = envs->ri[0] - envs->rj[0];
        envs->rirj[1] = envs->ri[1] - envs->rj[1];
        envs->rirj[2] = envs->ri[2] - envs->rj[2];
        return 0;
}
コード例 #14
0
ファイル: g3c2e.c プロジェクト: BalticPinguin/libcint
FINT CINTinit_int3c2e_EnvVars(CINTEnvVars *envs, const FINT *ng, const FINT *shls,
                             const FINT *atm, const FINT natm,
                             const FINT *bas, const FINT nbas, const double *env)
{
        envs->natm = natm;
        envs->nbas = nbas;
        envs->atm = atm;
        envs->bas = bas;
        envs->env = env;
        envs->shls = shls;

        const FINT i_sh = shls[0];
        const FINT j_sh = shls[1];
        const FINT k_sh = shls[2];
        envs->i_l = bas(ANG_OF, i_sh);
        envs->j_l = bas(ANG_OF, j_sh);
        envs->k_l = bas(ANG_OF, k_sh);
        envs->i_prim = bas(NPRIM_OF, i_sh);
        envs->j_prim = bas(NPRIM_OF, j_sh);
        envs->k_prim = bas(NPRIM_OF, k_sh);
        envs->i_ctr = bas(NCTR_OF, i_sh);
        envs->j_ctr = bas(NCTR_OF, j_sh);
        envs->k_ctr = bas(NCTR_OF, k_sh);
        envs->nfi = CINTlen_cart(envs->i_l);
        envs->nfj = CINTlen_cart(envs->j_l);
        envs->nfk = CINTlen_cart(envs->k_l);
        envs->nf = envs->nfi * envs->nfk * envs->nfj;

        envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh));
        envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh));
        envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh));

        envs->common_factor = (M_PI*M_PI*M_PI)*2/SQRTPI
                * CINTcommon_fac_sp(envs->i_l) * CINTcommon_fac_sp(envs->j_l)
                * CINTcommon_fac_sp(envs->k_l);

        envs->gbits = ng[GSHIFT];
        envs->ncomp_e1 = ng[POS_E1];
        envs->ncomp_tensor = ng[TENSOR];

        envs->li_ceil = envs->i_l + ng[IINC];
        envs->lj_ceil = envs->j_l + ng[JINC];
        envs->lk_ceil = envs->k_l + ng[KINC];
        envs->ll_ceil = 0; // to reuse CINTg0_2e_2d
        envs->nrys_roots =(envs->li_ceil + envs->lj_ceil
                         + envs->lk_ceil)/2 + 1;

        assert(i_sh < SHLS_MAX);
        assert(j_sh < SHLS_MAX);
        assert(k_sh < SHLS_MAX);
        assert(envs->i_l < ANG_MAX);
        assert(envs->j_l < ANG_MAX);
        assert(envs->k_l < ANG_MAX);
        assert(envs->i_ctr < NCTR_MAX);
        assert(envs->j_ctr < NCTR_MAX);
        assert(envs->k_ctr < NCTR_MAX);
        assert(envs->i_prim < NPRIM_MAX);
        assert(envs->j_prim < NPRIM_MAX);
        assert(envs->k_prim < NPRIM_MAX);
        assert(envs->i_prim >= envs->i_ctr);
        assert(envs->j_prim >= envs->j_ctr);
        assert(envs->k_prim >= envs->k_ctr);
        assert(bas(ATOM_OF,i_sh) >= 0);
        assert(bas(ATOM_OF,j_sh) >= 0);
        assert(bas(ATOM_OF,k_sh) >= 0);
        assert(bas(ATOM_OF,i_sh) < natm);
        assert(bas(ATOM_OF,j_sh) < natm);
        assert(bas(ATOM_OF,k_sh) < natm);
        assert(envs->nrys_roots < MXRYSROOTS);

        CINTset_g3c2e_params(envs);
        return 0;
}
コード例 #15
0
ファイル: optimizer.c プロジェクト: sunqm/libcint
void CINTOpt_setij(CINTOpt *opt, FINT *ng,
                   FINT *atm, FINT natm,
                   FINT *bas, FINT nbas, double *env)
{
        FINT i, j, ip, jp, io, jo, off;
        if (opt->prim_offset == NULL) {
                opt->prim_offset = (FINT *)malloc(sizeof(FINT) * nbas);
                opt->tot_prim = 0;
                for (i = 0; i < nbas; i++) {
                        opt->prim_offset[i] = opt->tot_prim;
                        opt->tot_prim += bas(NPRIM_OF, i);
                }
        }

        FINT ijkl_inc;
        if ((ng[IINC]+ng[JINC]) > (ng[KINC]+ng[LINC])) {
                ijkl_inc = ng[IINC] + ng[JINC];
        } else {
                ijkl_inc = ng[KINC] + ng[LINC];
        }

        FINT iprim, ictr, jprim, jctr, il, jl;
        double eij, aij, rr, maxci, maxcj, rirj_g4d;
        double *ai, *aj, *ri, *rj, *ci, *cj;
        double *expij, *rij;
        FINT *cceij;
        opt->expij = (double **)malloc(sizeof(double *) * opt->tot_prim);
        opt->rij = (double **)malloc(sizeof(double *) * opt->tot_prim);
        opt->cceij = (FINT **)malloc(sizeof(FINT *) * opt->tot_prim);
        for (i = 0; i < nbas; i++) {
                ri = env + atm(PTR_COORD,bas(ATOM_OF,i));
                ai = env + bas(PTR_EXP,i);
                io = opt->prim_offset[i];
                iprim = bas(NPRIM_OF,i);
                ictr = bas(NCTR_OF,i);
                ci = env + bas(PTR_COEFF,i);
// For derivative/dipole operator, the l-value in g2e is virtually increased
                il = bas(ANG_OF,i);
                for (ip = 0; ip < bas(NPRIM_OF,i); ip++) {
                        maxci = max_pgto_coeff(ci, iprim, ictr, ip);
                        maxci = maxci / CINTgto_norm(bas(ANG_OF,i), ai[ip]);
                        expij = (double *)malloc(sizeof(double)*opt->tot_prim);
                        rij = (double *)malloc(sizeof(double)*opt->tot_prim*3);
                        cceij = (FINT *)malloc(sizeof(FINT) * opt->tot_prim);
                        opt->expij[io+ip] = expij;
                        opt->rij[io+ip] = rij;
                        opt->cceij[io+ip] = cceij;

                        for (j = 0; j < nbas; j++) {
                                rj = env + atm(PTR_COORD,bas(ATOM_OF,j));
                                aj = env + bas(PTR_EXP,j);
                                jo = opt->prim_offset[j];
                                jprim = bas(NPRIM_OF,j);
                                jctr = bas(NCTR_OF,j);
                                cj = env + bas(PTR_COEFF,j);
                                jl = bas(ANG_OF,j);
                                rr = (ri[0]-rj[0])*(ri[0]-rj[0])
                                   + (ri[1]-rj[1])*(ri[1]-rj[1])
                                   + (ri[2]-rj[2])*(ri[2]-rj[2]);
                                for (jp = 0; jp < bas(NPRIM_OF,j); jp++) {
                                        maxcj = max_pgto_coeff(cj, jprim, jctr, jp);
                                        maxcj = maxcj / CINTgto_norm(bas(ANG_OF,j), aj[jp]);
                                        aij = ai[ip] + aj[jp];
                                        off = jo + jp;
                                        eij = rr * ai[ip] * aj[jp] / aij;
                                        expij[off] = exp(-eij);
                                        rij[off*3+0] = (ai[ip]*ri[0] + aj[jp]*rj[0]) / aij;
                                        rij[off*3+1] = (ai[ip]*ri[1] + aj[jp]*rj[1]) / aij;
                                        rij[off*3+2] = (ai[ip]*ri[2] + aj[jp]*rj[2]) / aij;

        if (maxci*maxcj == 0) {
                cceij[off] = 750;
        } else if (rr > 1e-12) {
/* value estimation based on g0_2e_2d and g0_xx2d_4d,
 * value/exp(-eij) ~< (il+jl+2)!*(aij/2)^(il+jl)*(ri_or_rj-rij)^(ij+jl)*rirj^max(il,jl)
 *                 ~< (il+jl+2)!*(aij/2)^(il+jl)*|rirj|^((il+jl)+max(il,jl))
 * But in practice, |rirj|^((il+jl)/2) is large enough to cover all other factors */
                rirj_g4d = pow(rr+0.5, (il+jl+ijkl_inc+1)/2);
                cceij[off] = eij - log(maxci*maxcj*rirj_g4d);
        } else {
/* If basis on the same center, include the (ss|ss)^{1/2} contribution
 * (ss|ss) = 2\sqrt{aij/pi} */
                cceij[off] = -log(maxci*maxcj) - log(aij)/4;
        }
                                }
                        }
                }
        }
}
コード例 #16
0
ファイル: cint1e.c プロジェクト: sunqm/NWints
/*
 * 1e GTO integral basic loop for < i|1/r|j>, no 1/r
 * if nuc_id >= 0: nuclear attraction, use nuclear model
 * if nuc_id <  0: 1/r potential, do not use nuclear model
 */
FINT CINT1e_nuc_loop(double *gctr, CINTEnvVars *envs, double fac, FINT nuc_id)
{
        const FINT *shls  = envs->shls;
        const FINT *atm = envs->atm;
        const FINT *bas = envs->bas;
        const double *env = envs->env;
        const FINT i_sh = shls[0];
        const FINT j_sh = shls[1];
        const FINT i_l = envs->i_l;
        const FINT j_l = envs->j_l;
        const FINT i_ctr = envs->i_ctr;
        const FINT j_ctr = envs->j_ctr;
        const FINT nfi = envs->nfi;
        const FINT nfj = envs->nfj;
        const FINT nf = envs->nf;
        const FINT n_comp = envs->ncomp_e1 * envs->ncomp_tensor;
        const double *ri = envs->ri;
        const double *rj = envs->rj;
        const double *ai = env + bas(PTR_EXP, i_sh);
        const double *aj = env + bas(PTR_EXP, j_sh);
        const double *ci = env + bas(PTR_COEFF, i_sh);
        const double *cj = env + bas(PTR_COEFF, j_sh);
        FINT ip, jp, i, n;
        FINT has_value = 0;
        double tau;
        const double *cr;
        double (*f_nuc_mod)();
        double x, u[MXRYSROOTS], w[MXRYSROOTS];
        FINT *const idx = malloc(sizeof(FINT) * nf * 3);
        double rij[3], aij, dij, eij, rrij, t2;
        double *g = malloc(sizeof(double) * envs->g_size * 3
                           * ((1<<envs->gbits)+1)); // +1 as buffer
        double *const gout = malloc(sizeof(double) * nf * n_comp);
        double *const gctri = malloc(sizeof(double) * nf * i_ctr * n_comp);

        if (nuc_id < 0) {
                cr = &env[PTR_RINV_ORIG];
                f_nuc_mod = CINTno_nuc_mod;
        } else {
                cr = &env[atm(PTR_COORD, nuc_id)],
                f_nuc_mod = CINTnuc_mod;
        }

        CINTg1e_index_xyz(idx, envs);

        rrij = CINTsquare_dist(ri, rj);
        fac *= 2 * M_PI * CINTcommon_fac_sp(i_l) * CINTcommon_fac_sp(j_l);

        for (jp = 0; jp < envs->j_prim; jp++) {
                envs->aj = aj[jp];
                n = nf * i_ctr * n_comp;
                CINTdset0(n, gctri);
                for (ip = 0; ip < envs->i_prim; ip++) {
                        envs->ai = ai[ip];
                        aij = ai[ip] + aj[jp];
                        eij = (ai[ip] * aj[jp] / aij) * rrij;
                        if (eij > EXPCUTOFF)
                                continue;
                        has_value = 1;

                        rij[0] = (ai[ip] * ri[0] + aj[jp] * rj[0]) / aij;
                        rij[1] = (ai[ip] * ri[1] + aj[jp] * rj[1]) / aij;
                        rij[2] = (ai[ip] * ri[2] + aj[jp] * rj[2]) / aij;
                        tau = (*f_nuc_mod)(aij, nuc_id, atm, env);
                        x = aij * CINTsquare_dist(rij, cr) * tau * tau;
                        CINTrys_roots(envs->nrys_roots, x, u, w);

                        dij = exp(-eij) / aij * fac;
                        CINTdset0(nf * n_comp, gout);
                        for (i = 0; i < envs->nrys_roots; i++) {
                                t2 = u[i] / (1 + u[i]) * tau * tau;
                                CINTg_nuc(g, aij, rij, cr, t2,
                                          dij * w[i] * tau, envs);

                                (*envs->f_gout)(g, gout, idx, envs);
                        }

                        n = nf * n_comp;
                        CINTprim_to_ctr(gctri, n, gout, 1, envs->i_prim,
                                        i_ctr, ci+ip);
                }
                n = nf * i_ctr;
                CINTprim_to_ctr(gctr, n, gctri, n_comp, envs->j_prim,
                                j_ctr, cj+jp);
        }
        free(g);
        free(idx);
        free(gout);
        free(gctri);

        return has_value;
}
コード例 #17
0
ファイル: Dijkstra.cpp プロジェクト: brieucdnl/JV-IN
void trouver_chemin(GameElements::Map * map, Math::Vector2<int> & my_cell,Math::Vector2<int> & target_cell,std::vector<Math::Vector2<int>> & chemin)
{
	
	value_tab[my_cell[0]][my_cell[1]] =0;
	Math::Vector2<int> current_cell = target_cell;
	int val_h = 0,val_b = 0,val_d = 0,val_g = 0;
	while(!(current_cell[0] == my_cell[0] && current_cell[1] == my_cell[1]))
	{
		val_h =0;
		val_b =0;
		val_g =0;
		val_d =0;
		//calculer les index des cellules autour
		Math::Vector2<int> haut(current_cell);
		Math::Vector2<int> bas(current_cell);
		Math::Vector2<int> gauche(current_cell);
		Math::Vector2<int> droite(current_cell);
		Math::Vector2<int> choice(current_cell);

		if(bas[0] < map->height()-1) bas[0] ++;
		if(haut[0] > 0) haut[0] --;
		if(gauche[1] > 0) gauche[1] --;
		if(droite[1] < map->width()-1) droite[1] ++;

		int min_val = value_tab[current_cell[0]][current_cell[1]];
		if(haut[0] != current_cell[0]){val_h = value_tab[haut[0]][haut[1]];}
		if(gauche[1] != current_cell[1]){val_g = value_tab[gauche[0]][gauche[1]];}
		if(droite[1] != current_cell[1]){val_d = value_tab[droite[0]][droite[1]];}
		if(bas[0] != current_cell[0]){ val_b = value_tab[bas[0]][bas[1]] ;}
		
		//rechercher la cellule avec la valeur min la plus proche
		if(val_h == -1 && val_d == -1 && val_g == -1 && val_b == -1){std::cout << "CELLULE NON ATTEINTE !! " << std::endl;break;}

		else{
			if(val_h != -1)
				if(min_val > val_h)
				{
					min_val = val_h;					
					choice = haut;
				}
			

			if(val_g != -1)
				if(min_val > val_g)
				{
					min_val = val_g;
					choice = gauche;
				}

			if(val_d != -1)
				if(min_val > val_d)
				{
					min_val = val_d;
					choice = droite;
				}

			if(val_b != -1)
				if(min_val > val_b)
				{
					min_val = val_b;
					choice = bas;
				}
			current_cell = choice ;
			chemin.push_back(choice);
		}	
	}
}
コード例 #18
0
ファイル: optimizer.c プロジェクト: BB-Goldstein/qcint
void CINTOpt_setij(CINTOpt *opt, FINT *ng,
                   const FINT *atm, const FINT natm,
                   const FINT *bas, const FINT nbas, const double *env)
{
        FINT i, j, ip, jp, io, jo, off;
        if (!opt->prim_offset) {
                opt->prim_offset = (FINT *)malloc(sizeof(FINT) * nbas);
                opt->tot_prim = 0;
                for (i = 0; i < nbas; i++) {
                        opt->prim_offset[i] = opt->tot_prim;
                        opt->tot_prim += bas(NPRIM_OF, i);
                }
        }

        FINT ik_inc, jl_inc;
        if ((ng[IINC]+ng[JINC]) > (ng[KINC]+ng[LINC])) {
                ik_inc = ng[IINC];
                jl_inc = ng[JINC];
        } else {
                ik_inc = ng[KINC];
                jl_inc = ng[LINC];
        }

        FINT iprim, ictr, jprim, jctr, il, jl;
        double eij, aij, rr, maxci, maxcj, rirj_g4d;
        const double *ai, *aj, *ri, *rj, *ci, *cj;
        double *expij, *rij;
        FINT *cceij;
        opt->expij = (double **)malloc(sizeof(double *) * opt->tot_prim);
        opt->rij = (double **)malloc(sizeof(double *) * opt->tot_prim);
        opt->cceij = (FINT **)malloc(sizeof(FINT *) * opt->tot_prim);
        for (i = 0; i < nbas; i++) {
                ri = env + atm(PTR_COORD,bas(ATOM_OF,i));
                ai = env + bas(PTR_EXP,i);
                io = opt->prim_offset[i];
                iprim = bas(NPRIM_OF,i);
                ictr = bas(NCTR_OF,i);
                ci = env + bas(PTR_COEFF,i);
// For derivative/dipole operator, the l-value in g2e is virtually increased
                il = bas(ANG_OF,i) + ik_inc;
                for (ip = 0; ip < bas(NPRIM_OF,i); ip++) {
                        maxci = max_pgto_coeff(ci, iprim, ictr, ip);
                        maxci = maxci / CINTgto_norm(il, ai[ip]);
                        expij = (double *)malloc(sizeof(double)*opt->tot_prim);
                        rij = (double *)malloc(sizeof(double)*opt->tot_prim*3);
                        cceij = (FINT *)malloc(sizeof(FINT) * opt->tot_prim);
                        opt->expij[io+ip] = expij;
                        opt->rij[io+ip] = rij;
                        opt->cceij[io+ip] = cceij;

                        for (j = 0; j < nbas; j++) {
                                rj = env + atm(PTR_COORD,bas(ATOM_OF,j));
                                aj = env + bas(PTR_EXP,j);
                                jo = opt->prim_offset[j];
                                jprim = bas(NPRIM_OF,j);
                                jctr = bas(NCTR_OF,j);
                                cj = env + bas(PTR_COEFF,j);
                                jl = bas(ANG_OF,j) + jl_inc;
                                rr = (ri[0]-rj[0])*(ri[0]-rj[0])
                                   + (ri[1]-rj[1])*(ri[1]-rj[1])
                                   + (ri[2]-rj[2])*(ri[2]-rj[2]);
                                for (jp = 0; jp < bas(NPRIM_OF,j); jp++) {
                                        maxcj = max_pgto_coeff(cj, jprim, jctr, jp);
                                        maxcj = maxcj/CINTgto_norm(jl, aj[jp]);
                                        aij = ai[ip] + aj[jp];
                                        off = jo + jp;
                                        eij = rr * ai[ip] * aj[jp] / aij;
                                        expij[off] = exp(-eij);
                                        rij[off*3+0] = (ai[ip]*ri[0] + aj[jp]*rj[0]) / aij;
                                        rij[off*3+1] = (ai[ip]*ri[1] + aj[jp]*rj[1]) / aij;
                                        rij[off*3+2] = (ai[ip]*ri[2] + aj[jp]*rj[2]) / aij;
/* estimation of the value, based on g0_2e_2d and g0_xx2d_4d,
 * value ~< exp(-eij)*(il+jl+2)!*(aij/2)^(il+jl)*(ri_or_rj-rij)^(ij+jl)*rirj^max(il,jl)
 *       ~< *       exp(-eij)*(il+jl+2)!*(aij/2)^(il+jl)*rirj^((il+jl)+max(il,jl))
 * But in practice, rirj^((il+jl)/2) is usually large enough to cover all other factors */
/* rr+1 to prevent log() diverge when i,j on same center */
                                        rirj_g4d = pow((rr+1), (il+jl+1)/2);
/*cceij[off] =-log(expij[off]*maxci*maxcj*rirj_g4d);
  when eij is big, expij == 0, singular value in cceij */
                                        cceij[off] = eij - log(maxci*maxcj*rirj_g4d);
                                }
                        }
                }
        }
}
コード例 #19
0
ファイル: g2e_stg.c プロジェクト: sunqm/qcint
void CINTinit_int2e_stg_EnvVars(CINTEnvVars *envs, int *ng, int *shls,
                                int *atm, int natm, int *bas, int nbas, double *env)
{
        envs->natm = natm;
        envs->nbas = nbas;
        envs->atm = atm;
        envs->bas = bas;
        envs->env = env;
        envs->shls = shls;

        int i_sh = shls[0];
        int j_sh = shls[1];
        int k_sh = shls[2];
        int l_sh = shls[3];
        envs->i_l = bas(ANG_OF, i_sh);
        envs->j_l = bas(ANG_OF, j_sh);
        envs->k_l = bas(ANG_OF, k_sh);
        envs->l_l = bas(ANG_OF, l_sh);
        envs->x_ctr[0] = bas(NCTR_OF, i_sh);
        envs->x_ctr[1] = bas(NCTR_OF, j_sh);
        envs->x_ctr[2] = bas(NCTR_OF, k_sh);
        envs->x_ctr[3] = bas(NCTR_OF, l_sh);
        envs->nfi = (envs->i_l+1)*(envs->i_l+2)/2;
        envs->nfj = (envs->j_l+1)*(envs->j_l+2)/2;
        envs->nfk = (envs->k_l+1)*(envs->k_l+2)/2;
        envs->nfl = (envs->l_l+1)*(envs->l_l+2)/2;
        envs->nf = envs->nfi * envs->nfk * envs->nfl * envs->nfj;
        envs->common_factor = 1;

        envs->gbits = ng[GSHIFT];
        envs->ncomp_e1 = ng[POS_E1];
        envs->ncomp_e2 = ng[POS_E2];
        envs->ncomp_tensor = ng[TENSOR];

        envs->li_ceil = envs->i_l + ng[IINC];
        envs->lj_ceil = envs->j_l + ng[JINC];
        envs->lk_ceil = envs->k_l + ng[KINC];
        envs->ll_ceil = envs->l_l + ng[LINC];

        envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh));
        envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh));
        envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh));
        envs->rl = env + atm(PTR_COORD, bas(ATOM_OF, l_sh));

        // ceil(L_tot/2) + 1
        int nroots = (envs->li_ceil + envs->lj_ceil +
                      envs->lk_ceil + envs->ll_ceil + 3)/2;
        envs->nrys_roots = nroots;
        assert(nroots < MXRYSROOTS);

        int dli, dlj, dlk, dll;
        int ibase = envs->li_ceil > envs->lj_ceil;
        int kbase = envs->lk_ceil > envs->ll_ceil;
        if (kbase) {
                if (ibase) {
                        envs->f_g0_2d4d = &CINTg0_2e_ik2d4d;
                        envs->f_g0_2d4d_simd1 = &CINTg0_2e_ik2d4d_simd1;
                } else {
                        envs->f_g0_2d4d = &CINTg0_2e_kj2d4d;
                        envs->f_g0_2d4d_simd1 = &CINTg0_2e_kj2d4d_simd1;
                }
        } else {
                if (ibase) {
                        envs->f_g0_2d4d = &CINTg0_2e_il2d4d;
                        envs->f_g0_2d4d_simd1 = &CINTg0_2e_il2d4d_simd1;
                } else {
                        envs->f_g0_2d4d = &CINTg0_2e_lj2d4d;
                        envs->f_g0_2d4d_simd1 = &CINTg0_2e_lj2d4d_simd1;
                }
        }
        envs->f_g0_2e = &CINTg0_2e_stg;
        envs->f_g0_2e_simd1 = &CINTg0_2e_stg_simd1;

        if (kbase) {
                dlk = envs->lk_ceil + envs->ll_ceil + 1;
                dll = envs->ll_ceil + 1;
        } else {
                dlk = envs->lk_ceil + 1;
                dll = envs->lk_ceil + envs->ll_ceil + 1;
        }

        if (ibase) {
                dli = envs->li_ceil + envs->lj_ceil + 1;
                dlj = envs->lj_ceil + 1;
        } else {
                dli = envs->li_ceil + 1;
                dlj = envs->li_ceil + envs->lj_ceil + 1;
        }
        envs->g_stride_i = nroots;
        envs->g_stride_k = nroots * dli;
        envs->g_stride_l = nroots * dli * dlk;
        envs->g_stride_j = nroots * dli * dlk * dll;
        envs->g_size     = nroots * dli * dlk * dll * dlj;

        if (kbase) {
                envs->g2d_klmax = envs->g_stride_k;
                envs->rx_in_rklrx = envs->rk;
                envs->rkrl[0] = envs->rk[0] - envs->rl[0];
                envs->rkrl[1] = envs->rk[1] - envs->rl[1];
                envs->rkrl[2] = envs->rk[2] - envs->rl[2];
        } else {
                envs->g2d_klmax = envs->g_stride_l;
                envs->rx_in_rklrx = envs->rl;
                envs->rkrl[0] = envs->rl[0] - envs->rk[0];
                envs->rkrl[1] = envs->rl[1] - envs->rk[1];
                envs->rkrl[2] = envs->rl[2] - envs->rk[2];
        }

        if (ibase) {
                envs->g2d_ijmax = envs->g_stride_i;
                envs->rx_in_rijrx = envs->ri;
                envs->rirj[0] = envs->ri[0] - envs->rj[0];
                envs->rirj[1] = envs->ri[1] - envs->rj[1];
                envs->rirj[2] = envs->ri[2] - envs->rj[2];
        } else {
                envs->g2d_ijmax = envs->g_stride_j;
                envs->rx_in_rijrx = envs->rj;
                envs->rirj[0] = envs->rj[0] - envs->ri[0];
                envs->rirj[1] = envs->rj[1] - envs->ri[1];
                envs->rirj[2] = envs->rj[2] - envs->ri[2];
        }
}
コード例 #20
0
ファイル: cint2c2e.c プロジェクト: BalticPinguin/libcint
FINT CINT2c2e_loop_nopt(double *gctr, CINTEnvVars *envs)
{
        const FINT *shls  = envs->shls;
        const FINT *bas = envs->bas;
        const double *env = envs->env;
        const FINT i_sh = shls[0];
        const FINT k_sh = shls[1];
        const FINT i_ctr  = envs->i_ctr;
        const FINT k_ctr  = envs->k_ctr;
        const double *ai = env + bas(PTR_EXP, i_sh);
        const double *ak = env + bas(PTR_EXP, k_sh);
        const double *ci = env + bas(PTR_COEFF, i_sh);
        const double *ck = env + bas(PTR_COEFF, k_sh);
        const FINT n_comp = envs->ncomp_tensor;
        double fac1i, fac1k;
        FINT ip, kp;
        FINT empty[3] = {1, 1, 1};
        FINT *iempty = empty + 0;
        FINT *kempty = empty + 1;
        FINT *gempty = empty + 2;
        /* COMMON_ENVS_AND_DECLARE end */
        const FINT nc = i_ctr * k_ctr;
        const FINT leng = envs->g_size * 3 * ((1<<envs->gbits)+1);
        const FINT lenk = envs->nf * nc * n_comp; // gctrk
        const FINT leni = envs->nf * i_ctr * n_comp; // gctri
        const FINT len0 = envs->nf * n_comp; // gout
        const FINT len = leng + lenk + leni + len0;
        double *const g = (double *)malloc(sizeof(double)*len);
        double *g1 = g + leng;
        double *gout, *gctri, *gctrk;

        if (n_comp == 1) {
                gctrk = gctr;
        } else {
                gctrk = g1;
                g1 += lenk;
        }
        if (k_ctr == 1) {
                gctri = gctrk;
                iempty = kempty;
        } else {
                gctri = g1;
                g1 += leni;
        }
        if (i_ctr == 1) {
                gout = gctri;
                gempty = iempty;
        } else {
                gout = g1;
        }

        envs->idx = (FINT *)malloc(sizeof(FINT) * envs->nf * 3);
        CINTg1e_index_xyz(envs->idx, envs);

        *kempty = 1;
        for (kp = 0; kp < envs->k_prim; kp++) {
                envs->ak = ak[kp];
                envs->akl = ak[kp]; // to use CINTg0_2e
                if (k_ctr == 1) {
                        fac1k = envs->common_factor * ck[kp];
                } else {
                        fac1k = envs->common_factor;
                        *iempty = 1;
                }
                for (ip = 0; ip < envs->i_prim; ip++) {
                        envs->ai = ai[ip];
                        envs->aij = ai[ip];
                        if (i_ctr == 1) {
                                fac1i = fac1k*ci[ip];
                        } else {
                                fac1i = fac1k;
                        }
                        CINT2e_core(gout, g, fac1i, envs, *gempty);
                        PRIM2CTR0(i, gout, envs->nf*n_comp);
                } // end loop i_prim
                if (!*iempty) {
                        PRIM2CTR0(k, gctri, envs->nf*i_ctr*n_comp);
                }
        } // end loop k_prim

        if (n_comp > 1 && !*kempty) {
                CINTdmat_transpose(gctr, gctrk, envs->nf*nc, n_comp);
        }
        free(g);
        free(envs->idx);
        return !*kempty;
}
コード例 #21
0
ファイル: cint1e.c プロジェクト: sunqm/NWints
/*
 * 1e GTO integral basic loop for < i|j>, no 1/r
 */
FINT CINT1e_loop(double *gctr, CINTEnvVars *envs, double fac)
{
        const FINT *shls  = envs->shls;
        const FINT *atm = envs->atm;
        const FINT *bas = envs->bas;
        const double *env = envs->env;
        const FINT i_sh = shls[0];
        const FINT j_sh = shls[1];
        const FINT i_l = envs->i_l;
        const FINT j_l = envs->j_l;
        const FINT i_ctr = envs->i_ctr;
        const FINT j_ctr = envs->j_ctr;
        const FINT nfi = envs->nfi;
        const FINT nfj = envs->nfj;
        const FINT n_comp = envs->ncomp_e1 * envs->ncomp_tensor;
        const FINT nf = envs->nf;
        const double *ri = envs->ri;
        const double *rj = envs->rj;
        const double *ai = env + bas(PTR_EXP, i_sh);
        const double *aj = env + bas(PTR_EXP, j_sh);
        const double *ci = env + bas(PTR_COEFF, i_sh);
        const double *cj = env + bas(PTR_COEFF, j_sh);
        FINT ip, jp, n;
        FINT has_value = 0;
        FINT *const idx = malloc(sizeof(FINT) * nf * 3);
        double aij, dij, eij, rrij;
        double *g = malloc(sizeof(double) * envs->g_size * 3
                           * ((1<<envs->gbits)+1)); // +1 as buffer
        double *gout = malloc(sizeof(double) * nf * n_comp);
        double *gctri = malloc(sizeof(double) * nf * i_ctr * n_comp);

        CINTg1e_index_xyz(idx, envs);

        rrij = CINTsquare_dist(ri, rj);
        fac *= SQRTPI * M_PI * CINTcommon_fac_sp(i_l) * CINTcommon_fac_sp(j_l);

        for (jp = 0; jp < envs->j_prim; jp++) {
                envs->aj = aj[jp];
                n = nf * i_ctr * n_comp;
                CINTdset0(n, gctri);
                for (ip = 0; ip < envs->i_prim; ip++) {
                        envs->ai = ai[ip];
                        aij = ai[ip] + aj[jp];
                        eij = (ai[ip] * aj[jp] / aij) * rrij;
                        if (eij > EXPCUTOFF)
                                continue;
                        has_value = 1;

                        dij = exp(-eij) / (aij * sqrt(aij)) * fac;
                        CINTg_ovlp(g, ai[ip], aj[jp], dij, envs);

                        CINTdset0(nf * n_comp, gout);
                        (*envs->f_gout)(g, gout, idx, envs);

                        n = nf * n_comp;
                        CINTprim_to_ctr(gctri, n, gout, 1, envs->i_prim,
                                        i_ctr, ci+ip);
                }
                n = nf * i_ctr;
                CINTprim_to_ctr(gctr, n, gctri, n_comp, envs->j_prim,
                                j_ctr, cj+jp);
        }
        free(g);
        free(idx);
        free(gout);
        free(gctri);

        return has_value;
}