本文整理汇总了C++中InArgs::get_x_poly方法的典型用法代码示例。如果您正苦于以下问题:C++ InArgs::get_x_poly方法的具体用法?C++ InArgs::get_x_poly怎么用?C++ InArgs::get_x_poly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InArgs
的用法示例。
在下文中一共展示了InArgs::get_x_poly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evalModel
void VanDerPolOscillator::evalModel( const InArgs& inArgs,
const OutArgs& outArgs ) const
{
// compute f(x)
Teuchos::RCP<const Epetra_Vector> x = inArgs.get_x();
Teuchos::RCP<Epetra_Vector> f = outArgs.get_f();
if ( (x != Teuchos::null) && (f != Teuchos::null) ) {
evalVField((*x)[0],(*x)[1],(*f)[0],(*f)[1]);
}
// compute f([x])
Teuchos::RCP<const Teuchos::Polynomial<Epetra_Vector> > x_poly =
inArgs.get_x_poly();
Teuchos::RCP<Teuchos::Polynomial<Epetra_Vector> > f_poly =
outArgs.get_f_poly();
if ( (x_poly != Teuchos::null) && (f_poly != Teuchos::null) ) {
unsigned int d = x_poly->degree();
Sacado::Tay::Taylor<double> x1(d,0.0);
Sacado::Tay::Taylor<double> x2(d,0.0);
Sacado::Tay::Taylor<double> f1(d,0.0);
Sacado::Tay::Taylor<double> f2(d,0.0);
for (unsigned int i=0; i<=d; i++) {
x1.fastAccessCoeff(i) = (*(x_poly->getCoefficient(i)))[0];
x2.fastAccessCoeff(i) = (*(x_poly->getCoefficient(i)))[1];
}
evalVField(x1,x2,f1,f2);
for (unsigned int i=0; i<=d; i++) {
(*(f_poly->getCoefficient(i)))[0] = f1.coeff(i);
(*(f_poly->getCoefficient(i)))[1] = f2.coeff(i);
}
}
// compute W
Teuchos::RCP<Epetra_Operator> W = outArgs.get_W();
if (W != Teuchos::null) {
const double alpha = inArgs.get_alpha();
const double beta = inArgs.get_beta();
Epetra_CrsMatrix &crsW = Teuchos::dyn_cast<Epetra_CrsMatrix>(*W);
const int dim = 2;
double values_1[2];
double values_2[2];
int indices[] = {0,1};
Sacado::Fad::DFad<double> x1(dim,0,(*x)[0]);
Sacado::Fad::DFad<double> x2(dim,1,(*x)[1]);
Sacado::Fad::DFad<double> f1;
Sacado::Fad::DFad<double> f2;
evalVField(x1,x2,f1,f2);
values_1[0] = alpha * f1.fastAccessDx(0) - beta;
values_1[1] = alpha * f1.fastAccessDx(1);
values_2[0] = alpha * f2.fastAccessDx(0);
values_2[0] = alpha * f2.fastAccessDx(1) - beta;
crsW.ReplaceGlobalValues(0,dim,values_1,indices);
crsW.ReplaceGlobalValues(1,dim,values_2,indices);
}
}