当前位置: 首页>>代码示例>>C++>>正文


C++ rvec_dec函数代码示例

本文整理汇总了C++中rvec_dec函数的典型用法代码示例。如果您正苦于以下问题:C++ rvec_dec函数的具体用法?C++ rvec_dec怎么用?C++ rvec_dec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rvec_dec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reset_x_ndim

void reset_x_ndim(int ndim,int ncm,atom_id ind_cm[],
		  int nreset,atom_id *ind_reset,rvec x[],real mass[])
{
  int  i,m,ai;
  rvec xcm;
  real tm,mm;
  
  tm=0.0;
  clear_rvec(xcm);
  for(i=0; i<ncm; i++) {
    ai=ind_cm[i];
    mm=mass[ai];
    for(m=0; m<ndim; m++)
      xcm[m]+=mm*x[ai][m];
    tm+=mm;
  }
  for(m=0; m<ndim; m++)
    xcm[m]/=tm;
    
  if (ind_reset)
    for(i=0; i<nreset; i++)
      rvec_dec(x[ind_reset[i]],xcm);
  else
    for(i=0; i<nreset; i++)
      rvec_dec(x[i],xcm);
}
开发者ID:BioinformaticsArchive,项目名称:GromPy,代码行数:26,代码来源:do_fit.c

示例2: reset_x_ndim

void reset_x_ndim(int ndim,int ncm,const atom_id *ind_cm,
                  int nreset,const atom_id *ind_reset,
                  rvec x[],const real mass[])
{
    int  i,m,ai;
    rvec xcm;
    real tm,mm;

    if (ndim>DIM)
    {
        gmx_incons("More than 3 dimensions not supported.");
    }
    tm = 0.0;
    clear_rvec(xcm);
    if (ind_cm != NULL)
    {
        for(i=0; i<ncm; i++)
        {
            ai = ind_cm[i];
            mm = mass[ai];
            for(m=0; m<ndim; m++)
            {
                xcm[m] += mm*x[ai][m];
            }
            tm += mm;
        }
    }
    else
    {
        for(i=0; i<ncm; i++)
        {
            mm = mass[i];
            for(m=0; m<ndim; m++)
            {
                xcm[m] += mm*x[i][m];
            }
            tm += mm;
        }
    }
    for(m=0; m<ndim; m++)
    {
        xcm[m] /= tm;
    }

    if (ind_reset != NULL)
    {
        for(i=0; i<nreset; i++)
        {
            rvec_dec(x[ind_reset[i]],xcm);
        }
    }
    else
    {
        for(i=0; i<nreset; i++)
        {
            rvec_dec(x[i],xcm);
        }
    }
}
开发者ID:enasyunis,项目名称:gromacs,代码行数:59,代码来源:do_fit.c

示例3: calc_axes

static void calc_axes(rvec x[],t_atom atom[],int gnx[],atom_id *index[],
		      gmx_bool bRot,t_bundle *bun)
{
  int  end,i,div,d;
  real *mtot,m;
  rvec axis[MAX_ENDS],cent;
  
  snew(mtot,bun->n);

  for(end=0; end<bun->nend; end++) {
    for(i=0; i<bun->n; i++) {
      clear_rvec(bun->end[end][i]);
      mtot[i] = 0;
    }
    div = gnx[end]/bun->n;
    for(i=0; i<gnx[end]; i++) {
      m = atom[index[end][i]].m;
      for(d=0; d<DIM; d++)
	bun->end[end][i/div][d] += m*x[index[end][i]][d];
      mtot[i/div] += m;
    }
    clear_rvec(axis[end]);
    for(i=0; i<bun->n; i++) {
      svmul(1.0/mtot[i],bun->end[end][i],bun->end[end][i]);
      rvec_inc(axis[end],bun->end[end][i]);
    }
    svmul(1.0/bun->n,axis[end],axis[end]);
  }
  sfree(mtot);

  rvec_add(axis[0],axis[1],cent);
  svmul(0.5,cent,cent);
  /* center the bundle on the origin */
  for(end=0; end<bun->nend; end++) {
    rvec_dec(axis[end],cent);
    for(i=0; i<bun->n; i++)
      rvec_dec(bun->end[end][i],cent);
  }
  if (bRot) {
    /* rotate the axis parallel to the z-axis */
    rotate_ends(bun,axis[0],YY,ZZ);
    rotate_ends(bun,axis[0],XX,ZZ);
  }
  for(i=0; i<bun->n; i++) {
    rvec_add(bun->end[0][i],bun->end[1][i],bun->mid[i]);
    svmul(0.5,bun->mid[i],bun->mid[i]);
    rvec_sub(bun->end[0][i],bun->end[1][i],bun->dir[i]);
    bun->len[i] = norm(bun->dir[i]);
    unitv(bun->dir[i],bun->dir[i]);
  }
}
开发者ID:andersx,项目名称:gmx-debug,代码行数:51,代码来源:gmx_bundle.c

