42#ifndef THYRA_MULTI_VECTOR_STD_OPS_HPP
43#define THYRA_MULTI_VECTOR_STD_OPS_HPP
45#include "Thyra_MultiVectorStdOps_decl.hpp"
46#include "Thyra_VectorStdOps.hpp"
47#include "Thyra_VectorSpaceBase.hpp"
48#include "Thyra_VectorStdOps.hpp"
49#include "Thyra_MultiVectorBase.hpp"
50#include "Thyra_VectorBase.hpp"
51#include "RTOpPack_ROpSum.hpp"
52#include "RTOpPack_ROpNorm1.hpp"
53#include "RTOpPack_ROpNormInf.hpp"
54#include "Teuchos_Assert.hpp"
55#include "Teuchos_Assert.hpp"
64 const int m = V.
domain()->dim();
66 V.
range()->scalarProds(V, V, prods());
67 for (
int j = 0; j < m; ++j )
68 norms[j] = ST::magnitude(ST::squareroot(prods[j]));
83 using Teuchos::tuple;
using Teuchos::ptrInArg;
using Teuchos::null;
84 const int m = V.
domain()->dim();
85 RTOpPack::ROpSum<Scalar> sum_op;
88 for(
int kc = 0; kc < m; ++kc ) {
89 rcp_op_targs[kc] = sum_op.reduct_obj_create();
90 op_targs[kc] = rcp_op_targs[kc].ptr();
94 for(
int kc = 0; kc < m; ++kc ) {
95 sums[kc] = sum_op(*op_targs[kc]);
100template<
class Scalar>
104 using Teuchos::tuple;
using Teuchos::ptrInArg;
using Teuchos::null;
106 RTOpPack::ROpNorm1<Scalar> sum_abs_op;
108 RTOpPack::ROpNormInf<Scalar> max_op;
111 max_targ = max_op.reduct_obj_create();
117 return max_op(*max_targ);
121template<
class Scalar>
128template<
class Scalar>
133 bool is_compatible = U.
range()->isCompatible(*a.
space());
136 "update(...), Error, U.range()->isCompatible(*a.space())==false" );
137 is_compatible = U.
range()->isCompatible(*V->
range());
140 "update(...), Error, U.range()->isCompatible((V->range())==false" );
144 "update(...), Error, U.domain().isCompatible(V->domain())==false" );
146 const int m = U.
domain()->dim();
147 for(
int j = 0; j < m; ++j ) {
153template<
class Scalar>
160template<
class Scalar>
168template<
class Scalar>
176template<
class Scalar>
181 bool is_compatible = U.
range()->isCompatible(*V->
range());
184 "update(...), Error, U.range()->isCompatible((V->range())==false");
188 "update(...), Error, U.domain().isCompatible(V->domain())==false");
190 const int m = U.
domain()->dim();
191 for(
int j = 0; j < m; ++j )
196template<
class Scalar>
202 bool is_compatible = U.
range()->isCompatible(*V->
range());
205 "update(...), Error, U.range()->isCompatible((V->range())==false");
209 "update(...), Error, U.domain().isCompatible(V->domain())==false");
211 const int m = U.
domain()->dim();
212 for(
int j = 0; j < m; ++j ) {
219template<
class Scalar>
227 Y->linear_combination(alpha, X, beta);
231template<
class Scalar>
235 const int m = V->
domain()->dim();
236 for(
int j = 0; j < m; ++j )
242template<
class Scalar>
244 const Scalar& alpha )
250template<
class Scalar>
252 const Scalar& alpha )
254 const int m = Z->domain()->dim();
255 for(
int j = 0; j < m; ++j )
256 Vp_S( Z->col(j).ptr(), alpha );
261template<
class Scalar>
265 using Teuchos::tuple;
using Teuchos::ptrInArg;
272template<
class Scalar>
276 using Teuchos::tuple;
using Teuchos::ptrInArg;
279 tuple(ST::one(), ST::one()), tuple(ptrInArg(X), ptrInArg(Y)),
285template<
class Scalar>
289 using Teuchos::tuple;
using Teuchos::ptrInArg;
using Teuchos::as;
292 tuple(ST::one(), as<Scalar>(-ST::one())), tuple(ptrInArg(X), ptrInArg(Y)),
298template<
class Scalar>
304 using Teuchos::tuple;
using Teuchos::ptrInArg;
307 tuple(alpha, ST::one()), tuple(ptrInArg(X), ptrInArg(Y)),
317#define THYRA_MULTI_VECTOR_STD_OPS_INSTANT(SCALAR) \
319 template void norms( const MultiVectorBase<SCALAR >& V, \
320 const ArrayView<ScalarTraits<SCALAR >::magnitudeType> &norms ); \
322 template void dots( const MultiVectorBase<SCALAR >& V1, const MultiVectorBase<SCALAR >& V2, \
323 const ArrayView<SCALAR > &dots ); \
325 template void sums( const MultiVectorBase<SCALAR >& V, const ArrayView<SCALAR > &sums ); \
327 template Teuchos::ScalarTraits<SCALAR >::magnitudeType \
328 norm_1( const MultiVectorBase<SCALAR >& V ); \
330 template void scale( SCALAR alpha, const Ptr<MultiVectorBase<SCALAR > > &V ); \
332 template void scaleUpdate( const VectorBase<SCALAR >& a, \
333 const MultiVectorBase<SCALAR >& U, const Ptr<MultiVectorBase<SCALAR > > &V ); \
335 template void assign( const Ptr<MultiVectorBase<SCALAR > > &V, SCALAR alpha ); \
337 template void assign( const Ptr<MultiVectorBase<SCALAR > > &V, \
338 const MultiVectorBase<SCALAR >& U ); \
340 template void update( SCALAR alpha, const MultiVectorBase<SCALAR >& U, \
341 const Ptr<MultiVectorBase<SCALAR > > &V ); \
343 template void update( const ArrayView<const SCALAR > &alpha, SCALAR beta, \
344 const MultiVectorBase<SCALAR >& U, const Ptr<MultiVectorBase<SCALAR > > &V ); \
346 template void update( const MultiVectorBase<SCALAR >& U, \
347 const ArrayView<const SCALAR > &alpha, SCALAR beta, \
348 const Ptr<MultiVectorBase<SCALAR > > &V ); \
350 template void linear_combination( \
351 const ArrayView<const SCALAR > &alpha, \
352 const ArrayView<const Ptr<const MultiVectorBase<SCALAR > > > &X, \
353 const SCALAR &beta, \
354 const Ptr<MultiVectorBase<SCALAR > > &Y \
357 template void randomize( SCALAR l, SCALAR u, \
358 const Ptr<MultiVectorBase<SCALAR > > &V ); \
360 template void Vt_S( const Ptr<MultiVectorBase<SCALAR > > &Z, \
361 const SCALAR & alpha ); \
363 template void Vp_S( const Ptr<MultiVectorBase<SCALAR > > &Z, \
364 const SCALAR & alpha ); \
366 template void Vp_V( const Ptr<MultiVectorBase<SCALAR > > &Z, \
367 const MultiVectorBase<SCALAR >& X ); \
369 template void V_VpV( const Ptr<MultiVectorBase<SCALAR > > &Z, \
370 const MultiVectorBase<SCALAR >& X, const MultiVectorBase<SCALAR >& Y ); \
372 template void V_VmV( const Ptr<MultiVectorBase<SCALAR > > &Z, \
373 const MultiVectorBase<SCALAR >& X, const MultiVectorBase<SCALAR >& Y ); \
375 template void V_StVpV( \
376 const Ptr<MultiVectorBase<SCALAR > > &Z, const SCALAR &alpha, \
377 const MultiVectorBase<SCALAR >& X, const MultiVectorBase<SCALAR >& Y \
RCP< const LinearOpBase< Scalar > > scale(const Scalar &scalar, const RCP< const LinearOpBase< Scalar > > &Op, const std::string &label="")
Build an implicit const scaled linear operator.
Thrown if vector spaces are incompatible.
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
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 assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
void sums(const MultiVectorBase< Scalar > &V, const ArrayView< Scalar > &sums)
Multi-vector column sum.
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
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 dots(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
Column-wise Euclidean dot product.
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=0)
Apply a reduction/transformation operator column by column and return an array of the reduction objec...
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 update(Scalar alpha, const MultiVectorBase< Scalar > &U, const Ptr< MultiVectorBase< Scalar > > &V)
alpha*U + V -> V.
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 dots(const MultiVectorBase< Scalar > &V1, const MultiVectorBase< Scalar > &V2, const ArrayView< Scalar > &dots)
Multi-vector dot product.
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 linear_combination(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &X, const Scalar &beta, const Ptr< MultiVectorBase< Scalar > > &Y)
Y.col(j)(i) = beta*Y.col(j)(i) + sum( alpha[k]*X[k].col(j)(i), k=0...m-1 ), for i = 0....
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 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.
Abstract interface for finite-dimensional dense vectors.
void Vp_StV(const Ptr< VectorBase< Scalar > > &y, const Scalar &alpha, const VectorBase< Scalar > &x)
AXPY: y(i) = alpha * x(i) + y(i), i = 0...y->space()->dim()-1.
void ele_wise_prod(const Scalar &alpha, const VectorBase< Scalar > &x, const VectorBase< Scalar > &v, const Ptr< VectorBase< Scalar > > &y)
Element-wise product update: y(i) += alpha * x(i) * v(i), i = 0...y->space()->dim()-1.
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TypeTo as(const TypeFrom &t)