本文整理汇总了C++中Ith函数的典型用法代码示例。如果您正苦于以下问题:C++ Ith函数的具体用法?C++ Ith怎么用?C++ Ith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Ith函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}