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 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
43 #define THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
44 
45 #include "Thyra_MultiVectorBase.hpp"
46 #include "RTOpPack_ROpNorm1.hpp"
47 #include "RTOpPack_ROpNorm2.hpp"
48 #include "RTOpPack_ROpNormInf.hpp"
49 
50 namespace Thyra {
51 
52 
63 template<class Scalar>
64 void norms( const MultiVectorBase<Scalar>& V,
65  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
66 
67 
81 template<class Scalar, class NormOp>
82 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
83  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
84 
85 
96 template<class Scalar>
97 void norms_1( const MultiVectorBase<Scalar>& V,
98  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
99 
100 
111 template<class Scalar>
112 void norms_2( const MultiVectorBase<Scalar>& V,
113  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
114 
115 
126 template<class Scalar>
127 void norms_inf( const MultiVectorBase<Scalar>& V,
128  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
129 
130 
135 template<class Scalar>
136 Array<typename ScalarTraits<Scalar>::magnitudeType>
137 norms_inf( const MultiVectorBase<Scalar>& V );
138 
139 
152 template<class Scalar>
153 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
154  const ArrayView<Scalar> &dots );
155 
156 
167 template<class Scalar>
168 void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
169 
170 
175 template<class Scalar>
177 norm_1( const MultiVectorBase<Scalar>& V );
178 
179 
187 template<class Scalar>
188 void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
189 
190 
195 template<class Scalar>
196 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
197  const Ptr<MultiVectorBase<Scalar> > &V );
198 
203 template<class Scalar>
204 void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
205 
210 template<class Scalar>
211 void assign( const Ptr<MultiVectorBase<Scalar> > &V,
212  const MultiVectorBase<Scalar>& U );
213 
214 
219 template<class Scalar>
220 void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
221  const Ptr<MultiVectorBase<Scalar> > &V );
222 
223 
229 template<class Scalar>
230 void update(
231  const ArrayView<const Scalar> &alpha,
232  Scalar beta,
233  const MultiVectorBase<Scalar>& U,
234  const Ptr<MultiVectorBase<Scalar> > &V
235  );
236 
237 
243 template<class Scalar>
244 void update(
245  const MultiVectorBase<Scalar>& U,
246  const ArrayView<const Scalar> &alpha,
247  Scalar beta,
248  const Ptr<MultiVectorBase<Scalar> > &V
249  );
250 
251 
278 template<class Scalar>
279 void linear_combination(
280  const ArrayView<const Scalar> &alpha,
281  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
282  const Scalar &beta,
283  const Ptr<MultiVectorBase<Scalar> > &Y
284  );
285 
286 
297 template<class Scalar>
298 void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
299 
300 
306 template<class Scalar>
307 void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
308 
309 
315 template<class Scalar>
316 void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
317 
318 
324 template<class Scalar>
325 void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
326  const MultiVectorBase<Scalar>& X );
327 
328 
334 template<class Scalar>
335 void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
336  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
337 
338 
344 template<class Scalar>
345 void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
346  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
347 
348 
354 template<class Scalar>
355 void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
356  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
357 
358 
359 } // end namespace Thyra
360 
361 
362 // /////////////////////////////////////
363 // Inline functions
364 
365 
366 template<class Scalar>
367 inline
368 void Thyra::norms_1( const MultiVectorBase<Scalar>& V,
369  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
370 {
371  V.norms_1(norms);
372 }
373 
374 
375 template<class Scalar>
376 inline
377 void Thyra::norms_2( const MultiVectorBase<Scalar>& V,
378  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
379 {
380  V.norms_2(norms);
381 }
382 
383 
384 template<class Scalar>
385 inline
386 void Thyra::norms_inf( const MultiVectorBase<Scalar>& V,
387  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
388 {
389  V.norms_inf(norms);
390 }
391 
392 
393 template<class Scalar>
395 Thyra::norms_inf( const MultiVectorBase<Scalar>& V )
396 {
397  typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
398  Array<ScalarMag> norms(V.domain()->dim());
399  Thyra::norms_inf<Scalar>(V, norms());
400  return norms;
401 }
402 
403 
404 // /////////////////////////////////////////////
405 // Other implementations
406 
407 
408 template<class Scalar, class NormOp>
409 void Thyra::reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
410  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
411 {
412  using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
413  const int m = V.domain()->dim();
414  Array<RCP<RTOpPack::ReductTarget> > rcp_op_targs(m);
415  Array<Ptr<RTOpPack::ReductTarget> > op_targs(m);
416  for( int kc = 0; kc < m; ++kc ) {
417  rcp_op_targs[kc] = op.reduct_obj_create();
418  op_targs[kc] = rcp_op_targs[kc].ptr();
419  }
420  applyOp<Scalar>(op, tuple(ptrInArg(V)),
421  ArrayView<Ptr<MultiVectorBase<Scalar> > >(null),
422  op_targs );
423  for( int kc = 0; kc < m; ++kc ) {
424  norms[kc] = op(*op_targs[kc]);
425  }
426 }
427 
428 
429 #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.