本文整理汇总了C++中stokhos::OrthogPolyApprox::mean方法的典型用法代码示例。如果您正苦于以下问题:C++ OrthogPolyApprox::mean方法的具体用法?C++ OrthogPolyApprox::mean怎么用?C++ OrthogPolyApprox::mean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stokhos::OrthogPolyApprox
的用法示例。
在下文中一共展示了OrthogPolyApprox::mean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: func
Stieltjes_PCE_Setup(bool use_pce_quad_points_) :
func(), use_pce_quad_points(use_pce_quad_points_)
{
rtol = 1e-8;
atol = 1e-12;
const OrdinalType d = 3;
const OrdinalType p = 5;
// 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));
// Create approximation
sz = basis->size();
Stokhos::OrthogPolyApprox<OrdinalType,ValueType> x(basis);
for (OrdinalType i=0; i<d; i++)
x.term(i, 1) = 1.0;
// Tensor product quadrature
Teuchos::RCP<const Stokhos::Quadrature<OrdinalType,ValueType> > quad =
Teuchos::rcp(new Stokhos::TensorProductQuadrature<OrdinalType,ValueType>(basis, 4*p));
// Triple product tensor
Teuchos::RCP<Stokhos::Sparse3Tensor<int,double> > Cijk =
basis->computeTripleProductTensor(basis->size());
// Quadrature expansion
exp = Teuchos::rcp(new Stokhos::QuadOrthogPolyExpansion<OrdinalType,ValueType>(basis, Cijk, quad));
// Compute PCE via quadrature expansion
u.reset(basis);
v.reset(basis);
func.eval(*exp, x, u);
exp->times(v,u,u);
// Compute Stieltjes basis
st_1d_basis =
Teuchos::rcp(new Stokhos::StieltjesPCEBasis<OrdinalType,ValueType>(
p, Teuchos::rcp(&u,false), quad, use_pce_quad_points));
Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<OrdinalType,ValueType> > > st_bases(1);
st_bases[0] = st_1d_basis;
st_basis =
Teuchos::rcp(new Stokhos::CompletePolynomialBasis<OrdinalType,ValueType>(st_bases, 1e-15));
st_sz = st_basis->size();
u_st.reset(st_basis);
v_st.reset(st_basis);
u_st[0] = u.mean();
u_st[1] = 1.0;
// Tensor product quadrature
st_quad =
Teuchos::rcp(new Stokhos::TensorProductQuadrature<OrdinalType,ValueType>(st_basis));
// Triple product tensor
Teuchos::RCP<Stokhos::Sparse3Tensor<int,double> > st_Cijk =
st_basis->computeTripleProductTensor(st_basis->size());
// Quadrature expansion
Stokhos::QuadOrthogPolyExpansion<OrdinalType,ValueType> st_exp(st_basis,
st_Cijk,
st_quad);
st_exp.times(v_st, u_st, u_st);
}