本文整理汇总了C++中stokhos::OrthogPolyApprox类的典型用法代码示例。如果您正苦于以下问题:C++ OrthogPolyApprox类的具体用法?C++ OrthogPolyApprox怎么用?C++ OrthogPolyApprox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrthogPolyApprox类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Stokhos::ConstantOrthogPolyExpansion<ordinal_type, value_type>::
plusEqual(Stokhos::OrthogPolyApprox<ordinal_type, value_type>& c,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type>& x)
{
if (c.size() < 1)
c.resize(1);
c[0] += x[0];
}
示例2:
void
Stokhos::ConstantOrthogPolyExpansion<ordinal_type, value_type>::
divideEqual(Stokhos::OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
const value_type& val)
{
if (c.size() < 1)
c.resize(1);
c[0] /= val;
}
示例3:
void
Stokhos::QuadOrthogPolyExpansion<ordinal_type, value_type>::
divideEqual(Stokhos::OrthogPolyApprox<ordinal_type, value_type>& c,
const value_type& val)
{
ordinal_type pc = c.size();
value_type* cc = c.coeff();
for (ordinal_type i=0; i<pc; i++)
cc[i] /= val;
}
示例4: comparePCEs
bool comparePCEs(const PCEType& a1,
const std::string& a1_name,
const Stokhos::OrthogPolyApprox<OrdinalType,ValueType>&a2,
const std::string& a2_name,
const ValueType& rel_tol, const ValueType& abs_tol,
Teuchos::FancyOStream& out)
{
bool success = true;
out << "Comparing " << a1_name << " == " << a2_name << " ... ";
const OrdinalType n = a1.size();
// Compare sizes
if (a2.size() != n) {
out << "\nError, "<<a1_name<<".size() = "<<a1.size()<<" == "
<< a2_name<<".size() = "<<a2.size()<<" : failed!\n";
return false;
}
// Compare elements
for( OrdinalType i = 0; i < n; ++i ) {
ValueType nrm = std::sqrt(a2.basis()->norm_squared(i));
ValueType err = std::abs(a1.coeff(i) - a2[i]) / nrm;
ValueType tol =
abs_tol + rel_tol*std::max(std::abs(a1.coeff(i)),std::abs(a2[i]))/nrm;
if (err > tol) {
out
<<"\nError, relErr("<<a1_name<<"["<<i<<"],"
<<a2_name<<"["<<i<<"]) = relErr("<<a1.coeff(i)<<","<<a2[i]<<") = "
<<err<<" <= tol = "<<tol<<": failed!\n";
success = false;
}
}
if (success) {
out << "passed\n";
}
else {
out << std::endl
<< a1_name << " = " << a1 << std::endl
<< a2_name << " = " << a2 << std::endl;
}
return success;
}
示例5: 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);
}