10 #include "Sacado_DynamicArrayTraits.hpp"
17 template <
int NN,
typename ExprT>
19 static const int N = NN;
23 template <
typename tuple_type>
25 return expr_.template eval_sample<0>(x);
29 template <
typename T,
typename Storage>
32 OrthogPolyImpl<T,Storage>::
33 expressionCopy(
const Expr<S>& x)
35 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
44 approx_type* tc = th_.get();
49 const int N = Expr<S>::num_args;
50 for (
int i=0; i<N; i++) {
51 const approx_type* opa = &(x.getArg(i));
61 tc =
new approx_type(expansion_->getBasis(), sz);
64 if (x.has_fast_access(sz)) {
65 for (
int i=1; i<sz; i++)
66 (*tc)[i] = x.fast_higher_order_coeff(i);
69 for (
int i=1; i<sz; i++)
70 (*tc)[i] = x.higher_order_coeff(i);
75 th_ = Sacado::Handle<approx_type>(tc);
79 const int N = Expr<S>::num_args;
80 const approx_type* opas[N];
81 for (
int i=0; i<N; i++)
82 opas[i] = &(x.getArg(i));
83 ExprQuadFuncWrapper< N, Expr<S> > func(x);
84 quad_expansion_->nary_op(func, *th_, opas);
88 template <
typename T,
typename Storage>
89 OrthogPolyImpl<T,Storage>::
96 expansion_ = const_expansion_;
99 template <
typename T,
typename Storage>
100 OrthogPolyImpl<T,Storage>::
107 expansion_ = const_expansion_;
110 template <
typename T,
typename Storage>
111 OrthogPolyImpl<T,Storage>::
113 expansion_(expansion),
114 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
115 th_(new Stokhos::OrthogPolyApprox<int,
value_type,
Storage>(expansion_->getBasis()))
120 template <
typename T,
typename Storage>
121 OrthogPolyImpl<T,Storage>::
124 expansion_(expansion),
125 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
126 th_(new Stokhos::OrthogPolyApprox<int,
value_type,
Storage>(expansion_->getBasis(), sz))
131 template <
typename T,
typename Storage>
132 OrthogPolyImpl<T,Storage>::
133 OrthogPolyImpl(
const OrthogPolyImpl<T,Storage>& x) :
134 expansion_(x.expansion_),
135 quad_expansion_(x.quad_expansion_),
141 template <
typename T,
typename Storage>
142 template <
typename S>
143 OrthogPolyImpl<T,Storage>::
144 OrthogPolyImpl(
const Expr<S>& x) :
145 expansion_(x.expansion()),
146 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
147 th_(new Stokhos::OrthogPolyApprox<int,
value_type,
Storage>(expansion_->getBasis(), x.size()))
153 template <
typename T,
typename Storage>
155 OrthogPolyImpl<T,Storage>::
158 expansion_ = expansion;
159 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
160 th_->
reset(expansion_->getBasis());
163 template <
typename T,
typename Storage>
165 OrthogPolyImpl<T,Storage>::
168 expansion_ = expansion;
169 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
170 th_->
reset(expansion_->getBasis(), sz);
173 template <
typename T,
typename Storage>
175 OrthogPolyImpl<T,Storage>::
178 return th_->evaluate(point);
181 template <
typename T,
typename Storage>
183 OrthogPolyImpl<T,Storage>::
188 return th_->evaluate(point, bvals);
191 template <
typename T,
typename Storage>
192 template <
typename S>
194 OrthogPolyImpl<T,Storage>::
195 isEqualTo(
const Expr<S>& x)
const {
196 typedef IsEqual<value_type> IE;
197 if (x.size() != this->size())
return false;
200 if (expansion_ != x.expansion_) {
203 if ((expansion_ != const_expansion_) &&
204 (x.expansion_ != x.const_expansion_))
208 for (
int i=0; i<this->size(); i++)
209 eq = eq && IE::eval(x.coeff(i), this->coeff(i));
213 template <
typename T,
typename Storage>
214 OrthogPolyImpl<T,Storage>&
215 OrthogPolyImpl<T,Storage>::
223 template <
typename T,
typename Storage>
224 OrthogPolyImpl<T,Storage>&
225 OrthogPolyImpl<T,Storage>::
226 operator=(
const OrthogPolyImpl<T,Storage>& x)
228 expansion_ = x.expansion_;
229 quad_expansion_ = x.quad_expansion_;
234 template <
typename T,
typename Storage>
235 template <
typename S>
236 OrthogPolyImpl<T,Storage>&
237 OrthogPolyImpl<T,Storage>::
238 operator=(
const Expr<S>& x)
241 expansion_ = x.expansion();
242 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
243 th_->reset(expansion_->getBasis(), x.size());
248 template <
typename T,
typename Storage>
249 OrthogPolyImpl<T,Storage>&
250 OrthogPolyImpl<T,Storage>::
254 expansion_->plusEqual(*th_, v);
258 template <
typename T,
typename Storage>
259 OrthogPolyImpl<T,Storage>&
260 OrthogPolyImpl<T,Storage>::
264 expansion_->minusEqual(*th_, v);
268 template <
typename T,
typename Storage>
269 OrthogPolyImpl<T,Storage>&
270 OrthogPolyImpl<T,Storage>::
274 expansion_->timesEqual(*th_, v);
278 template <
typename T,
typename Storage>
279 OrthogPolyImpl<T,Storage>&
280 OrthogPolyImpl<T,Storage>::
284 expansion_->divideEqual(*th_, v);
288 template <
typename T,
typename Storage>
290 operator << (std::ostream& os, const OrthogPoly<T,Storage>& a)
296 for (ordinal_type i=0; i<a.size(); i++) {
297 os << a.coeff(i) <<
" ";
304 template <
typename T,
typename Storage>
314 for (ordinal_type i=0; i<a.size(); i++) {
315 is >> a.fastAccessCoeff(i);
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
ExprQuadFuncWrapper(const ExprT &expr)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
KERNEL_PREFIX value_type operator()(tuple_type x) const
ExprT::value_type value_type
Orthogonal polynomial expansion class for constant (size 1) expansions.
std::istream & operator>>(std::istream &is, OrthogPoly< T, Storage > &a)