• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Ith函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Ith

void Rossler::EventsConstraints (realtype t, N_Vector x, int * constraints, void * data) {
  realtype a, b, c;
  realtype x1, x2, x3;
  realtype ris[3], xdot[3];
  Parameters * parameters;
  
  x1 = Ith (x, 0);
  x2 = Ith (x, 1);
  x3 = Ith (x, 2);
 
  parameters = (Parameters *) data;
  a = parameters->At(0);
  b = parameters->At(1);
  c = parameters->At(2);

  RHS(t,x,xderiv,data);
  for(int i=0; i<GetDimension(); i++)
    xdot[i] = Ith(xderiv,i);
  
  ris[0] = - xdot[1] - xdot[2];
  ris[1] = xdot[0] + a*xdot[1];
  ris[2] = xdot[0]*x3 + xdot[2]*(x1-c);
	
  for(int i=0; i<GetNumberOfEvents(); i++)
    constraints[i] = (ris[i] < 0 ? 1 : 0);
}
开发者ID:danielelinaro,项目名称:BAL,代码行数:26,代码来源:balRossler.cpp


示例2: JacB

static int JacB(int NB, realtype t,
                N_Vector y, N_Vector yB, N_Vector fyB,
                DlsMat JB, void *user_dataB,
                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
{
  UserData data;
  realtype y1, y2, y3;
  realtype p1, p2, p3;
  
  data = (UserData) user_dataB;

  /* The p vector */
  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];

  /* The y vector */
  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);

  /* Load JB */
  IJth(JB,1,1) = p1;     IJth(JB,1,2) = -p1; 
  IJth(JB,2,1) = -p2*y3; IJth(JB,2,2) = p2*y3+2.0*p3*y2;
                         IJth(JB,2,3) = RCONST(-2.0)*p3*y2;
  IJth(JB,3,1) = -p2*y2; IJth(JB,3,2) = p2*y2;

  return(0);
}
开发者ID:A1kmm,项目名称:modml-solver,代码行数:25,代码来源:cvsRoberts_ASAi_dns.c


示例3: setup_initial_states

int setup_initial_states(N_Vector y)
{
  /* Initialize y */
  Ith(y,1) = Y1;
  Ith(y,2) = Y2;
  Ith(y,3) = Y3;
}
开发者ID:NeuroArchive,项目名称:NeuroUnits,代码行数:7,代码来源:user_funcs.c


示例4: g

static void g(realtype t, N_Vector y, realtype *gout, void *g_data)
{
  realtype y1, y3;

  y1 = Ith(y,1); y3 = Ith(y,3);
  gout[0] = y1 - RCONST(0.0001);
  gout[1] = y3 - RCONST(0.01);
}
开发者ID:igemsoftware,项目名称:USTC-Software_2011,代码行数:8,代码来源:cvdx.c


示例5: GetSol

