42#include "Teuchos_SerialDenseMatrix.hpp"
70template <
typename Storage>
72typename PCE<Storage>::value_type
74standard_deviation()
const {
77 const_pointer c = this->coeff();
78 for (ordinal_type i=1; i<sz; ++i)
83template <
typename Storage>
85typename PCE<Storage>::value_type
87two_norm_squared()
const {
90 const_pointer c = this->coeff();
91 for (ordinal_type i=0; i<sz; ++i)
96template <
typename Storage>
98typename PCE<Storage>::value_type
100inner_product(
const PCE& x)
const {
105 const_pointer c = this->coeff();
106 const_pointer xc =
x.coeff();
107 for (ordinal_type i=0; i<n; ++i)
112template <
typename Storage>
113KOKKOS_INLINE_FUNCTION
116isEqualTo(
const PCE& x)
const {
117 typedef IsEqual<value_type> IE;
119 if (
x.size() != sz)
return false;
121 for (ordinal_type i=0; i<sz; i++)
122 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
126template <
typename Storage>
127KOKKOS_INLINE_FUNCTION
130isEqualTo(
const PCE& x)
const volatile {
131 typedef IsEqual<value_type> IE;
133 if (
x.size() != sz)
return false;
135 for (ordinal_type i=0; i<sz; i++)
136 eq = eq && IE::eval(
x.coeff(i), this->coeff(i));
140template <
typename Storage>
141KOKKOS_INLINE_FUNCTION
144operator=(
const typename PCE<Storage>::value_type v)
151template <
typename Storage>
152KOKKOS_INLINE_FUNCTION
155operator=(
const typename PCE<Storage>::value_type v)
volatile
159 return const_cast<PCE&
>(*this);
162template <
typename Storage>
163KOKKOS_INLINE_FUNCTION
166operator=(
const PCE<Storage>& x)
181 if (s_.size() >
x.s_.size())
182 for (ordinal_type i=
x.s_.size(); i<s_.size(); i++)
188template <
typename Storage>
189KOKKOS_INLINE_FUNCTION
192operator=(
const volatile PCE<Storage>& x)
196 cijk_ =
const_cast<const my_cijk_type&
>(
x.cijk_);
207 if (s_.size() >
x.s_.size())
208 for (ordinal_type i=
x.s_.size(); i<s_.size(); i++)
214template <
typename Storage>
215KOKKOS_INLINE_FUNCTION
218operator=(
const PCE<Storage>& x)
volatile
222 const_cast<my_cijk_type&
>(cijk_) =
x.cijk_;
233 if (s_.size() >
x.s_.size())
234 for (ordinal_type i=
x.s_.size(); i<s_.size(); i++)
237 return const_cast<PCE&
>(*this);
240template <
typename Storage>
241KOKKOS_INLINE_FUNCTION
244operator=(
const volatile PCE<Storage>& x)
volatile
248 const_cast<my_cijk_type&
>(cijk_) =
249 const_cast<const my_cijk_type&
>(
x.cijk_);
260 if (s_.size() >
x.s_.size())
261 for (ordinal_type i=
x.s_.size(); i<s_.size(); i++)
264 return const_cast<PCE&
>(*this);
267template <
typename Storage>
268KOKKOS_INLINE_FUNCTION
274 PCE<Storage>
x(cijk_, sz);
275 pointer xc =
x.coeff();
276 const_pointer cc = this->coeff();
277 for (ordinal_type i=0; i<sz; ++i)
282template <
typename Storage>
283KOKKOS_INLINE_FUNCTION
289 PCE<Storage>
x(
const_cast<const my_cijk_type&
>(cijk_), sz);
290 pointer xc =
x.coeff();
291 const_volatile_pointer cc = this->coeff();
292 for (ordinal_type i=0; i<sz; ++i)
297template <
typename Storage>
298KOKKOS_INLINE_FUNCTION
301operator*=(
const typename PCE<Storage>::value_type v)
303 pointer cc = this->coeff();
305 for (ordinal_type i=0; i<sz; ++i)
310template <
typename Storage>
311KOKKOS_INLINE_FUNCTION
314operator*=(
const typename PCE<Storage>::value_type v)
volatile
316 volatile_pointer cc = this->coeff();
318 for (ordinal_type i=0; i<sz; ++i)
320 return const_cast<PCE&
>(*this);
323template <
typename Storage>
324KOKKOS_INLINE_FUNCTION
327operator/=(
const typename PCE<Storage>::value_type v)
329 pointer cc = this->coeff();
331 for (ordinal_type i=0; i<sz; ++i)
336template <
typename Storage>
337KOKKOS_INLINE_FUNCTION
340operator/=(
const typename PCE<Storage>::value_type v)
volatile
342 volatile pointer cc = this->coeff();
344 for (ordinal_type i=0; i<sz; ++i)
346 return const_cast<PCE&
>(*this);
349template <
typename Storage>
350KOKKOS_INLINE_FUNCTION
353operator+=(
const PCE<Storage>& x)
358 this->reset(
x.cijk_, xsz);
360 const_pointer xc =
x.coeff();
361 pointer cc = this->coeff();
362 for (ordinal_type i=0; i<xsz; ++i)
367template <
typename Storage>
368KOKKOS_INLINE_FUNCTION
371operator-=(
const PCE<Storage>& x)
376 this->reset(
x.cijk_, xsz);
378 const_pointer xc =
x.coeff();
379 pointer cc = this->coeff();
380 for (ordinal_type i=0; i<xsz; ++i)
385template <
typename Storage>
386KOKKOS_INLINE_FUNCTION
389operator*=(
const PCE<Storage>& x)
395#if !defined(__CUDA_ARCH__)
396 TEUCHOS_TEST_FOR_EXCEPTION(
397 sz != xsz && sz != 1 && xsz != 1, std::logic_error,
398 "Sacado::UQ::PCE::operator*=(): input sizes do not match");
401 if (cijk_.is_empty() && !
x.cijk_.is_empty())
404#if !defined(__CUDA_ARCH__)
405 TEUCHOS_TEST_FOR_EXCEPTION(
406 cijk_.is_empty() && csz != 1, std::logic_error,
407 "Sacado::UQ::PCE::operator*(): empty cijk but expansion size > 1");
413 const_pointer xc =
x.coeff();
414 pointer cc = this->coeff();
417 for (ordinal_type i=0; i<sz; ++i)
422 for (ordinal_type i=0; i<xsz; ++i)
426 PCE<Storage>
y(cijk_, csz);
427 pointer yc =
y.coeff();
428 for (ordinal_type i=0; i<csz; ++i) {
429 const cijk_size_type num_entry = cijk_.num_entry(i);
430 const cijk_size_type entry_beg = cijk_.entry_begin(i);
431 const cijk_size_type entry_end = entry_beg + num_entry;
433 for (cijk_size_type entry = entry_beg; entry < entry_end; ++entry) {
434 const cijk_size_type
j = cijk_.coord(entry,0);
435 const cijk_size_type k = cijk_.coord(entry,1);
436 ytmp += cijk_.value(entry) * ( cc[
j] * xc[k] + cc[k] * xc[
j] );
445template <
typename Storage>
446KOKKOS_INLINE_FUNCTION
449operator/=(
const PCE<Storage>& x)
455#if !defined(__CUDA_ARCH__)
456 TEUCHOS_TEST_FOR_EXCEPTION(
457 sz != xsz && sz != 1 && xsz != 1, std::logic_error,
458 "Sacado::UQ::PCE::operator/=(): input sizes do not match");
461 if (cijk_.is_empty() && !
x.cijk_.is_empty())
467 const_pointer xc =
x.coeff();
468 pointer cc = this->coeff();
470#if defined(__CUDA_ARCH__)
472 for (ordinal_type i=0; i<sz; ++i)
476#if !defined(__CUDA_ARCH__)
479 for (ordinal_type i=0; i<sz; ++i)
484 PCE<Storage>
y(cijk_, csz);
494template <
typename Storage>
495KOKKOS_INLINE_FUNCTION
504 const ordinal_type asz = a.size();
505 const ordinal_type bsz = b.size();
506 const ordinal_type csz = asz > bsz ? asz : bsz;
507 my_cijk_type c_cijk = asz > bsz ? a.cijk() : b.cijk();
509 PCE<Storage> c(c_cijk, csz);
510 const_pointer ac = a.coeff();
511 const_pointer bc = b.coeff();
512 pointer cc = c.coeff();
514 for (ordinal_type i=0; i<bsz; ++i)
515 cc[i] = ac[i] + bc[i];
516 for (ordinal_type i=bsz; i<asz; ++i)
520 for (ordinal_type i=0; i<asz; ++i)
521 cc[i] = ac[i] + bc[i];
522 for (ordinal_type i=asz; i<bsz; ++i)
529template <
typename Storage>
530KOKKOS_INLINE_FUNCTION
533 const PCE<Storage>& b)
539 const ordinal_type bsz = b.size();
540 PCE<Storage> c(b.cijk(), bsz);
541 const_pointer bc = b.coeff();
542 pointer cc = c.coeff();
544 for (ordinal_type i=1; i<bsz; ++i)
549template <
typename Storage>
550KOKKOS_INLINE_FUNCTION
559 const ordinal_type asz = a.size();
560 PCE<Storage> c(a.cijk(), asz);
561 const_pointer ac = a.coeff();
562 pointer cc = c.coeff();
564 for (ordinal_type i=1; i<asz; ++i)
569template <
typename Storage>
570KOKKOS_INLINE_FUNCTION
579 const ordinal_type asz = a.size();
580 const ordinal_type bsz = b.size();
581 const ordinal_type csz = asz > bsz ? asz : bsz;
582 my_cijk_type c_cijk = asz > bsz ? a.cijk() : b.cijk();
584 PCE<Storage> c(c_cijk, csz);
585 const_pointer ac = a.coeff();
586 const_pointer bc = b.coeff();
587 pointer cc = c.coeff();
589 for (ordinal_type i=0; i<bsz; ++i)
590 cc[i] = ac[i] - bc[i];
591 for (ordinal_type i=bsz; i<asz; ++i)
595 for (ordinal_type i=0; i<asz; ++i)
596 cc[i] = ac[i] - bc[i];
597 for (ordinal_type i=asz; i<bsz; ++i)
604template <
typename Storage>
605KOKKOS_INLINE_FUNCTION
608 const PCE<Storage>& b)
614 const ordinal_type bsz = b.size();
615 PCE<Storage> c(b.cijk(), bsz);
616 const_pointer bc = b.coeff();
617 pointer cc = c.coeff();
619 for (ordinal_type i=1; i<bsz; ++i)
624template <
typename Storage>
625KOKKOS_INLINE_FUNCTION
634 const ordinal_type asz = a.size();
635 PCE<Storage> c(a.cijk(), asz);
636 const_pointer ac = a.coeff();
637 pointer cc = c.coeff();
639 for (ordinal_type i=1; i<asz; ++i)
644template <
typename Storage>
645KOKKOS_INLINE_FUNCTION
654 typedef typename my_cijk_type::size_type cijk_size_type;
656 const ordinal_type asz = a.size();
657 const ordinal_type bsz = b.size();
658 const ordinal_type csz = asz > bsz ? asz : bsz;
660#if !defined(__CUDA_ARCH__)
661 TEUCHOS_TEST_FOR_EXCEPTION(
662 asz != bsz && asz != 1 && bsz != 1, std::logic_error,
663 "Sacado::UQ::PCE::operator*(): input sizes do not match");
666 my_cijk_type c_cijk = a.cijk().is_empty() ? b.cijk() : a.cijk();
668#if !defined(__CUDA_ARCH__)
669 TEUCHOS_TEST_FOR_EXCEPTION(
670 c_cijk.is_empty() && csz != 1, std::logic_error,
671 "Sacado::UQ::PCE::operator*(): empty cijk but expansion size > 1");
674 PCE<Storage> c(c_cijk, csz);
675 const_pointer ac = a.coeff();
676 const_pointer bc = b.coeff();
677 pointer cc = c.coeff();
680 const value_type acz = ac[0];
681 for (ordinal_type i=0; i<csz; ++i)
685 const value_type bcz = bc[0];
686 for (ordinal_type i=0; i<csz; ++i)
690 for (ordinal_type i=0; i<csz; ++i) {
691 const cijk_size_type num_entry = c_cijk.num_entry(i);
692 const cijk_size_type entry_beg = c_cijk.entry_begin(i);
693 const cijk_size_type entry_end = entry_beg + num_entry;
695 for (cijk_size_type entry = entry_beg; entry < entry_end; ++entry) {
696 const cijk_size_type
j = c_cijk.coord(entry,0);
697 const cijk_size_type k = c_cijk.coord(entry,1);
698 ytmp += c_cijk.value(entry) * ( ac[
j] * bc[k] + ac[k] * bc[
j] );
707template <
typename Storage>
708KOKKOS_INLINE_FUNCTION
711 const PCE<Storage>& b)
717 const ordinal_type bsz = b.size();
718 PCE<Storage> c(b.cijk(), bsz);
719 const_pointer bc = b.coeff();
720 pointer cc = c.coeff();
721 for (ordinal_type i=0; i<bsz; ++i)
726template <
typename Storage>
727KOKKOS_INLINE_FUNCTION
736 const ordinal_type asz = a.size();
737 PCE<Storage> c(a.cijk(), asz);
738 const_pointer ac = a.coeff();
739 pointer cc = c.coeff();
740 for (ordinal_type i=0; i<asz; ++i)
745template <
typename Storage>
746KOKKOS_INLINE_FUNCTION
756 const ordinal_type asz = a.size();
757 const ordinal_type bsz = b.size();
758 const ordinal_type csz = asz > bsz ? asz : bsz;
760#if !defined(__CUDA_ARCH__)
761TEUCHOS_TEST_FOR_EXCEPTION(
762 asz != bsz && asz != 1 && bsz != 1, std::logic_error,
763 "Sacado::UQ::PCE::operator/(): input sizes do not match");
765 my_cijk_type c_cijk = asz == bsz || asz >1 ? a.cijk() : b.cijk();
767 PCE<Storage> c(c_cijk, csz);
769#if defined(__CUDA_ARCH__)
770 const_pointer ac = a.coeff();
771 pointer cc = c.coeff();
772 value_type bcz = b.fastAccessCoeff(0);
773 for (ordinal_type i=0; i<asz; ++i)
777#if !defined(__CUDA_ARCH__)
779 const_pointer ac = a.coeff();
780 const_pointer bc = b.coeff();
781 pointer cc = c.coeff();
782 const value_type bcz = bc[0];
783 for (ordinal_type i=0; i<csz; ++i)
794template <
typename Storage>
795KOKKOS_INLINE_FUNCTION
798 const PCE<Storage>& b)
801 PCE<Storage> a_pce(a);
805template <
typename Storage>
806KOKKOS_INLINE_FUNCTION
815 const ordinal_type asz = a.size();
816 PCE<Storage> c(a.cijk(), asz);
817 const_pointer ac = a.coeff();
818 pointer cc = c.coeff();
819 for (ordinal_type i=0; i<asz; ++i)
824template <
typename Storage>
825KOKKOS_INLINE_FUNCTION
829#if !defined(__CUDA_ARCH__)
830 TEUCHOS_TEST_FOR_EXCEPTION(
831 a.size() != 1, std::logic_error,
832 "Sacado::UQ::PCE::exp(): argument has size != 1");
835 PCE<Storage> c(a.cijk(), 1);
836 c.fastAccessCoeff(0) = std::exp( a.fastAccessCoeff(0) );
841template <
typename Storage>
842KOKKOS_INLINE_FUNCTION
846#if !defined(__CUDA_ARCH__)
847 TEUCHOS_TEST_FOR_EXCEPTION(
848 a.size() != 1, std::logic_error,
849 "Sacado::UQ::PCE::log(): argument has size != 1");
852 PCE<Storage> c(a.cijk(), 1);
853 c.fastAccessCoeff(0) = std::log( a.fastAccessCoeff(0) );
858template <
typename Storage>
859KOKKOS_INLINE_FUNCTION
863#if !defined(__CUDA_ARCH__)
864 TEUCHOS_TEST_FOR_EXCEPTION(
865 a.size() != 1, std::logic_error,
866 "Sacado::UQ::PCE::log10(): argument has size != 1");
869 PCE<Storage> c(a.cijk(), 1);
870 c.fastAccessCoeff(0) = std::log10( a.fastAccessCoeff(0) );
875template <
typename Storage>
876KOKKOS_INLINE_FUNCTION
880#if !defined(__CUDA_ARCH__)
881 TEUCHOS_TEST_FOR_EXCEPTION(
882 a.size() != 1, std::logic_error,
883 "Sacado::UQ::PCE::sqrt(): argument has size != 1");
886 PCE<Storage> c(a.cijk(), 1);
887 c.fastAccessCoeff(0) = std::sqrt( a.fastAccessCoeff(0) );
892template <
typename Storage>
893KOKKOS_INLINE_FUNCTION
897#if !defined(__CUDA_ARCH__)
898 TEUCHOS_TEST_FOR_EXCEPTION(
899 a.size() != 1, std::logic_error,
900 "Sacado::UQ::PCE::cbrt(): argument has size != 1");
903 PCE<Storage> c(a.cijk(), 1);
904 c.fastAccessCoeff(0) = std::cbrt( a.fastAccessCoeff(0) );
909template <
typename Storage>
910KOKKOS_INLINE_FUNCTION
912pow(
const PCE<Storage>& a,
const PCE<Storage>& b)
914#if !defined(__CUDA_ARCH__)
915 TEUCHOS_TEST_FOR_EXCEPTION(
916 a.size() != 1 || b.size() != 1, std::logic_error,
917 "Sacado::UQ::PCE::pow(): arguments have size != 1");
920 PCE<Storage> c(a.cijk(), 1);
921 c.fastAccessCoeff(0) = std::pow(a.fastAccessCoeff(0), b.fastAccessCoeff(0));
926template <
typename Storage>
927KOKKOS_INLINE_FUNCTION
930 const PCE<Storage>& b)
932#if !defined(__CUDA_ARCH__)
933 TEUCHOS_TEST_FOR_EXCEPTION(
934 b.size() != 1, std::logic_error,
935 "Sacado::UQ::PCE::pow(): arguments have size != 1");
938 PCE<Storage> c(b.cijk(), 1);
939 c.fastAccessCoeff(0) = std::pow(a, b.fastAccessCoeff(0));
944template <
typename Storage>
945KOKKOS_INLINE_FUNCTION
950#if !defined(__CUDA_ARCH__)
951 TEUCHOS_TEST_FOR_EXCEPTION(
952 a.size() != 1, std::logic_error,
953 "Sacado::UQ::PCE::pow(): arguments have size != 1");
956 PCE<Storage> c(a.cijk(), 1);
957 c.fastAccessCoeff(0) = std::pow(a.fastAccessCoeff(0), b);
962template <
typename Storage>
963KOKKOS_INLINE_FUNCTION
967#if !defined(__CUDA_ARCH__)
968 TEUCHOS_TEST_FOR_EXCEPTION(
969 a.size() != 1, std::logic_error,
970 "Sacado::UQ::PCE::sin(): argument has size != 1");
973 PCE<Storage> c(a.cijk(), 1);
974 c.fastAccessCoeff(0) = std::sin( a.fastAccessCoeff(0) );
979template <
typename Storage>
980KOKKOS_INLINE_FUNCTION
984#if !defined(__CUDA_ARCH__)
985 TEUCHOS_TEST_FOR_EXCEPTION(
986 a.size() != 1, std::logic_error,
987 "Sacado::UQ::PCE::cos(): argument has size != 1");
990 PCE<Storage> c(a.cijk(), 1);
991 c.fastAccessCoeff(0) = std::cos( a.fastAccessCoeff(0) );
996template <
typename Storage>
997KOKKOS_INLINE_FUNCTION
1001#if !defined(__CUDA_ARCH__)
1002 TEUCHOS_TEST_FOR_EXCEPTION(
1003 a.size() != 1, std::logic_error,
1004 "Sacado::UQ::PCE::tan(): argument has size != 1");
1007 PCE<Storage> c(a.cijk(), 1);
1008 c.fastAccessCoeff(0) = std::tan( a.fastAccessCoeff(0) );
1013template <
typename Storage>
1014KOKKOS_INLINE_FUNCTION
1018#if !defined(__CUDA_ARCH__)
1019 TEUCHOS_TEST_FOR_EXCEPTION(
1020 a.size() != 1, std::logic_error,
1021 "Sacado::UQ::PCE::sinh(): argument has size != 1");
1024 PCE<Storage> c(a.cijk(), 1);
1025 c.fastAccessCoeff(0) = std::sinh( a.fastAccessCoeff(0) );
1030template <
typename Storage>
1031KOKKOS_INLINE_FUNCTION
1035#if !defined(__CUDA_ARCH__)
1036 TEUCHOS_TEST_FOR_EXCEPTION(
1037 a.size() != 1, std::logic_error,
1038 "Sacado::UQ::PCE::cosh(): argument has size != 1");
1041 PCE<Storage> c(a.cijk(), 1);
1042 c.fastAccessCoeff(0) = std::cosh( a.fastAccessCoeff(0) );
1047template <
typename Storage>
1048KOKKOS_INLINE_FUNCTION
1052#if !defined(__CUDA_ARCH__)
1053 TEUCHOS_TEST_FOR_EXCEPTION(
1054 a.size() != 1, std::logic_error,
1055 "Sacado::UQ::PCE::tanh(): argument has size != 1");
1058 PCE<Storage> c(a.cijk(), 1);
1059 c.fastAccessCoeff(0) = std::tanh( a.fastAccessCoeff(0) );
1064template <
typename Storage>
1065KOKKOS_INLINE_FUNCTION
1069#if !defined(__CUDA_ARCH__)
1070 TEUCHOS_TEST_FOR_EXCEPTION(
1071 a.size() != 1, std::logic_error,
1072 "Sacado::UQ::PCE::acos(): argument has size != 1");
1075 PCE<Storage> c(a.cijk(), 1);
1076 c.fastAccessCoeff(0) = std::acos( a.fastAccessCoeff(0) );
1081template <
typename Storage>
1082KOKKOS_INLINE_FUNCTION
1086#if !defined(__CUDA_ARCH__)
1087 TEUCHOS_TEST_FOR_EXCEPTION(
1088 a.size() != 1, std::logic_error,
1089 "Sacado::UQ::PCE::asin(): argument has size != 1");
1092 PCE<Storage> c(a.cijk(), 1);
1093 c.fastAccessCoeff(0) = std::asin( a.fastAccessCoeff(0) );
1098template <
typename Storage>
1099KOKKOS_INLINE_FUNCTION
1103#if !defined(__CUDA_ARCH__)
1104 TEUCHOS_TEST_FOR_EXCEPTION(
1105 a.size() != 1, std::logic_error,
1106 "Sacado::UQ::PCE::atan(): argument has size != 1");
1109 PCE<Storage> c(a.cijk(), 1);
1110 c.fastAccessCoeff(0) = std::atan( a.fastAccessCoeff(0) );
1168template <
typename Storage>
1169KOKKOS_INLINE_FUNCTION
1173 PCE<Storage> c(a.cijk(), 1);
1174 c.fastAccessCoeff(0) = a.two_norm();
1178template <
typename Storage>
1179KOKKOS_INLINE_FUNCTION
1183 PCE<Storage> c(a.cijk(), 1);
1184 c.fastAccessCoeff(0) = a.two_norm();
1188template <
typename Storage>
1189KOKKOS_INLINE_FUNCTION
1193 PCE<Storage> c(a.cijk(), 1);
1194 c.fastAccessCoeff(0) = std::ceil( a.fastAccessCoeff(0) );
1208template <
typename Storage>
1209KOKKOS_INLINE_FUNCTION
1212 const PCE<Storage>& b)
1214 if (a >= b.two_norm()) {
1215 PCE<Storage> c(b.cijk(), 1);
1216 c.fastAccessCoeff(0) = a;
1222template <
typename Storage>
1227 if (a.two_norm() >= b)
1229 PCE<Storage> c(a.cijk(), 1);
1230 c.fastAccessCoeff(0) = b;
1244template <
typename Storage>
1245KOKKOS_INLINE_FUNCTION
1248 const PCE<Storage>& b)
1250 if (a <= b.two_norm()) {
1251 PCE<Storage> c(b.cijk(), 1);
1252 c.fastAccessCoeff(0) = a;
1258template <
typename Storage>
1259KOKKOS_INLINE_FUNCTION
1264 if (a.two_norm() <= b)
1266 PCE<Storage> c(a.cijk(), 1);
1267 c.fastAccessCoeff(0) = b;
1271template <
typename Storage>
1272KOKKOS_INLINE_FUNCTION
1277 const ordinal_type asz = a.size();
1278 const ordinal_type bsz = b.size();
1279 const ordinal_type n = asz > bsz ? asz : bsz;
1280 for (ordinal_type i=0; i<n; i++)
1281 if (a.coeff(i) != b.coeff(i))
1286template <
typename Storage>
1287KOKKOS_INLINE_FUNCTION
1290 const PCE<Storage>& b)
1293 const ordinal_type n = b.size();
1294 if (a != b.coeff(0))
1296 for (ordinal_type i=1; i<n; i++)
1302template <
typename Storage>
1303KOKKOS_INLINE_FUNCTION
1309 const ordinal_type n = a.size();
1310 if (a.coeff(0) != b)
1312 for (ordinal_type i=1; i<n; i++)
1318template <
typename Storage>
1319KOKKOS_INLINE_FUNCTION
1326template <
typename Storage>
1327KOKKOS_INLINE_FUNCTION
1330 const PCE<Storage>& b)
1335template <
typename Storage>
1336KOKKOS_INLINE_FUNCTION
1344template <
typename Storage>
1345KOKKOS_INLINE_FUNCTION
1347operator<=(
const PCE<Storage>& a,
const PCE<Storage>& b)
1349 return a.two_norm() <= b.two_norm();
1352template <
typename Storage>
1353KOKKOS_INLINE_FUNCTION
1356 const PCE<Storage>& b)
1358 return a <= b.two_norm();
1361template <
typename Storage>
1362KOKKOS_INLINE_FUNCTION
1367 return a.two_norm() <= b;
1370template <
typename Storage>
1371KOKKOS_INLINE_FUNCTION
1375 return a.two_norm() >= b.two_norm();
1378template <
typename Storage>
1379KOKKOS_INLINE_FUNCTION
1382 const PCE<Storage>& b)
1384 return a >= b.two_norm();
1387template <
typename Storage>
1388KOKKOS_INLINE_FUNCTION
1393 return a.two_norm() >= b;
1396template <
typename Storage>
1397KOKKOS_INLINE_FUNCTION
1399operator<(
const PCE<Storage>& a,
const PCE<Storage>& b)
1401 return a.two_norm() < b.two_norm();
1404template <
typename Storage>
1405KOKKOS_INLINE_FUNCTION
1408 const PCE<Storage>& b)
1410 return a < b.two_norm();
1413template <
typename Storage>
1414KOKKOS_INLINE_FUNCTION
1419 return a.two_norm() < b;
1422template <
typename Storage>
1423KOKKOS_INLINE_FUNCTION
1427 return a.two_norm() > b.two_norm();
1430template <
typename Storage>
1431KOKKOS_INLINE_FUNCTION
1434 const PCE<Storage>& b)
1436 return a > b.two_norm();
1439template <
typename Storage>
1440KOKKOS_INLINE_FUNCTION
1445 return a.two_norm() > b;
1448template <
typename Storage>
1449KOKKOS_INLINE_FUNCTION
1452 bool is_zero =
true;
1453 const ordinal_type sz = x.size();
1454 for (ordinal_type i=0; i<sz; i++)
1455 is_zero = is_zero && (x.fastAccessCoeff(i) == 0.0);
1459template <
typename Storage>
1460KOKKOS_INLINE_FUNCTION
1467template <
typename Storage>
1468KOKKOS_INLINE_FUNCTION
1471 const PCE<Storage>& x2)
1476template <
typename Storage>
1477KOKKOS_INLINE_FUNCTION
1485template <
typename Storage>
1486KOKKOS_INLINE_FUNCTION
1493template <
typename Storage>
1494KOKKOS_INLINE_FUNCTION
1497 const PCE<Storage>& x2)
1502template <
typename Storage>
1503KOKKOS_INLINE_FUNCTION
1511template <
typename Storage>
1513operator << (std::ostream& os,
const PCE<Storage>& a)
1519 for (ordinal_type i=0; i<a.size(); i++) {
1520 os << a.coeff(i) <<
" ";
1527template <
typename Storage>
1537 for (ordinal_type i=0; i<a.size(); i++) {
1538 is >> a.fastAccessCoeff(i);
1547template <
typename Storage>
1549CG_divide(
const PCE<Storage>& a,
const PCE<Storage>& b, PCE<Storage>& c) {
1553 const ordinal_type size = c.size();
1556 value_type alpha, beta, rTz, rTz_old, resid;
1559 PCE<Storage> r(a.cijk(),size);
1560 PCE<Storage> p(a.cijk(),size);
1561 PCE<Storage> bp(a.cijk(),size);
1562 PCE<Storage> z(a.cijk(),size);
1568 resid = r.two_norm();
1570 rTz = r.inner_product(z);
1572 value_type tol = 1e-6;
1573 while ( resid > tol && k < 100){
1576 alpha = rTz/p.inner_product(bp);
1582 resid = r.two_norm();
1585 rTz = r.inner_product(z);
OrthogPoly< T, Storage > operator-(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
KOKKOS_INLINE_FUNCTION bool operator||(const PCE< Storage > &x1, const PCE< Storage > &x2)
KOKKOS_INLINE_FUNCTION bool toBool(const PCE< Storage > &x)
KOKKOS_INLINE_FUNCTION PCE< Storage > operator+(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION bool operator==(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION bool operator<(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
std::ostream & operator<<(std::ostream &os, const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION bool operator>(const PCE< Storage > &a, const PCE< Storage > &b)
void CG_divide(const PCE< Storage > &a, const PCE< Storage > &b, PCE< Storage > &c)
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > operator*(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > operator/(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
std::istream & operator>>(std::istream &is, PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION bool operator!=(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(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 bool operator>=(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION bool operator<=(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION PCE< Storage > ceil(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION bool operator&&(const PCE< Storage > &x1, const PCE< Storage > &x2)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > operator-(const PCE< Storage > &a, const PCE< Storage > &b)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y