Thyra Version of the Day
Loading...
Searching...
No Matches
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
50namespace Thyra {
51
52
63template<class Scalar>
64void norms( const MultiVectorBase<Scalar>& V,
66
67
81template<class Scalar, class NormOp>
82void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
84
85
96template<class Scalar>
97void norms_1( const MultiVectorBase<Scalar>& V,
99
100
111template<class Scalar>
112void norms_2( const MultiVectorBase<Scalar>& V,
114
115
126template<class Scalar>
129
130
135template<class Scalar>
138
139
152template<class Scalar>
153void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
154 const ArrayView<Scalar> &dots );
155
156
167template<class Scalar>
168void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
169
170
175template<class Scalar>
178
179
187template<class Scalar>
188void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
189
190
195template<class Scalar>
197 const Ptr<MultiVectorBase<Scalar> > &V );
198
203template<class Scalar>
204void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
205
210template<class Scalar>
211void assign( const Ptr<MultiVectorBase<Scalar> > &V,
212 const MultiVectorBase<Scalar>& U );
213
214
219template<class Scalar>
220void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
221 const Ptr<MultiVectorBase<Scalar> > &V );
222
223
229template<class Scalar>
230void update(
231 const ArrayView<const Scalar> &alpha,
232 Scalar beta,
235 );
236
237
243template<class Scalar>
244void update(
246 const ArrayView<const Scalar> &alpha,
247 Scalar beta,
249 );
250
251
278template<class Scalar>
280 const ArrayView<const Scalar> &alpha,
281 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
282 const Scalar &beta,
284 );
285
286
297template<class Scalar>
298void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
299
300
306template<class Scalar>
307void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
308
309
315template<class Scalar>
316void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
317
318
324template<class Scalar>
325void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
326 const MultiVectorBase<Scalar>& X );
327
328
334template<class Scalar>
335void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
337
338
344template<class Scalar>
345void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
347
348
354template<class Scalar>
355void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
357
358
359} // end namespace Thyra
360
361
362// /////////////////////////////////////
363// Inline functions
364
365
366template<class Scalar>
367inline
373
374
375template<class Scalar>
376inline
382
383
384template<class Scalar>
385inline
391
392
393template<class Scalar>
396{
397 typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
398 Array<ScalarMag> norms(V.domain()->dim());
400 return norms;
401}
402
403
404// /////////////////////////////////////////////
405// Other implementations
406
407
408template<class Scalar, class NormOp>
409void Thyra::reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
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);
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)),
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
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Interface for a collection of column vectors called a multi-vector.
void norms_inf(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise infinity-norms.
void sums(const MultiVectorBase< Scalar > &V, const ArrayView< Scalar > &sums)
Multi-vector column sum.
void applyOp(const RTOpPack::RTOpT< Scalar > &primary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const ArrayView< const Ptr< RTOpPack::ReductTarget > > &reduct_objs, const Ordinal primary_global_offset) const
Calls mvMultiReductApplyOpImpl().
void randomize(Scalar l, Scalar u, const Ptr< MultiVectorBase< Scalar > > &V)
Generate a random multi-vector with elements uniformly distributed elements.
void V_VpV(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = X(i,j) + Y(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
void reductions(const MultiVectorBase< Scalar > &V, const NormOp &op, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector reductions.
void dots(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
Column-wise Euclidean dot product.
void norms_inf(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector infinity norm.
Array< typename ScalarTraits< Scalar >::magnitudeType > norms_inf(const MultiVectorBase< Scalar > &V)
Column-wise multi-vector infinity norm.
void Vt_S(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha)
Z(i,j) *= alpha, i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void norms_2(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector 2 (Euclidean) norm.
void norms_2(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise 2-norms.
ScalarTraits< Scalar >::magnitudeType norm_1(const MultiVectorBase< Scalar > &V)
Take the induced matrix one norm of a multi-vector.
void V_VmV(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = X(i,j) - Y(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void linear_combination(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
Y.col(j)(i) = beta*Y.col(j)(i) + sum( alpha[k]*X[k].col(j)(i),
void scaleUpdate(const VectorBase< Scalar > &a, const MultiVectorBase< Scalar > &U, const Ptr< MultiVectorBase< Scalar > > &V)
A*U + V -> V (where A is a diagonal matrix with diagonal a).
void update(Scalar alpha, const MultiVectorBase< Scalar > &mv)
void norms_1(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise 1-norms.
void V_StVpV(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha, const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y)
Z(i,j) = alpha*X(i,j) + Y(i), i = 0...z->space()->dim()-1, , j = 0...Z->domain()->dim()-1.
void Vp_V(const Ptr< MultiVectorBase< Scalar > > &Z, const MultiVectorBase< Scalar > &X)
Z(i,j) += X(i,j), i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void Vp_S(const Ptr< MultiVectorBase< Scalar > > &Z, const Scalar &alpha)
Z(i,j) += alpha, i = 0...Z->range()->dim()-1, j = 0...Z->domain()->dim()-1.
void assign(Scalar alpha)
V = alpha.
void norms_1(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector one norm.
Abstract interface for finite-dimensional dense vectors.