void GetSol(void *cpode_mem, N_Vector yy0, realtype tol, 
            realtype tout, booleantype proj, N_Vector yref)
{
  N_Vector yy, yp;
  realtype t, x, y, xd, yd, g;
  int flag;
  long int nst, nfe, nsetups, nje, nfeLS, ncfn, netf;

  if (proj) {
    printf(" YES   ");
    CPodeSetProjFrequency(cpode_mem, 1);
  } else {
    CPodeSetProjFrequency(cpode_mem, 0);
    printf(" NO    ");
  }

  yy = N_VNew_Serial(4);
  yp = N_VNew_Serial(4);

  flag = CPodeReInit(cpode_mem, (void *)f, NULL, 0.0, yy0, NULL, CP_SS, tol, &tol);

  flag = CPode(cpode_mem, tout, &t, yy, yp, CP_NORMAL_TSTOP);

  x  = Ith(yy,1);
  y  = Ith(yy,2);
  g = ABS(x*x + y*y - 1.0);

  N_VLinearSum(1.0, yy, -1.0, yref, yy);

  N_VAbs(yy, yy);

  x  = Ith(yy,1);
  y  = Ith(yy,2);  
  xd = Ith(yy,3);
  yd = Ith(yy,4);


  printf("%9.2e  %9.2e  %9.2e  %9.2e  |  %9.2e  |",  
         Ith(yy,1),Ith(yy,2),Ith(yy,3),Ith(yy,4),g);

  CPodeGetNumSteps(cpode_mem, &nst);
  CPodeGetNumFctEvals(cpode_mem, &nfe);
  CPodeGetNumLinSolvSetups(cpode_mem, &nsetups);
  CPodeGetNumErrTestFails(cpode_mem, &netf);
  CPodeGetNumNonlinSolvConvFails(cpode_mem, &ncfn);

  CPDlsGetNumJacEvals(cpode_mem, &nje);
  CPDlsGetNumFctEvals(cpode_mem, &nfeLS);


  printf(" %6ld   %6ld+%-4ld  %4ld (%3ld)  |  %3ld  %3ld\n",
         nst, nfe, nfeLS, nsetups, nje, ncfn, netf);

  N_VDestroy_Serial(yy);
  N_VDestroy_Serial(yp);

  return;
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:58,代码来源:pend_test.c


示例6: g

static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
{
  realtype y1, y3;

  y1 = Ith(y,1); y3 = Ith(y,3);
  gout[0] = y1 - RCONST(0.0001);
  gout[1] = y3 - RCONST(0.01);

  return(0);
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:10,代码来源:cvRoberts_dns_uw.c


示例7: setup_tolerances

int setup_tolerances(N_Vector abstol)
{
  /* Set the scalar relative tolerance */
  //reltol = RTOL;
  /* Set the vector absolute tolerance */
  Ith(abstol,1) = ATOL1;
  Ith(abstol,2) = ATOL2;
  Ith(abstol,3) = ATOL3;

}
开发者ID:NeuroArchive,项目名称:NeuroUnits,代码行数:10,代码来源:user_funcs.c


示例8: fQB

static int fQB(realtype t, N_Vector y, N_Vector yB, 
               N_Vector qBdot, void *user_dataB)
{
  UserData data;
  realtype y1, y2, y3;
  realtype p1, p2, p3;
  realtype l1, l2, l3;
  realtype l21, l32, y23;

  data = (UserData) user_dataB;

  /* The p vector */
  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];

  /* The y vector */
  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
  
  /* The lambda vector */
  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);

  /* Temporary variables */
  l21 = l2-l1;
  l32 = l3-l2;
  y23 = y2*y3;

  Ith(qBdot,1) = y1*l21;
  Ith(qBdot,2) = - y23*l21;
  Ith(qBdot,3) = y2*y2*l32;

  return(0);
}
开发者ID:A1kmm,项目名称:modml-solver,代码行数:31,代码来源:cvsRoberts_ASAi_dns.c


示例9: operAccum

void    operAccum(real pl[], real q[], integer N, real t, integer indx)
{
    integer i;
    real    xnorm, ipr, ipi;
    xnorm = norm2(pl, N);
    for (i = 1; i <= nopers; i++) {
        FSmul(&opers[i], t, pl, q);
        inprod(pl, q, N, &ipr, &ipi);
        Ith(opr[i], indx) += ipr / xnorm;
        Ith(opi[i], indx) += ipi / xnorm;
    }
}
开发者ID:geniussz,项目名称:qotoolbox,代码行数:12,代码来源:solvemc.c


示例10: RefSol