示例4: prep_data

/* prepare the coordinates by removing periodic boundary crossings.
   gnx = the number of atoms/molecules
   index = the indices
   xcur = the current coordinates
   xprev = the previous coordinates
   box = the box matrix */
static void prep_data(gmx_bool bMol,int gnx,atom_id index[],
		      rvec xcur[],rvec xprev[],matrix box)
{
    int  i,m,ind;
    rvec hbox;

    /* Remove periodicity */
    for(m=0; (m<DIM); m++)
        hbox[m]=0.5*box[m][m];
    
    for(i=0; (i<gnx); i++) {
        if (bMol)
            ind = i;
        else
            ind = index[i];

        for(m=DIM-1; m>=0; m--) 
        {
            while(xcur[ind][m]-xprev[ind][m] <= -hbox[m])
                rvec_inc(xcur[ind],box[m]);
            while(xcur[ind][m]-xprev[ind][m] >  hbox[m])
                rvec_dec(xcur[ind],box[m]);
        }      
    }
}
开发者ID:BradleyDickson,项目名称:ABPenabledGROMACS,代码行数:31,代码来源:gmx_msd.c

示例5: center_coords

static void center_coords(t_atoms *atoms, matrix box, rvec x0[], int axis)
{
    int  i, m;
    real tmass, mm;
    rvec com, shift, box_center;

    tmass = 0;
    clear_rvec(com);
    for (i = 0; (i < atoms->nr); i++)
    {
        mm     = atoms->atom[i].m;
        tmass += mm;
        for (m = 0; (m < DIM); m++)
        {
            com[m] += mm*x0[i][m];
        }
    }
    for (m = 0; (m < DIM); m++)
    {
        com[m] /= tmass;
    }
    calc_box_center(ecenterDEF, box, box_center);
    rvec_sub(box_center, com, shift);
    shift[axis] -= box_center[axis];

    for (i = 0; (i < atoms->nr); i++)
    {
        rvec_dec(x0[i], shift);
    }
}
开发者ID:tanigawa,项目名称:gromacs,代码行数:30,代码来源:gmx_densorder.cpp

示例6: do_stopcm_grp

void do_stopcm_grp(FILE *fp,int start,int homenr,unsigned short *group_id,
		   rvec x[],rvec v[],t_vcm *vcm)
{
  int  i,g,m;
  real tm,tm_1;
  rvec dv,dx;
  
  if (vcm->mode != ecmNO) {
    /* Subtract linear momentum */
    g = 0;
    switch (vcm->ndim) {
    case 1:
      for(i=start; (i<start+homenr); i++) {
	if (group_id)
	  g = group_id[i];
	v[i][XX] -= vcm->group_v[g][XX];
      }
      break;
    case 2:
      for(i=start; (i<start+homenr); i++) {
	if (group_id)
	  g = group_id[i];
	v[i][XX] -= vcm->group_v[g][XX];
	v[i][YY] -= vcm->group_v[g][YY];
      }
      break;
    case 3:
      for(i=start; (i<start+homenr); i++) {
	if (group_id)
	  g = group_id[i];
	rvec_dec(v[i],vcm->group_v[g]);
      }
      break;
    }
    if (vcm->mode == ecmANGULAR) {
      /* Subtract angular momentum */
      for(i=start; (i<start+homenr); i++) {
	if (group_id)
	  g = group_id[i];
	/* Compute the correction to the velocity for each atom */
	rvec_sub(x[i],vcm->group_x[g],dx);
	cprod(vcm->group_w[g],dx,dv);
	rvec_dec(v[i],dv);
      }
    }
  }
}
开发者ID:TTarenzi,项目名称:MMCG-HAdResS,代码行数:47,代码来源:vcm.c

