本文整理汇总了C++中stokhos::OrthogPolyApprox::term方法的典型用法代码示例。如果您正苦于以下问题:C++ OrthogPolyApprox::term方法的具体用法?C++ OrthogPolyApprox::term怎么用?C++ OrthogPolyApprox::term使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stokhos::OrthogPolyApprox
的用法示例。
在下文中一共展示了OrthogPolyApprox::term方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnitTestSetup
UnitTestSetup() {
rtol = 1e-4;
atol = 1e-5;
crtol = 1e-12;
catol = 1e-12;
a = 3.1;
const OrdinalType d = 2;
const OrdinalType p = 7;
// Create product basis
Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<OrdinalType,ValueType> > > bases(d);
for (OrdinalType i=0; i<d; i++)
bases[i] =
Teuchos::rcp(new Stokhos::LegendreBasis<OrdinalType,ValueType>(p));
basis =
Teuchos::rcp(new Stokhos::CompletePolynomialBasis<OrdinalType,ValueType>(bases));
// Constant expansion
exp =
Teuchos::rcp(new Stokhos::ConstantOrthogPolyExpansion<OrdinalType,ValueType>());
// Create approximation
cx.reset(basis, 1);
cx.term(0, 0) = a;
cu.reset(basis, 1);
cu2.reset(basis, 1);
}
示例2: if
ordinal_type
Stokhos::ProductLanczosPCEBasis<ordinal_type, value_type>::
isInvariant(const Stokhos::OrthogPolyApprox<ordinal_type, value_type>& pce) const
{
Teuchos::RCP<const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > basis =
pce.basis();
ordinal_type dim = basis->dimension();
value_type tol = 1.0e-15;
// Check if basis is a product basis
Teuchos::RCP<const Stokhos::ProductBasis<ordinal_type,value_type> > prod_basis = Teuchos::rcp_dynamic_cast<const Stokhos::ProductBasis<ordinal_type,value_type> >(basis);
if (prod_basis == Teuchos::null)
return -2;
// Build list of dimensions pce depends on by looping over each dimension,
// computing norm of pce with just that dimension -- note we don't include
// the constant term
Teuchos::Array<ordinal_type> dependent_dims;
tmp_pce.reset(basis);
for (ordinal_type i=0; i<dim; i++) {
ordinal_type p = prod_basis->getCoordinateBases()[i]->order();
tmp_pce.init(0.0);
for (ordinal_type j=1; j<=p; j++)
tmp_pce.term(i,j) = pce.term(i,j);
value_type nrm = tmp_pce.two_norm();
if (nrm > tol) dependent_dims.push_back(i);
}
// If dependent_dims has length 1, pce a function of a single variable,
// which is an invariant subspace
if (dependent_dims.size() == 1)
return dependent_dims[0];
// If dependent_dims has length 0, pce is constant
else if (dependent_dims.size() == 0)
return -1;
// Otherwise pce depends on more than one variable
return -2;
}