void RefSol(realtype tout, N_Vector yref)
{
  void *cpode_mem;
  N_Vector yy, yp;
  realtype tol, t, th, thd;
  int flag;
  

  yy = N_VNew_Serial(2);
  yp = N_VNew_Serial(2);
  Ith(yy,1) = 0.0;  /* theta */
  Ith(yy,2) = 0.0;  /* thetad */
  tol = TOL_REF;

  cpode_mem = CPodeCreate(CP_EXPL, CP_BDF, CP_NEWTON);  
  flag = CPodeSetMaxNumSteps(cpode_mem, 100000);
  flag = CPodeInit(cpode_mem, (void *)fref, NULL, 0.0, yy, yp, CP_SS, tol, &tol);
  flag = CPDense(cpode_mem, 2);

  flag = CPodeSetStopTime(cpode_mem, tout);
  flag = CPode(cpode_mem, tout, &t, yy, yp, CP_NORMAL_TSTOP);
  th  = Ith(yy,1);
  thd = Ith(yy,2);
  Ith(yref,1) = cos(th);
  Ith(yref,2) = sin(th);
  Ith(yref,3) = -thd*sin(th);
  Ith(yref,4) =  thd*cos(th);
  
  N_VDestroy_Serial(yy);
  N_VDestroy_Serial(yp);
  CPodeFree(&cpode_mem);

  return;
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:34,代码来源:pend_test.c


示例11: fref

static int fref(realtype t, N_Vector yy, N_Vector fy, void *f_data)
{
  realtype th, thd, g;

  g = 13.7503716373294544;

  th  = Ith(yy,1);
  thd  = Ith(yy,2);

  Ith(fy,1) = thd;
  Ith(fy,2) = -g*cos(th);

  return(0);
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:14,代码来源:pend_test.c


示例12: fB

static int fB(realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB)
{
  UserData data;
  realtype y2, y3;
  realtype p1, p2, p3;
  realtype l1, l2, l3;
  realtype l21, l32;
  
  data = (UserData) user_dataB;

  /* The p vector */
  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];

  /* The y vector */
  y2 = Ith(y,2); y3 = Ith(y,3);
  
  /* The lambda vector */
  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);

  /* Temporary variables */
  l21 = l2-l1;
  l32 = l3-l2;

  /* Load yBdot */
  Ith(yBdot,1) = - p1*l21;
  Ith(yBdot,2) = p2*y3*l21 - RCONST(2.0)*p3*y2*l32;
  Ith(yBdot,3) = p2*y2*l21 - RCONST(1.0);

  return(0);
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:30,代码来源:cvsRoberts_ASAi_dns_constraints.c


示例13: Jac

static void Jac(long int N, DenseMat J, realtype t,
                N_Vector y, N_Vector fy, void *jac_data,
                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
  realtype y1, y2, y3;

  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);

  IJth(J,1,1) = RCONST(-0.04);
  IJth(J,1,2) = RCONST(1.0e4)*y3;
  IJth(J,1,3) = RCONST(1.0e4)*y2;
  IJth(J,2,1) = RCONST(0.04); 
  IJth(J,2,2) = RCONST(-1.0e4)*y3-RCONST(6.0e7)*y2;
  IJth(J,2,3) = RCONST(-1.0e4)*y2;
  IJth(J,3,2) = RCONST(6.0e7)*y2;
}
开发者ID:igemsoftware,项目名称:USTC-Software_2011,代码行数:16,代码来源:cvdx.c


示例14: Jac

static void Jac(long int N, DenseMat J, realtype t,
                N_Vector y, N_Vector fy, void *jac_data, 
                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
  realtype y1, y2, y3;
  UserData data;
  realtype p1, p2, p3;
 
  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
  data = (UserData) jac_data;
  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
 
  IJth(J,1,1) = -p1;  IJth(J,1,2) = p2*y3;          IJth(J,1,3) = p2*y2;
  IJth(J,2,1) =  p1;  IJth(J,2,2) = -p2*y3-2*p3*y2; IJth(J,2,3) = -p2*y2;
                      IJth(J,3,2) = 2*p3*y2;
}
开发者ID:bareqsh,项目名称:SBML_odeSolver,代码行数:16,代码来源:cvfdx.c


示例15: res