示例7: my_sub_xcm

static void my_sub_xcm(int nbb,atom_id bbind[],rvec x[],rvec xcm)
{
  int i,ai;
  
  for(i=0; (i<nbb); i++) {
    ai=bbind[i];
    rvec_dec(x[ai],xcm);
  }
}
开发者ID:BioinformaticsArchive,项目名称:GromPy,代码行数:9,代码来源:fitahx.c

示例8: sub_xcm

real sub_xcm(rvec x[], int gnx, atom_id *index, t_atom atom[], rvec xcm,
             gmx_bool bQ)
{
    int  i, ii;
    real tm;

    tm = calc_xcm(x, gnx, index, atom, xcm, bQ);
    for (i = 0; (i < gnx); i++)
    {
        ii = index ? index[i] : i;
        rvec_dec(x[ii], xcm);
    }
    return tm;
}
开发者ID:dkarkoulis,项目名称:gromacs,代码行数:14,代码来源:princ.c

示例9: center_molecule

static void center_molecule(int atomCount, rvec x[])
{
    rvec center;
    clear_rvec(center);
    for (int i = 0; i < atomCount; ++i)
    {
        rvec_inc(center, x[i]);
    }
    svmul(1.0/atomCount, center, center);
    for (int i = 0; i < atomCount; ++i)
    {
        rvec_dec(x[i], center);
    }
}
开发者ID:mokmonteiro,项目名称:gromacs,代码行数:14,代码来源:insert-molecules.cpp

示例10: correct_box_elem

static int correct_box_elem(FILE *fplog, int step, tensor box, int v, int d)
{
    int shift, maxshift = 10;

    shift = 0;

    /* correct elem d of vector v with vector d */
    while (box[v][d] > BOX_MARGIN_CORRECT*0.5*box[d][d])
    {
        if (fplog)
        {
            fprintf(fplog, "Step %d: correcting invalid box:\n", step);
            pr_rvecs(fplog, 0, "old box", box, DIM);
        }
        rvec_dec(box[v], box[d]);
        shift--;
        if (fplog)
        {
            pr_rvecs(fplog, 0, "new box", box, DIM);
        }
        if (shift <= -maxshift)
        {
            gmx_fatal(FARGS,
                      "Box was shifted at least %d times. Please see log-file.",
                      maxshift);
        }
    }
    while (box[v][d] < -BOX_MARGIN_CORRECT*0.5*box[d][d])
    {
        if (fplog)
        {
            fprintf(fplog, "Step %d: correcting invalid box:\n", step);
            pr_rvecs(fplog, 0, "old box", box, DIM);
        }
        rvec_inc(box[v], box[d]);
        shift++;
        if (fplog)
        {
            pr_rvecs(fplog, 0, "new box", box, DIM);
        }
        if (shift >= maxshift)
        {
            gmx_fatal(FARGS,
                      "Box was shifted at least %d times. Please see log-file.",
                      maxshift);
        }
    }

    return shift;
}
开发者ID:yhalcyon,项目名称:Gromacs,代码行数:50,代码来源:pbc.c

示例11: copy_mat

