51 #ifdef HAVE_STOKHOS_FORUQTK
55 namespace HermiteBasisUnitTest {
58 template <
typename OrdinalType,
typename ValueType>
71 int order =
setup.basis.order();
76 int size =
setup.basis.size();
84 for (
int i=1; i<=
setup.p; i++)
93 n1[0] =
setup.basis.norm_squared(0);
95 for (
int i=1; i<=
setup.p; i++) {
96 n1[i] =
setup.basis.norm_squared(i);
108 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
110 for (
int i=0; i<=
setup.p; i++) {
112 for (
int j=0;
j<nqp;
j++)
113 n2[i] += w[
j]*v[
j][i]*v[
j][i];
124 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
127 for (
int i=0; i<=
setup.p; i++) {
129 for (
int k=0; k<nqp; k++)
130 mat(i,
j) += w[k]*v[k][i]*v[k][
j];
137 out <<
"\n Error, mat.normInf() < atol = " << mat.
normInf()
138 <<
" < " <<
setup.atol <<
": failed!\n";
139 out <<
"mat = " << mat << std::endl;
145 setup.basis.computeTripleProductTensor();
149 setup.basis.getQuadPoints(3*
setup.p, x, w, v);
152 for (
int i=0; i<=
setup.p; i++) {
154 for (
int k=0; k<=
setup.p; k++) {
157 for (
int qp=0; qp<nqp; qp++)
158 c += w[qp]*v[qp][i]*v[qp][
j]*v[qp][k];
159 std::stringstream ss;
160 ss <<
"Cijk(" << i <<
"," <<
j <<
"," << k <<
")";
171 setup.basis.computeDerivDoubleProductTensor();
175 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
179 for (
int i=0; i<nqp; i++) {
182 setup.basis.evaluateBasesAndDerivatives(x[i], val[i], deriv[i]);
186 for (
int i=0; i<=
setup.p; i++) {
189 for (
int qp=0; qp<nqp; qp++)
190 b += w[qp]*deriv[qp][i]*val[qp][
j];
191 std::stringstream ss;
192 ss <<
"Bij(" << i <<
"," <<
j <<
")";
223 setup.basis.evaluateBases(x, v1);
232 for (
int i=2; i<=
setup.p; i++)
242 setup.basis.evaluateBasesAndDerivatives(x, val1, deriv1);
251 for (
int i=2; i<=
setup.p; i++)
257 for (
int i=2; i<=
setup.p; i++)
258 deriv2[i] = (val2[i-1] + x*deriv2[i-1] -
std::sqrt(i-1.0)*deriv2[i-2]) /
270 for (
int i=0; i<=
setup.p; i++)
271 v1[i] =
setup.basis.evaluate(x, i);
280 for (
int i=2; i<=
setup.p; i++)
291 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
294 a2[0] = 0.0; b2[0] = 1.0; c2[0] = 1.0; d2[0] = 1.0;
295 for (
int i=1; i<=
setup.p; i++) {
317 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
323 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
325 for (
int i=0; i<=
setup.p; i++) {
327 for (
int j=0;
j<nqp;
j++)
328 a2[i] += w[
j]*x[
j]*v[
j][i]*v[
j][i];
329 a2[i] = a2[i]*c1[i]/n1[i];
341 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
346 for (
int i=1; i<=
setup.p; i++) {
347 b2[i] = d1[i]*(c1[i]/c1[i-1])*(n1[i]/n1[i-1]);
353 #ifdef HAVE_STOKHOS_DAKOTA
358 setup.basis.getQuadPoints(
setup.p, x1, w1, v1);
362 webbur::hermite_compute(n, &x2[0], &w2[0]);
364 for (
int i=0; i<n; i++) {
367 v2[i].resize(
setup.p+1);
368 setup.basis.evaluateBases(x2[i], v2[i]);
375 for (
int i=0; i<n; i++) {
376 std::stringstream ss1, ss2;
377 ss1 <<
"v1[" << i <<
"]";
378 ss2 <<
"v2[" << i <<
"]";
386 #ifdef HAVE_STOKHOS_FORUQTK
391 setup.basis.getQuadPoints(
setup.p, x1, w1, v1);
397 double endpts[2] = {0.0, 0.0};
401 GAUSSQ_F77(&kind, &n, &alpha, &beta, &kpts, endpts, &b[0], &x2[0], &w2[0]);
403 for (
int i=0; i<n; i++) {
406 v2[i].resize(
setup.p+1);
407 setup.basis.evaluateBases(x2[i], v2[i]);
414 for (
int i=0; i<n; i++) {
415 std::stringstream ss1, ss2;
416 ss1 <<
"v1[" << i <<
"]";
417 ss2 <<
"v2[" << i <<
"]";
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
bool compareArrays(const Array1 &a1, const std::string &a1_name, const Array2 &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
bool compareValues(const ValueType &a1, const std::string &a1_name, const ValueType &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
static int runUnitTestsFromMain(int argc, char *argv[])
KOKKOS_INLINE_FUNCTION PCE< Storage > ceil(const PCE< Storage > &a)
UnitTestSetup< int, double > setup
void resize(size_type new_size, const value_type &x=value_type())
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
int main(int argc, char **argv)
ScalarTraits< ScalarType >::magnitudeType normInf() const
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
Stokhos::HermiteBasis< OrdinalType, ValueType > basis
TEUCHOS_UNIT_TEST(Stokhos_HermiteBasis, Order)
void GAUSSQ_F77(int *kind, int *n, double *alpha, double *beta, int *kpts, double *endpts, double *b, double *x, double *w)