00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "Sacado_PCE_StandardPoly.hpp"
00033
00034 template <typename BasisT>
00035 Sacado::PCE::TripleProduct<BasisT>::
00036 TripleProduct(unsigned int degree) :
00037 l(degree+1),
00038 basis(2*degree),
00039 Cijk(l*l*l)
00040 {
00041 compute();
00042 }
00043
00044 template <typename BasisT>
00045 Sacado::PCE::TripleProduct<BasisT>::
00046 TripleProduct(const Sacado::PCE::TripleProduct<BasisT>& tp) :
00047 l(tp.l),
00048 basis(tp.basis),
00049 Cijk(tp.Cijk)
00050 {
00051 }
00052
00053 template <typename BasisT>
00054 Sacado::PCE::TripleProduct<BasisT>::
00055 ~TripleProduct()
00056 {
00057 }
00058
00059 template <typename BasisT>
00060 Sacado::PCE::TripleProduct<BasisT>&
00061 Sacado::PCE::TripleProduct<BasisT>::
00062 operator=(const Sacado::PCE::TripleProduct<BasisT>& tp)
00063 {
00064 if (this != &tp) {
00065 l = tp.l;
00066 basis = tp.basis;
00067 Cijk = tp.Cijk;
00068 }
00069 return *this;
00070 }
00071
00072 template <typename BasisT>
00073 const typename Sacado::PCE::TripleProduct<BasisT>::value_type&
00074 Sacado::PCE::TripleProduct<BasisT>::
00075 value(unsigned int i, unsigned int j, unsigned int k) const
00076 {
00077 return Cijk[ l*(l*k + j) + i ];
00078 }
00079
00080 template <typename BasisT>
00081 const typename Sacado::PCE::TripleProduct<BasisT>::value_type&
00082 Sacado::PCE::TripleProduct<BasisT>::
00083 norm_squared(unsigned int i) const
00084 {
00085 return basis.norm_squared()[i];
00086 }
00087
00088 template <typename BasisT>
00089 void
00090 Sacado::PCE::TripleProduct<BasisT>::
00091 resize(unsigned int degree)
00092 {
00093 if (degree+1 != l) {
00094 l = degree+1;
00095 basis = BasisT(2*degree);
00096 Cijk.resize(l*l*l);
00097 compute();
00098 }
00099 }
00100
00101
00102
00103
00104 template <typename BasisT>
00105 void
00106 Sacado::PCE::TripleProduct<BasisT>::
00107 compute()
00108 {
00109 const std::vector<value_type>& nrm_sq = basis.norm_squared();
00110 StandardPoly<value_type> pij(2*(l-1));
00111 std::vector<value_type> a(2*l);
00112 for (unsigned int i=0; i<l; i++) {
00113 const StandardPoly<value_type>& pi = basis.getBasisPoly(i);
00114 for (unsigned int j=0; j<l; j++) {
00115 const StandardPoly<value_type>& pj = basis.getBasisPoly(j);
00116 pij.multiply(1.0, pi, pj, 0.0);
00117 basis.project(pij, a);
00118 for (unsigned int k=0; k<l; k++)
00119 Cijk[ l*(l*k+j) + i ] = a[k]*nrm_sq[k];
00120 }
00121 }
00122 }