void
BoxDeformation::apply(ArrayRef<RVec> x,
                      matrix         box,
                      int64_t        step)
{
    matrix updatedBox, invbox, mu;

    double elapsedTime = (step + 1 - initialStep_) * timeStep_;
    copy_mat(box, updatedBox);
    for (int i = 0; i < DIM; i++)
    {
        for (int j = 0; j < DIM; j++)
        {
            if (deformationTensor_[i][j] != 0)
            {
                updatedBox[i][j] =
                    referenceBox_[i][j] + elapsedTime * deformationTensor_[i][j];
            }
        }
    }
    /* We correct the off-diagonal elements,
     * which can grow indefinitely during shearing,
     * so the shifts do not get messed up.
     */
    for (int i = 1; i < DIM; i++)
    {
        for (int j = i-1; j >= 0; j--)
        {
            while (updatedBox[i][j] - box[i][j] > 0.5 * updatedBox[j][j])
            {
                rvec_dec(updatedBox[i], updatedBox[j]);
            }
            while (updatedBox[i][j] - box[i][j] < -0.5 * updatedBox[j][j])
            {
                rvec_inc(updatedBox[i], updatedBox[j]);
            }
        }
    }
    invertBoxMatrix(box, invbox);
    // Return the updated box
    copy_mat(updatedBox, box);
    mmul_ur0(box, invbox, mu);

    for (auto &thisX : x)
    {
        thisX[XX] = mu[XX][XX]*thisX[XX] + mu[YY][XX]*thisX[YY] + mu[ZZ][XX]*thisX[ZZ];
        thisX[YY] = mu[YY][YY]*thisX[YY] + mu[ZZ][YY]*thisX[ZZ];
        thisX[ZZ] = mu[ZZ][ZZ]*thisX[ZZ];
    }
}
开发者ID:friforever,项目名称:gromacs,代码行数:50,代码来源:boxdeformation.cpp

示例12: print_constraint

void print_constraint(t_pull *pull, rvec *f, int step, matrix box, int niter) 
{
  int i,ii,m; 
  rvec tmp,tmp2,tmp3;

  for (i=0;i<pull->pull.n;i++) {
    if (pull->bCyl) 
      rvec_sub(pull->pull.x_con[i],pull->dyna.x_con[i],tmp);
    else 
      rvec_sub(pull->pull.x_con[i],pull->ref.x_con[0],tmp);
    for (m=DIM-1; m>=0; m--) {
      if (tmp[m] < -0.5*box[m][m]) rvec_inc(tmp,box[m]);
      if (tmp[m] >  0.5*box[m][m]) rvec_dec(tmp,box[m]);
      tmp[m] *= pull->dims[m];
    }
    if (pull->bVerbose) 
      fprintf(pull->out,"%d:%d ds:%e f:%e n:%d\n", step,i,norm(tmp),
	      pull->pull.f[i][ZZ],niter);
    else
      fprintf(pull->out,"%e ",pull->pull.f[i][ZZ]);
  }

  if (!pull->bVerbose)
    fprintf(pull->out,"\n");

  /* DEBUG */ /* this code doesn't correct for pbc, needs improvement */
  if (pull->bVerbose) {
    for (i=0;i<pull->pull.n;i++) {
      if (pull->bCyl) 
	fprintf(pull->out,"eConstraint: step %d. Refgroup = dynamic (%f,%f\n"
		"Group %d (%s): ref. dist = %8.3f, unconstr. dist = %8.3f"
		" con. dist = %8.3f f_i = %8.3f\n", step, pull->r,pull->rc,
		i,pull->pull.grps[i],
		pull->dyna.x_ref[i][ZZ]-pull->pull.x_ref[i][ZZ],
		pull->dyna.x_unc[i][ZZ]-pull->pull.x_unc[i][ZZ],
		pull->dyna.x_con[i][ZZ]-pull->pull.x_con[i][ZZ],
		pull->pull.f[i][ZZ]);
      else {
	rvec_sub(pull->ref.x_ref[0],pull->pull.x_ref[i],tmp);
	rvec_sub(pull->ref.x_unc[0],pull->pull.x_unc[i],tmp2);
	rvec_sub(pull->ref.x_con[0],pull->pull.x_con[i],tmp3);
	fprintf(stderr,"grp %d:ref (%8.3f,%8.3f,%8.3f) unc(%8.3f%8.3f%8.3f\n"
		"con (%8.3f%8.3f%8.3f)\n",i, tmp[0],tmp[1],tmp[2],
		tmp2[0],tmp2[1],tmp2[2],tmp3[0],tmp3[1],tmp3[2]);
      }
    }
  } /* END DEBUG */

}
开发者ID:Chadi-akel,项目名称:cere,代码行数:49,代码来源:pullio.c

示例13: prep_data