static int res(realtype t, N_Vector y, N_Vector yp, N_Vector res, void *f_data)
{
  realtype y1, y2, y3, yp1, yp2, yp3;

  y1  = Ith(y,1);  y2  = Ith(y,2);  y3  = Ith(y,3);
  yp1 = Ith(yp,1); yp2 = Ith(yp,2); yp3 = Ith(yp,3);

  Ith(res,1) = yp1 - (RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3);
  Ith(res,2) = yp2 + (RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3 + RCONST(3.0e7)*y2*y2);
  Ith(res,3) = yp3 - RCONST(3.0e7)*y2*y2;

  return(0);
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:13,代码来源:cpsdenx.c


示例16: EventsConstraints

void PLL::EventsConstraints (realtype t, N_Vector X, int * constraints, void * data) {
#ifndef WITHPHIERR
  constraints[0] = 1;
  // minimum of x [we know that x is a sinusoid with mean 0]
  constraints[1] = (Ith(X,0) < 0 ? 1 : 0);
  constraints[2] = 1;
#endif
}
开发者ID:danielelinaro,项目名称:BAL,代码行数:8,代码来源:balPLL.cpp


示例17: Jac

static int Jac(realtype t, N_Vector y, N_Vector fy, SUNMatrix J,
               void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
  realtype y2, y3;
  UserData data;
  realtype p1, p2, p3;
 
  y2 = Ith(y,2); y3 = Ith(y,3);
  data = (UserData) user_data;
  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
 
  IJth(J,1,1) = -p1;  IJth(J,1,2) = p2*y3;          IJth(J,1,3) = p2*y2;
  IJth(J,2,1) =  p1;  IJth(J,2,2) = -p2*y3-2*p3*y2; IJth(J,2,3) = -p2*y2;
  IJth(J,3,1) = ZERO; IJth(J,3,2) = 2*p3*y2;        IJth(J,3,3) = ZERO;

  return(0);
}
开发者ID:polymec,项目名称:polymec-dev,代码行数:17,代码来源:cvsRoberts_ASAi_dns_constraints.c


示例18: Jac

int Jac(long int N, realtype t,
               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
  realtype y1, y2, y3;

  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);

  IJth(J,1,1) = RCONST(-0.04);
  IJth(J,1,2) = RCONST(1.0e4)*y3;
  IJth(J,1,3) = RCONST(1.0e4)*y2;
  IJth(J,2,1) = RCONST(0.04); 
  IJth(J,2,2) = RCONST(-1.0e4)*y3-RCONST(6.0e7)*y2;
  IJth(J,2,3) = RCONST(-1.0e4)*y2;
  IJth(J,3,2) = RCONST(6.0e7)*y2;

  return(0);
}
开发者ID:NeuroArchive,项目名称:NeuroUnits,代码行数:18,代码来源:user_funcs.c


示例19: ewt

static int ewt(N_Vector y, N_Vector w, void *user_data)
{
  int i;
  realtype yy, ww, rtol, atol[3];

  rtol    = RTOL;
  atol[0] = ATOL1;
  atol[1] = ATOL2;
  atol[2] = ATOL3;

  for (i=1; i<=3; i++) {
    yy = Ith(y,i);
    ww = rtol * SUNRabs(yy) + atol[i-1];
    if (ww <= 0.0) return (-1);
    Ith(w,i) = 1.0/ww;
  }

  return(0);
}
开发者ID:luca-heltai,项目名称:sundials,代码行数:19,代码来源:cvsRoberts_FSA_sps.c


示例20: main

int main()
{
  void *cpode_mem;
  N_Vector yref, yy0;
  realtype tol, tout;
  int i, flag;


  tout = 30.0;
 
  /* Get reference solution */
  yref = N_VNew_Serial(4);
  RefSol(tout, yref);

  /* Initialize solver */
  tol = TOL;
  cpode_mem = CPodeCreate(CP_EXPL, CP_BDF, CP_NEWTON);  
  yy0 = N_VNew_Serial(4);
  Ith(yy0,1) = 1.0;  /* x */
  Ith(yy0,2) = 0.0;  /* y */
  Ith(yy0,3) = 0.0;  /* xd */
  Ith(yy0,4) = 0.0;  /* yd */
  flag = CPodeInit(cpode_mem, (void *)f, NULL, 0.0, yy0, NULL, CP_SS, tol, &tol);
  flag = CPodeSetMaxNumSteps(cpode_mem, 50000);
  flag = CPodeSetStopTime(cpode_mem, tout);
  flag = CPodeProjDefine(cpode_mem, proj, NULL);
  flag = CPDense(cpode_mem, 4);

  for (i=0;i<5;i++) {

    printf("\n\n%.2e\n", tol);
    GetSol(cpode_mem, yy0, tol, tout, TRUE, yref);
    GetSol(cpode_mem, yy0, tol, tout, FALSE, yref);
    tol /= 10.0;
  }

  N_VDestroy_Serial(yref);
  CPodeFree(&cpode_mem);

  return(0);
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:41,代码来源:pend_test.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IupCreatev函数代码示例发布时间:2022-05-30
下一篇:
C++ Iterator函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap