Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_UnitTestHelpers.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef STOKHOS_UNIT_TEST_HELPERS_HPP
43 #define STOKHOS_UNIT_TEST_HELPERS_HPP
44 
46 #include "Stokhos_ProductBasis.hpp"
49 #include "Teuchos_FancyOStream.hpp"
50 
51 namespace Stokhos {
52 
53  template<class OrdinalType, class ValueType>
55  const std::string& a1_name,
57  const std::string& a2_name,
58  const ValueType& rel_tol, const ValueType& abs_tol,
60  {
61  bool success = true;
62 
63  out << "Comparing " << a1_name << " == " << a2_name << " ... ";
64 
65  const OrdinalType n = a1.size();
66 
67  // Compare sizes
68  if (a2.size() != n) {
69  out << "\nError, "<<a1_name<<".size() = "<<a1.size()<<" == "
70  << a2_name<<".size() = "<<a2.size()<<" : failed!\n";
71  return false;
72  }
73 
74  // Compare elements
75  for( OrdinalType i = 0; i < n; ++i ) {
76  ValueType nrm = std::sqrt(a1.basis()->norm_squared(i));
77  ValueType err = std::abs(a1[i] - a2[i]) / nrm;
78  ValueType tol =
79  abs_tol + rel_tol*std::max(std::abs(a1[i]),std::abs(a2[i]))/nrm;
80  if (err > tol) {
81  out
82  <<"\nError, relErr("<<a1_name<<"["<<i<<"],"
83  <<a2_name<<"["<<i<<"]) = relErr("<<a1[i]<<","<<a2[i]<<") = "
84  <<err<<" <= tol = "<<tol<<": failed!\n";
85  success = false;
86  }
87  }
88  if (success) {
89  out << "passed\n";
90  }
91  else {
92  out << std::endl
93  << a1_name << " = " << a1 << std::endl
94  << a2_name << " = " << a2 << std::endl;
95  }
96 
97  return success;
98  }
99 
100  template<class ValueType>
101  bool compareValues(const ValueType& a1,
102  const std::string& a1_name,
103  const ValueType&a2,
104  const std::string& a2_name,
105  const ValueType& rel_tol, const ValueType& abs_tol,
107  {
108  bool success = true;
109 
110  ValueType err = std::abs(a1 - a2);
111  ValueType tol = abs_tol + rel_tol*std::max(std::abs(a1),std::abs(a2));
112  if (err > tol) {
113  out << "\nError, relErr(" << a1_name <<","
114  << a2_name << ") = relErr(" << a1 <<"," << a2 <<") = "
115  << err << " <= tol = " << tol << ": failed!\n";
116  success = false;
117  }
118 
119  return success;
120  }
121 
122  template<class ValueType, class VectorType1, class VectorType2>
123  bool compareVecs(const VectorType1& a1,
124  const std::string& a1_name,
125  const VectorType2&a2,
126  const std::string& a2_name,
127  const ValueType& rel_tol, const ValueType& abs_tol,
129  {
130  bool success = true;
131 
132  out << "Comparing " << a1_name << " == " << a2_name << " ... ";
133 
134  const int n = a1.size();
135 
136  // Compare sizes
137  if (a2.size() != n) {
138  out << "\nError, "<<a1_name<<".size() = "<<a1.size()<<" == "
139  << a2_name<<".size() = "<<a2.size()<<" : failed!\n";
140  return false;
141  }
142 
143  // Compare elements
144  for( int i = 0; i < n; ++i ) {
145  ValueType err = std::abs(a1.coeff(i) - a2.coeff(i));
146  ValueType tol =
147  abs_tol + rel_tol*std::max(std::abs(a1.fastAccessCoeff(i)),
148  std::abs(a2.fastAccessCoeff(i)));
149  if (err > tol) {
150  out
151  <<"\nError, relErr("<<a1_name<<"["<<i<<"],"
152  <<a2_name<<"["<<i<<"]) = relErr("<<a1.coeff(i)<<","<<a2.coeff(i)
153  <<") = "<<err<<" <= tol = "<<tol<<": failed!\n";
154  success = false;
155  }
156  }
157  if (success) {
158  out << "passed\n";
159  }
160  else {
161  out << std::endl
162  << a1_name << " = " << a1 << std::endl
163  << a2_name << " = " << a2 << std::endl;
164  }
165 
166  return success;
167  }
168 
169  template<class Array1, class Array2, class ValueType>
170  bool compareArrays(const Array1& a1, const std::string& a1_name,
171  const Array2& a2, const std::string& a2_name,
172  const ValueType& rel_tol,
173  const ValueType& abs_tol,
175  {
176  using Teuchos::as;
177  bool success = true;
178 
179  out << "Comparing " << a1_name << " == " << a2_name << " ... ";
180 
181  const int n = a1.size();
182 
183  // Compare sizes
184  if (as<int>(a2.size()) != n) {
185  out << "\nError, "<<a1_name<<".size() = "<<a1.size()<<" == "
186  << a2_name<<".size() = "<<a2.size()<<" : failed!\n";
187  return false;
188  }
189 
190  // Compare elements
191  for( int i = 0; i < n; ++i ) {
192  ValueType err = std::abs(a1[i] - a2[i]);
193  ValueType tol =
194  abs_tol + rel_tol*std::max(std::abs(a1[i]),std::abs(a2[i]));
195  if (err > tol) {
196  out << "\nError, relErr(" << a1_name << "[" << i << "]," << a2_name
197  << "[" << i << "]) = relErr(" << a1[i] << "," <<a2[i] <<") = "
198  << err << " <= tol = " << tol << ": failed!\n";
199  success = false;
200  }
201  }
202  if (success) {
203  out << "passed\n";
204  }
205 
206  return success;
207  }
208 
209  template<class ordinal_type, class scalar_type>
212  const std::string& a1_name,
214  const std::string& a2_name,
215  const scalar_type& rel_tol,
216  const scalar_type& abs_tol,
218  {
219  using Teuchos::as;
220  bool success = true;
221 
222  out << "Comparing " << a1_name << " == " << a2_name << " ... ";
223 
224  const ordinal_type m = a1.numRows();
225  const ordinal_type n = a1.numCols();
226 
227  // Compare number of rows
228  if (a2.numRows() != m) {
229  out << "\nError, "<<a1_name<<".numRows() = "<<a1.numRows()<<" == "
230  << a2_name<<".numRows() = "<<a2.numRows()<<" : failed!\n";
231  return false;
232  }
233 
234  // Compare number of columnns
235  if (a2.numCols() != n) {
236  out << "\nError, "<<a1_name<<".numCols() = "<<a1.numCols()<<" == "
237  << a2_name<<".numCols() = "<<a2.numCols()<<" : failed!\n";
238  return false;
239  }
240 
241  // Compare elements
242  for (ordinal_type i=0; i<m; i++) {
243  for (ordinal_type j=0; j<n; j++) {
244  scalar_type err = std::abs(a1(i,j) - a2(i,j));
245  scalar_type tol =
246  abs_tol + rel_tol*std::max(std::abs(a1(i,j)),std::abs(a2(i,j)));
247  if (err > tol) {
248  out << "\nError, relErr(" << a1_name << "(" << i << "," << j << "), "
249  << a2_name << "(" << i << "," << j << ")) = relErr("
250  << a1(i,j) << ", " <<a2(i,j) <<") = "
251  << err << " <= tol = " << tol << ": failed!\n";
252  success = false;
253  }
254  }
255  }
256  if (success) {
257  out << "passed\n";
258  }
259 
260  return success;
261  }
262 
263  template<class ordinal_type, class scalar_type>
266  const std::string& cijk1_name,
268  const std::string& cijk2_name,
269  const scalar_type& rel_tol,
270  const scalar_type& abs_tol,
272  {
274  bool success = true;
275 
276  out << "Comparing " << cijk1_name << " == " << cijk2_name << " ... ";
277 
278  // Check number of nonzeros
279  TEUCHOS_TEST_EQUALITY(Cijk1.num_entries(), Cijk2.num_entries(), out,
280  success);
281 
282  // Check entries
283  for (typename Cijk_type::k_iterator k_it=Cijk2.k_begin();
284  k_it!=Cijk2.k_end(); ++k_it) {
285  ordinal_type k = Stokhos::index(k_it);
286  for (typename Cijk_type::kj_iterator j_it = Cijk2.j_begin(k_it);
287  j_it != Cijk2.j_end(k_it); ++j_it) {
288  ordinal_type j = Stokhos::index(j_it);
289  for (typename Cijk_type::kji_iterator i_it = Cijk2.i_begin(j_it);
290  i_it != Cijk2.i_end(j_it); ++i_it) {
291  ordinal_type i = Stokhos::index(i_it);
292  scalar_type c1 = Cijk1.getValue(i,j,k);
293  scalar_type c2 = Stokhos::value(i_it);
294 
295  double tol = abs_tol + c2*rel_tol;
296  double err = std::abs(c1-c2);
297  bool s = err < tol;
298  if (!s) {
299  out << std::endl
300  << "Check: rel_err( C(" << i << "," << j << "," << k << ") )"
301  << " = " << "rel_err( " << c1 << ", " << c2 << " ) = " << err
302  << " <= " << tol << " : ";
303  if (s) out << "Passed.";
304  else
305  out << "Failed!";
306  out << std::endl;
307  }
308  success = success && s;
309  }
310  }
311  }
312 
313  return success;
314  }
315 
316  template<class ordinal_type, class scalar_type>
320  const scalar_type& sparse_tol,
321  const scalar_type& rel_tol,
322  const scalar_type& abs_tol,
324  bool linear = false)
325  {
326  ordinal_type d = basis.dimension();
327  ordinal_type sz = basis.size();
331  for (ordinal_type i=0; i<d; i++)
332  Cijk_1d[i] = bases[i]->computeTripleProductTensor();
333  for (ordinal_type j=0; j<sz; j++) {
334  Stokhos::MultiIndex<ordinal_type> terms_j = basis.term(j);
335  for (ordinal_type i=0; i<sz; i++) {
336  Stokhos::MultiIndex<ordinal_type> terms_i = basis.term(i);
337  for (ordinal_type k=0; k<sz; k++) {
338  Stokhos::MultiIndex<ordinal_type> terms_k = basis.term(k);
339  if (!linear || terms_k.order() <= 1) {
340  scalar_type c = 1.0;
341  for (ordinal_type l=0; l<d; l++)
342  c *= (*Cijk_1d[l])(terms_i[l],terms_j[l],terms_k[l]);
343  if (std::abs(c/basis.norm_squared(i)) > sparse_tol)
344  Cijk2.add_term(i,j,k,c);
345  }
346  }
347  }
348  }
349  Cijk2.fillComplete();
350 
351  // std::cout << std::endl << Cijk << std::endl;
352  // std::cout << std::endl << Cijk2 << std::endl;
353 
354  bool success = compareSparse3Tensor(Cijk, "Cijk", Cijk2, "Cijk2",
355  rel_tol, abs_tol, out);
356 
357  return success;
358  }
359 
360  template <typename operator_type1, typename operator_type2,
361  typename scalar_type>
362  bool testPseudoSpectralPoints(const operator_type1& op1,
363  const operator_type2& op2,
364  const scalar_type& rel_tol,
365  const scalar_type& abs_tol,
366  Teuchos::FancyOStream& out) {
367  bool success = true;
368 
369  typedef typename operator_type1::const_set_iterator point_iterator_type;
370 
371  // Check sizes
372  TEUCHOS_TEST_EQUALITY(op1.point_size(), op2.point_size(), out, success);
373  if (!success) return false;
374 
375  // Compare points
376  point_iterator_type pi1 = op1.set_begin();
377  point_iterator_type pi2 = op2.set_begin();
378  while (pi1 != op1.set_end() || pi2 != op2.set_end()) {
379  std::stringstream ss1, ss2;
380  ss1 << pi1->first;
381  ss2 << pi2->first;
382  success = success &&
383  Stokhos::compareArrays(pi1->first, ss1.str(),
384  pi2->first, ss2.str(),
385  rel_tol, abs_tol, out);
386 
387  std::stringstream ss3, ss4;
388  ss3 << pi1->second.first;
389  ss4 << pi2->second.first;
390  success = success &&
391  Stokhos::compareValues(pi1->second.first, ss3.str(),
392  pi2->second.first, ss4.str(),
393  rel_tol, abs_tol, out);
394  ++pi1;
395  ++pi2;
396  }
397 
398  return success;
399  }
400 
401  template <typename operator_type1, typename operator_type2,
402  typename func_type1, typename func_type2,
403  typename scalar_type>
404  bool testPseudoSpectralApply(const operator_type1& op1,
405  const operator_type2& op2,
406  const func_type1& func1,
407  const func_type2& func2,
408  const scalar_type& rel_tol,
409  const scalar_type& abs_tol,
410  Teuchos::FancyOStream& out) {
411  bool success = true;
412 
414  typedef typename operator_type1::value_type value_type;
415  typedef typename operator_type1::const_iterator point_iterator_type;
416 
417  // Check sizes
418  TEUCHOS_TEST_EQUALITY(op1.coeff_size(), op2.coeff_size(), out, success);
419  if (!success)
420  return false;
421 
422  ordinal_type point_sz1 = op1.point_size();
423  ordinal_type point_sz2 = op2.point_size();
424  ordinal_type coeff_sz = op1.coeff_size();
425 
426  // Evaluate function at quadrature points
428  ordinal_type idx = 0;
429  for (point_iterator_type pi = op1.begin(); pi != op1.end(); ++pi) {
430  f(idx,0) = func1(*pi);
431  f(idx,1) = func2(*pi);
432  ++idx;
433  }
434 
436  idx = 0;
437  for (point_iterator_type pi = op2.begin(); pi != op2.end(); ++pi) {
438  f2(idx,0) = func1(*pi);
439  f2(idx,1) = func2(*pi);
440  ++idx;
441  }
442 
443  // Compare function evaluations
444  if (point_sz1 == point_sz2)
445  success = success &&
446  Stokhos::compareSDM(f, "f", f2, "f2", rel_tol, abs_tol, out);
447 
448  // Compute PCE coefficients
450  op1.transformQP2PCE(1.0, f, x, 0.0);
451 
453  op2.transformQP2PCE(1.0, f2, x2, 0.0);
454 
455  // Compare PCE coefficients
456  success = success &&
457  Stokhos::compareSDM(x, "x", x2, "x2", rel_tol, abs_tol, out);
458 
459  return success;
460  }
461 
462  template <typename operator_type1, typename operator_type2,
463  typename func_type1, typename func_type2,
464  typename scalar_type>
465  bool testPseudoSpectralApplyTrans(const operator_type1& op1,
466  const operator_type2& op2,
467  const func_type1& func1,
468  const func_type2& func2,
469  const scalar_type& rel_tol,
470  const scalar_type& abs_tol,
471  Teuchos::FancyOStream& out) {
472  bool success = true;
473 
475  typedef typename operator_type1::value_type value_type;
476  typedef typename operator_type1::const_iterator point_iterator_type;
477 
478  // Check sizes
479  TEUCHOS_TEST_EQUALITY(op1.coeff_size(), op2.coeff_size(), out, success);
480  if (!success)
481  return false;
482 
483  ordinal_type point_sz1 = op1.point_size();
484  ordinal_type point_sz2 = op2.point_size();
485  ordinal_type coeff_sz = op1.coeff_size();
486 
487  // Evaluate function at quadrature points
489  ordinal_type idx = 0;
490  for (point_iterator_type pi = op1.begin(); pi != op1.end(); ++pi) {
491  f(0,idx) = func1(*pi);
492  f(1,idx) = func2(*pi);
493  ++idx;
494  }
495 
497  idx = 0;
498  for (point_iterator_type pi = op2.begin(); pi != op2.end(); ++pi) {
499  f2(0,idx) = func1(*pi);
500  f2(1,idx) = func2(*pi);
501  ++idx;
502  }
503 
504  // Compare function evaluations
505  if (point_sz1 == point_sz2)
506  success = success &&
507  Stokhos::compareSDM(f, "f", f2, "f2", rel_tol, abs_tol, out);
508 
509  // Compute PCE coefficients
511  op1.transformQP2PCE(1.0, f, x, 0.0, true);
512 
514  op2.transformQP2PCE(1.0, f2, x2, 0.0, true);
515 
516  // Compare PCE coefficients
517  success = success &&
518  Stokhos::compareSDM(x, "x", x2, "x2", rel_tol, abs_tol, out);
519 
520  return success;
521  }
522 
523  template <typename basis_type, typename operator_type, typename scalar_type>
525  const operator_type& op,
526  const scalar_type& rel_tol,
527  const scalar_type& abs_tol,
528  Teuchos::FancyOStream& out) {
529  typedef typename operator_type::ordinal_type ordinal_type;
530  typedef typename operator_type::value_type value_type;
531 
532  ordinal_type coeff_sz = op.coeff_size();
533  ordinal_type point_sz = op.point_size();
535  eye.putScalar(0.0);
536  for (ordinal_type i=0; i<coeff_sz; ++i)
537  eye(i,i) = 1.0;
538 
539  // Map PCE coefficients to quad values
541  op.transformPCE2QP(1.0, eye, f, 0.0);
542 
543  // Map quad values to PCE coefficients
545  op.transformQP2PCE(1.0, f, x, 0.0);
546 
547  // Subtract identity
548  for (ordinal_type i=0; i<coeff_sz; ++i)
549  x(i,i) -= 1.0;
550 
551  // Expected answer, which is zero
553  z.putScalar(0.0);
554 
555  out << "Discrete orthogonality error = " << x.normInf() << std::endl;
556 
557  // Compare PCE coefficients
558  bool success = Stokhos::compareSDM(x, "x", z, "zero", rel_tol, abs_tol, out);
559 
560  return success;
561  }
562 
563  /*
564  template <typename basis_type, typename operator_type, typename scalar_type>
565  bool testPseudoSpectralDiscreteOrthogonality(const basis_type& basis,
566  const operator_type& op,
567  const scalar_type& rel_tol,
568  const scalar_type& abs_tol,
569  Teuchos::FancyOStream& out) {
570  typedef typename operator_type::ordinal_type ordinal_type;
571  typedef typename operator_type::value_type value_type;
572 
573  // Evaluate full basis at all quadrature points
574  ordinal_type coeff_sz = op.coeff_size();
575  ordinal_type point_sz = op.point_size();
576  Teuchos::SerialDenseMatrix<ordinal_type,value_type> f(point_sz,coeff_sz);
577  Teuchos::Array<value_type> vals(coeff_sz);
578  ordinal_type i = 0;
579  typename operator_type::const_iterator pi = op.begin();
580  for (; pi != op.end(); ++pi) {
581  basis.evaluateBases(*pi, vals);
582  for (ordinal_type j=0; j<coeff_sz; ++j)
583  f(i,j) = vals[j];
584 
585  ++i;
586  }
587 
588  // Compute PCE coefficients
589  Teuchos::SerialDenseMatrix<ordinal_type,value_type> x(coeff_sz,coeff_sz);
590  op.transformQP2PCE(1.0, f, x, 0.0);
591 
592  // Subtract identity
593  for (ordinal_type i=0; i<coeff_sz; ++i)
594  x(i,i) -= 1.0;
595 
596  // Expected answer, which is zero
597  Teuchos::SerialDenseMatrix<ordinal_type,value_type> z(coeff_sz,coeff_sz);
598  z.putScalar(0.0);
599 
600  out << "Discrete orthogonality error = " << x.normInf() << std::endl;
601 
602  // Compare PCE coefficients
603  bool success = Stokhos::compareSDM(x, "x", z, "zero", 1e-14, 1e-14, out);
604 
605  return success;
606  }
607  */
608 }
609 
610 #endif // STOKHOS_UNIT_TEST_HELPERS_HPP
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
bool compareVecs(const VectorType1 &a1, const std::string &a1_name, const VectorType2 &a2, const std::string &a2_name, const ValueType &rel_tol, const ValueType &abs_tol, Teuchos::FancyOStream &out)
k_iterator k_begin() const
Iterator pointing to first k entry.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
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)
kj_iterator j_begin(const k_iterator &k) const
Iterator pointing to first j entry for given k.
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)
void fillComplete()
Signal all terms have been added.
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)
virtual ordinal_type dimension() const =0
Return dimension of basis.
bool compareSparse3Tensor(const Stokhos::Sparse3Tensor< ordinal_type, scalar_type > &Cijk1, const std::string &cijk1_name, const Stokhos::Sparse3Tensor< ordinal_type, scalar_type > &Cijk2, const std::string &cijk2_name, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
kj_iterator j_end(const k_iterator &k) const
Iterator pointing to last j entry for given k.
bool testSparse3Tensor(const Stokhos::Sparse3Tensor< ordinal_type, scalar_type > &Cijk, const Stokhos::ProductBasis< ordinal_type, scalar_type > &basis, const scalar_type &sparse_tol, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out, bool linear=false)
virtual const MultiIndex< ordinal_type > & term(ordinal_type i) const =0
Get orders of each coordinate polynomial given an index i.
bool compareSDM(const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &a1, const std::string &a1_name, const Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > &a2, const std::string &a2_name, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
void add_term(ordinal_type i, ordinal_type j, ordinal_type k, const value_type &c)
Add new term for given (i,j,k)
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis() const
Return basis.
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
TypeTo as(const TypeFrom &t)
virtual const Teuchos::Array< value_type > & norm_squared() const =0
Return array storing norm-squared of each basis polynomial.
k_iterator k_end() const
Iterator pointing to last k entry.
virtual Teuchos::Array< Teuchos::RCP< const OneDOrthogPolyBasis< ordinal_type, value_type > > > getCoordinateBases() const =0
Return array of coordinate bases.
Legendre polynomial basis.
Stokhos::Sparse3Tensor< int, double > Cijk_type
OrdinalType numCols() const
ScalarTraits< ScalarType >::magnitudeType normInf() const
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
bool testPseudoSpectralDiscreteOrthogonality(const basis_type &basis, const operator_type &op, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
ordinal_type order() const
Compute total order of index.
ordinal_type size() const
Return size.
value_type getValue(ordinal_type i, ordinal_type j, ordinal_type k) const
Get Cijk value for a given i, j, k indices.
kji_iterator i_begin(const kj_iterator &j) const
Iterator pointing to first i entry for given j and k.
bool testPseudoSpectralPoints(const operator_type1 &op1, const operator_type2 &op2, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
kji_iterator i_end(const kj_iterator &j) const
Iterator pointing to last i entry for given j and k.
bool testPseudoSpectralApply(const operator_type1 &op1, const operator_type2 &op2, const func_type1 &func1, const func_type2 &func2, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
int n
virtual ordinal_type size() const =0
Return total size of basis.
bool testPseudoSpectralApplyTrans(const operator_type1 &op1, const operator_type2 &op2, const func_type1 &func1, const func_type2 &func2, const scalar_type &rel_tol, const scalar_type &abs_tol, Teuchos::FancyOStream &out)
ordinal_type num_entries() const
Return number of non-zero entries.
OrdinalType numRows() const