Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MultiVectorStdOps_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
11 #define THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
12 
13 #include "Thyra_MultiVectorBase.hpp"
14 #include "RTOpPack_ROpNorm1.hpp"
15 #include "RTOpPack_ROpNorm2.hpp"
16 #include "RTOpPack_ROpNormInf.hpp"
17 
18 namespace Thyra {
19 
20 
31 template<class Scalar>
32 void norms( const MultiVectorBase<Scalar>& V,
33  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
34 
35 
49 template<class Scalar, class NormOp>
50 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
51  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
52 
53 
64 template<class Scalar>
65 void norms_1( const MultiVectorBase<Scalar>& V,
66  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
67 
68 
79 template<class Scalar>
80 void norms_2( const MultiVectorBase<Scalar>& V,
81  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
82 
83 
94 template<class Scalar>
95 void norms_inf( const MultiVectorBase<Scalar>& V,
96  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
97 
98 
103 template<class Scalar>
104 Array<typename ScalarTraits<Scalar>::magnitudeType>
105 norms_inf( const MultiVectorBase<Scalar>& V );
106 
107 
120 template<class Scalar>
121 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
122  const ArrayView<Scalar> &dots );
123 
124 
135 template<class Scalar>
136 void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
137 
138 
143 template<class Scalar>
145 norm_1( const MultiVectorBase<Scalar>& V );
146 
147 
155 template<class Scalar>
156 void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
157 
158 
163 template<class Scalar>
164 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
165  const Ptr<MultiVectorBase<Scalar> > &V );
166 
171 template<class Scalar>
172 void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
173 
178 template<class Scalar>
179 void assign( const Ptr<MultiVectorBase<Scalar> > &V,
180  const MultiVectorBase<Scalar>& U );
181 
182 
187 template<class Scalar>
188 void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
189  const Ptr<MultiVectorBase<Scalar> > &V );
190 
191 
197 template<class Scalar>
198 void update(
199  const ArrayView<const Scalar> &alpha,
200  Scalar beta,
201  const MultiVectorBase<Scalar>& U,
202  const Ptr<MultiVectorBase<Scalar> > &V
203  );
204 
205 
211 template<class Scalar>
212 void update(
213  const MultiVectorBase<Scalar>& U,
214  const ArrayView<const Scalar> &alpha,
215  Scalar beta,
216  const Ptr<MultiVectorBase<Scalar> > &V
217  );
218 
219 
246 template<class Scalar>
247 void linear_combination(
248  const ArrayView<const Scalar> &alpha,
249  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
250  const Scalar &beta,
251  const Ptr<MultiVectorBase<Scalar> > &Y
252  );
253 
254 
265 template<class Scalar>
266 void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
267 
268 
274 template<class Scalar>
275 void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
276 
277 
283 template<class Scalar>
284 void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
285 
286 
292 template<class Scalar>
293 void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
294  const MultiVectorBase<Scalar>& X );
295 
296 
302 template<class Scalar>
303 void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
304  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
305 
306 
312 template<class Scalar>
313 void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
314  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
315 
316 
322 template<class Scalar>
323 void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
324  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
325 
326 
327 } // end namespace Thyra
328 
329 
330 // /////////////////////////////////////
331 // Inline functions
332 
333 
334 template<class Scalar>
335 inline
336 void Thyra::norms_1( const MultiVectorBase<Scalar>& V,
337  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
338 {
339  V.norms_1(norms);
340 }
341 
342 
343 template<class Scalar>
344 inline
345 void Thyra::norms_2( const MultiVectorBase<Scalar>& V,
346  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
347 {
348  V.norms_2(norms);
349 }
350 
351 
352 template<class Scalar>
353 inline
354 void Thyra::norms_inf( const MultiVectorBase<Scalar>& V,
355  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
356 {
357  V.norms_inf(norms);
358 }
359 
360 
361 template<class Scalar>
363 Thyra::norms_inf( const MultiVectorBase<Scalar>& V )
364 {
365  typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
366  Array<ScalarMag> norms(V.domain()->dim());
367  Thyra::norms_inf<Scalar>(V, norms());
368  return norms;
369 }
370 
371 
372 // /////////////////////////////////////////////
373 // Other implementations
374 
375 
376 template<class Scalar, class NormOp>
377 void Thyra::reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
378  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
379 {
380  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
381  const int m = V.domain()->dim();
382  Array<RCP<RTOpPack::ReductTarget> > rcp_op_targs(m);
383  Array<Ptr<RTOpPack::ReductTarget> > op_targs(m);
384  for( int kc = 0; kc < m; ++kc ) {
385  rcp_op_targs[kc] = op.reduct_obj_create();
386  op_targs[kc] = rcp_op_targs[kc].ptr();
387  }
388  applyOp<Scalar>(op, tuple(ptrInArg(V)),
389  ArrayView<Ptr<MultiVectorBase<Scalar> > >(null),
390  op_targs );
391  for( int kc = 0; kc < m; ++kc ) {
392  norms[kc] = op(*op_targs[kc]);
393  }
394 }
395 
396 
397 #endif // THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.