42 #include "Sacado_DynamicArrayTraits.hpp"
49 template <
int NN,
typename ExprT>
51 static const int N = NN;
55 template <
typename tuple_type>
57 return expr_.template eval_sample<0>(x);
61 template <
typename T,
typename Storage>
64 OrthogPolyImpl<T,Storage>::
65 expressionCopy(
const Expr<S>& x)
67 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
76 approx_type* tc = th_.get();
81 const int N = Expr<S>::num_args;
82 for (
int i=0; i<N; i++) {
83 const approx_type* opa = &(x.getArg(i));
93 tc =
new approx_type(expansion_->getBasis(), sz);
96 if (x.has_fast_access(sz)) {
97 for (
int i=1; i<sz; i++)
98 (*tc)[i] = x.fast_higher_order_coeff(i);
101 for (
int i=1; i<sz; i++)
102 (*tc)[i] = x.higher_order_coeff(i);
107 th_ = Sacado::Handle<approx_type>(tc);
111 const int N = Expr<S>::num_args;
112 const approx_type* opas[N];
113 for (
int i=0; i<N; i++)
114 opas[i] = &(x.getArg(i));
115 ExprQuadFuncWrapper< N, Expr<S> > func(x);
116 quad_expansion_->nary_op(func, *th_, opas);
120 template <
typename T,
typename Storage>
121 OrthogPolyImpl<T,Storage>::
123 expansion_(const_expansion_),
129 template <
typename T,
typename Storage>
130 OrthogPolyImpl<T,Storage>::
132 expansion_(const_expansion_),
138 template <
typename T,
typename Storage>
139 OrthogPolyImpl<T,Storage>::
141 expansion_(expansion),
142 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
147 template <
typename T,
typename Storage>
148 OrthogPolyImpl<T,Storage>::
151 expansion_(expansion),
152 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
157 template <
typename T,
typename Storage>
158 OrthogPolyImpl<T,Storage>::
159 OrthogPolyImpl(
const OrthogPolyImpl<T,Storage>& x) :
160 expansion_(x.expansion_),
161 quad_expansion_(x.quad_expansion_),
166 template <
typename T,
typename Storage>
167 template <
typename S>
168 OrthogPolyImpl<T,Storage>::
169 OrthogPolyImpl(
const Expr<S>& x) :
170 expansion_(x.expansion()),
171 quad_expansion_(Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_)),
177 template <
typename T,
typename Storage>
179 OrthogPolyImpl<T,Storage>::
182 expansion_ = expansion;
183 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
184 th_->
reset(expansion_->getBasis());
187 template <
typename T,
typename Storage>
189 OrthogPolyImpl<T,Storage>::
192 expansion_ = expansion;
193 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
194 th_->
reset(expansion_->getBasis(), sz);
197 template <
typename T,
typename Storage>
199 OrthogPolyImpl<T,Storage>::
202 return th_->evaluate(point);
205 template <
typename T,
typename Storage>
207 OrthogPolyImpl<T,Storage>::
212 return th_->evaluate(point, bvals);
215 template <
typename T,
typename Storage>
216 template <
typename S>
218 OrthogPolyImpl<T,Storage>::
219 isEqualTo(
const Expr<S>& x)
const {
220 typedef IsEqual<value_type> IE;
221 if (x.size() != this->size())
return false;
224 if (expansion_ != x.expansion_) {
227 if ((expansion_ != const_expansion_) &&
228 (x.expansion_ != const_expansion_))
232 for (
int i=0; i<this->size(); i++)
233 eq = eq && IE::eval(x.coeff(i), this->coeff(i));
237 template <
typename T,
typename Storage>
238 OrthogPolyImpl<T,Storage>&
239 OrthogPolyImpl<T,Storage>::
247 template <
typename T,
typename Storage>
248 OrthogPolyImpl<T,Storage>&
249 OrthogPolyImpl<T,Storage>::
250 operator=(
const OrthogPolyImpl<T,Storage>& x)
252 expansion_ = x.expansion_;
253 quad_expansion_ = x.quad_expansion_;
258 template <
typename T,
typename Storage>
259 template <
typename S>
260 OrthogPolyImpl<T,Storage>&
261 OrthogPolyImpl<T,Storage>::
262 operator=(
const Expr<S>& x)
265 expansion_ = x.expansion();
266 quad_expansion_ = Teuchos::rcp_dynamic_cast<quad_expansion_type>(expansion_);
267 th_->reset(expansion_->getBasis(), x.size());
272 template <
typename T,
typename Storage>
273 OrthogPolyImpl<T,Storage>&
274 OrthogPolyImpl<T,Storage>::
278 expansion_->plusEqual(*th_, v);
282 template <
typename T,
typename Storage>
283 OrthogPolyImpl<T,Storage>&
284 OrthogPolyImpl<T,Storage>::
288 expansion_->minusEqual(*th_, v);
292 template <
typename T,
typename Storage>
293 OrthogPolyImpl<T,Storage>&
294 OrthogPolyImpl<T,Storage>::
298 expansion_->timesEqual(*th_, v);
302 template <
typename T,
typename Storage>
303 OrthogPolyImpl<T,Storage>&
304 OrthogPolyImpl<T,Storage>::
308 expansion_->divideEqual(*th_, v);
312 template <
typename T,
typename Storage>
314 operator << (std::ostream& os, const OrthogPoly<T,Storage>& a)
320 for (ordinal_type i=0; i<a.size(); i++) {
321 os << a.coeff(i) <<
" ";
328 template <
typename T,
typename Storage>
338 for (ordinal_type i=0; i<a.size(); i++) {
339 is >> a.fastAccessCoeff(i);
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
ExprQuadFuncWrapper(const ExprT &expr)
KERNEL_PREFIX value_type operator()(tuple_type x) const
ExprT::value_type value_type
std::istream & operator>>(std::istream &is, OrthogPoly< T, Storage > &a)