17 #ifdef HAVE_STOKHOS_FORUQTK
21 namespace HermiteBasisUnitTest {
24 template <
typename OrdinalType,
typename ValueType>
37 int order =
setup.basis.order();
42 int size =
setup.basis.size();
50 for (
int i=1; i<=
setup.p; i++)
59 n1[0] =
setup.basis.norm_squared(0);
61 for (
int i=1; i<=
setup.p; i++) {
62 n1[i] =
setup.basis.norm_squared(i);
76 for (
int i=0; i<=
setup.p; i++) {
78 for (
int j=0;
j<nqp;
j++)
79 n2[i] += w[
j]*v[
j][i]*v[
j][i];
93 for (
int i=0; i<=
setup.p; i++) {
95 for (
int k=0; k<nqp; k++)
96 mat(i,
j) += w[k]*v[k][i]*v[k][
j];
103 out <<
"\n Error, mat.normInf() < atol = " << mat.
normInf()
104 <<
" < " <<
setup.atol <<
": failed!\n";
105 out <<
"mat = " <<
printMat(mat) << std::endl;
111 setup.basis.computeTripleProductTensor();
115 setup.basis.getQuadPoints(3*
setup.p, x, w, v);
118 for (
int i=0; i<=
setup.p; i++) {
120 for (
int k=0; k<=
setup.p; k++) {
123 for (
int qp=0; qp<nqp; qp++)
124 c += w[qp]*v[qp][i]*v[qp][
j]*v[qp][k];
125 std::stringstream ss;
126 ss <<
"Cijk(" << i <<
"," <<
j <<
"," << k <<
")";
137 setup.basis.computeDerivDoubleProductTensor();
141 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
145 for (
int i=0; i<nqp; i++) {
148 setup.basis.evaluateBasesAndDerivatives(x[i], val[i], deriv[i]);
152 for (
int i=0; i<=
setup.p; i++) {
155 for (
int qp=0; qp<nqp; qp++)
156 b += w[qp]*deriv[qp][i]*val[qp][
j];
157 std::stringstream ss;
158 ss <<
"Bij(" << i <<
"," <<
j <<
")";
168 setup.basis.computeDerivDoubleProductTensor();
172 for (
int i=0; i<=
setup.p; i++) {
177 std::stringstream ss;
178 ss <<
"Bij(" << i <<
"," <<
j <<
")";
189 setup.basis.evaluateBases(x, v1);
198 for (
int i=2; i<=
setup.p; i++)
199 v2[i] = x*v2[i-1] - (i-1.0)*v2[i-2];
208 setup.basis.evaluateBasesAndDerivatives(x, val1, deriv1);
217 for (
int i=2; i<=
setup.p; i++)
218 val2[i] = x*val2[i-1] - (i-1.0)*val2[i-2];
223 for (
int i=2; i<=
setup.p; i++)
224 deriv2[i] = i*val2[i-1];
237 for (
int i=0; i<=
setup.p; i++)
238 v1[i] =
setup.basis.evaluate(x, i);
247 for (
int i=2; i<=
setup.p; i++)
248 v2[i] = x*v2[i-1] - (i-1.0)*v2[i-2];
258 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
261 a2[0] = 0.0; b2[0] = 1.0; c2[0] = 1.0; d2[0] = 1.0;
262 for (
int i=1; i<=
setup.p; i++) {
284 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
290 setup.basis.getQuadPoints(2*
setup.p, x, w, v);
292 for (
int i=0; i<=
setup.p; i++) {
294 for (
int j=0;
j<nqp;
j++)
295 a2[i] += w[
j]*x[
j]*v[
j][i]*v[
j][i];
296 a2[i] = a2[i]*c1[i]/n1[i];
308 setup.basis.getRecurrenceCoefficients(a1, b1, c1, d1);
313 for (
int i=1; i<=
setup.p; i++) {
314 b2[i] = d1[i]*(c1[i]/c1[i-1])*(n1[i]/n1[i-1]);
320 #ifdef HAVE_STOKHOS_DAKOTA
325 setup.basis.getQuadPoints(
setup.p, x1, w1, v1);
329 webbur::hermite_compute(n, &x2[0], &w2[0]);
331 for (
int i=0; i<n; i++) {
334 v2[i].resize(
setup.p+1);
335 setup.basis.evaluateBases(x2[i], v2[i]);
342 for (
int i=0; i<n; i++) {
343 std::stringstream ss1, ss2;
344 ss1 <<
"v1[" << i <<
"]";
345 ss2 <<
"v2[" << i <<
"]";
353 #ifdef HAVE_STOKHOS_FORUQTK
358 setup.basis.getQuadPoints(
setup.p, x1, w1, v1);
364 double endpts[2] = {0.0, 0.0};
368 GAUSSQ_F77(&kind, &n, &alpha, &beta, &kpts, endpts, &b[0], &x2[0], &w2[0]);
370 for (
int i=0; i<n; i++) {
373 v2[i].resize(
setup.p+1);
374 setup.basis.evaluateBases(x2[i], v2[i]);
381 for (
int i=0; i<n; i++) {
382 std::stringstream ss1, ss2;
383 ss1 <<
"v1[" << i <<
"]";
384 ss2 <<
"v2[" << i <<
"]";
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
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)