/* prepare the coordinates by removing periodic boundary crossings.
   gnx = the number of atoms/molecules
   index = the indices
   xcur = the current coordinates
   xprev = the previous coordinates
   box = the box matrix */
static void prep_data(gmx_bool bMol, int gnx, int index[],
                      rvec xcur[], rvec xprev[], matrix box)
{
    int  i, m, ind;
    rvec hbox;

    /* Remove periodicity */
    for (m = 0; (m < DIM); m++)
    {
        hbox[m] = 0.5*box[m][m];
    }

    for (i = 0; (i < gnx); i++)
    {
        if (bMol)
        {
            ind = i;
        }
        else
        {
            ind = index[i];
        }

        for (m = DIM-1; m >= 0; m--)
        {
            if (hbox[m] == 0)
            {
                continue;
            }
            while (xcur[ind][m]-xprev[ind][m] <= -hbox[m])
            {
                rvec_inc(xcur[ind], box[m]);
            }
            while (xcur[ind][m]-xprev[ind][m] >  hbox[m])
            {
                rvec_dec(xcur[ind], box[m]);
            }
        }
    }
}
开发者ID:MichalKononenko,项目名称:gromacs,代码行数:46,代码来源:gmx_msd.cpp

示例14: correct_t0_pbc

void correct_t0_pbc(t_pull *pull, rvec x[], t_mdatoms *md, matrix box) {
  int i,ii,j,m;
  real tm;
  rvec com,dx;

  /* loop over all atoms in index for group i. Check if they moved
     more than half a box with respect to xp. If so add/subtract a box 
     from x0. Copy x to xp.
   */
  for (i=0;i<pull->ref.ngx[0];i++) {
    ii = pull->ref.idx[0][i];
    
    /* correct for jumps across the box */
    rvec_sub(x[ii],pull->ref.xp[0][i],dx);
    for (m=DIM-1; m>=0; m--) {
      if (dx[m] < -0.5*box[m][m]) {
	rvec_inc(dx,box[m]);
	if (pull->bVerbose && fabs(pull->dims[m])>GMX_REAL_MIN)
	  fprintf(stderr,"Jumped +box: nr %d dir: %d old:%8.3f\n",ii,m,
		  pull->ref.x0[0][i][m]); 
      }
      
      if (dx[m] >  0.5*box[m][m]) {
	rvec_dec(dx,box[m]);
	if (pull->bVerbose && fabs(pull->dims[m])>GMX_REAL_MIN)
	  fprintf(stderr,"Jumped -box: nr %d dir: %d old:%8.3f\n",ii,m,
		  pull->ref.x0[0][i][m]); 
      }

      pull->ref.x0[0][i][m] += dx[m];
      pull->ref.xp[0][i][m]  = x[ii][m];
    }
  }
  tm = calc_com2(pull->ref.x0[0],pull->ref.ngx[0],pull->ref.idx[0],
		 md,com,box);
  if (pull->bVerbose) 
    fprintf(stderr,"correct_t0: Group %s: mass:%8.3f com:%8.3f%8.3f%8.3f\n",
	    pull->ref.grps[0],tm,com[0],com[1],com[2]);
}
开发者ID:Chadi-akel,项目名称:cere,代码行数:39,代码来源:pullutil.c

示例15: calc_com2

/* calculates com of all atoms in x[], *index has their index numbers
   to get the masses from atom[] */
real calc_com2(rvec x[],int gnx,atom_id *index,t_mdatoms *md,rvec com,
	       matrix box)
{
  int  i,ii,m;
  real m0,tm;

  clear_rvec(com);
  tm=0;
  for(i=0; (i<gnx); i++) {
    ii=index[i];
    m0=md->massT[ii];
    tm+=m0;
    for(m=0; (m<DIM); m++)
      com[m]+=m0*x[i][m];
  }
  svmul(1/tm,com,com);
  for(m=DIM-1; m>=0; m--) {
    /* next two lines used to be commented out */
    if (com[m] < 0        ) rvec_inc(com,box[m]);
    if (com[m] > box[m][m]) rvec_dec(com,box[m]); 
  }
  return tm;
}
开发者ID:Chadi-akel,项目名称:cere,代码行数:25,代码来源:pullutil.c


注:本文中的rvec_dec函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。