44 namespace PseudoSpectralExpansionUnitTest {
46 template <
class Func,
typename OrdinalType,
typename ValueType>
61 OrdinalType nqp = weights.
size();
64 for (OrdinalType i=0; i<c.
size(); i++)
69 for (OrdinalType k=0; k<nqp; k++) {
72 for (
int i=0; i<c.
size(); i++)
73 c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
77 template <
class Func,
typename OrdinalType,
typename ValueType>
93 OrdinalType nqp = weights.
size();
96 for (OrdinalType i=0; i<c.
size(); i++)
101 for (OrdinalType k=0; k<nqp; k++) {
102 ValueType val1 = a.
evaluate(points[k], values[k]);
103 ValueType val2 = b.
evaluate(points[k], values[k]);
104 ValueType
val = func(val1, val2);
105 for (
int i=0; i<c.
size(); i++)
106 c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
110 template <
class Func,
typename OrdinalType,
typename ValueType>
127 OrdinalType nqp = weights.
size();
130 for (OrdinalType i=0; i<c.
size(); i++)
135 for (OrdinalType k=0; k<nqp; k++) {
136 ValueType val2 = b.
evaluate(points[k], values[k]);
137 ValueType
val = func(a, val2);
138 for (
int i=0; i<c.
size(); i++)
139 c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
143 template <
class Func,
typename OrdinalType,
typename ValueType>
160 OrdinalType nqp = weights.
size();
163 for (OrdinalType i=0; i<c.
size(); i++)
168 for (OrdinalType k=0; k<nqp; k++) {
169 ValueType val1 = a.
evaluate(points[k], values[k]);
170 ValueType
val = func(val1, b);
171 for (
int i=0; i<c.
size(); i++)
172 c[i] += weights[k]*val*values[k][i] / basis->norm_squared(i);
233 return 0.5*
std::log((1.0+a)/(1.0-a));
238 double operator() (
double a,
double b)
const {
return a + b; }
241 double operator() (
double a,
double b)
const {
return a - b; }
244 double operator() (
double a,
double b)
const {
return a * b; }
247 double operator() (
double a,
double b)
const {
return a / b; }
257 computePCE1<UMinusFunc>(
setup.u2, v, *
setup.quad);
593 computePCE2<PlusFunc>(
setup.u2, v, w, *
setup.quad);
640 setup.exp->plus(ru, v, w);
641 computePCE2<PlusFunc>(
setup.u2, v, w, *
setup.quad);
709 computePCE2<MinusFunc>(
setup.u2, v, w, *
setup.quad);
756 setup.exp->minus(ru, v, w);
757 computePCE2<MinusFunc>(
setup.u2, v, w, *
setup.quad);
825 computePCE2<TimesFunc>(
setup.u2, v, w, *
setup.quad);
872 setup.exp->times(ru, v, w);
873 computePCE2<TimesFunc>(
setup.u2, v, w, *
setup.quad);
957 computePCE2<DivideFunc>(
setup.u2, v, w, *
setup.quad);
1004 setup.exp->divide(ru, v, w);
1005 computePCE2<DivideFunc>(
setup.u2, v, w, *
setup.quad);
1189 setup.exp->plusEqual(ru, v);
1242 setup.exp->minusEqual(ru, v);
1243 setup.exp->unaryMinus(v, v);
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
void computePCE2LC(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, ValueType a, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &b, const Stokhos::Quadrature< OrdinalType, ValueType > &quad)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
value_type evaluate(const Teuchos::Array< value_type > &point) const
Evaluate polynomial approximation at a point.
double operator()(double a) const
double operator()(double a) const
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
double operator()(double a, double b) const
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)
double operator()(double a, double b) const
virtual const Teuchos::Array< Teuchos::Array< value_type > > & getBasisAtQuadPoints() const =0
Get values of basis at quadrature points.
double operator()(double a) const
double operator()(double a) const
void computePCE1(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a, const Stokhos::Quadrature< OrdinalType, ValueType > &quad)
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
double operator()(double a) const
UnitTestSetup< int, double > setup
void computePCE2RC(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a, ValueType b, const Stokhos::Quadrature< OrdinalType, ValueType > &quad)
double operator()(double a) const
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
virtual const Teuchos::Array< value_type > & getQuadWeights() const =0
Get quadrature weights.
virtual const Teuchos::Array< Teuchos::Array< value_type > > & getQuadPoints() const =0
Get quadrature points.
double operator()(double a, double b) const
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis() const
Return basis.
double operator()(double a) const
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
double operator()(double a) const
TEUCHOS_UNIT_TEST(Stokhos_PSExpansion, UMinus)
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
double operator()(double a) const
double operator()(double a) const
double operator()(double a) const
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
ordinal_type size() const
Return size.
void computePCE2(Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &c, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &a, const Stokhos::OrthogPolyApprox< OrdinalType, ValueType > &b, const Stokhos::Quadrature< OrdinalType, ValueType > &quad)
double operator()(double a, double b) const
double operator()(double a, double b) const
double operator()(double a) const
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
double operator()(double a) const