Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MultiVectorBase_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_BASE_DECL_HPP
11 #define THYRA_MULTI_VECTOR_BASE_DECL_HPP
12 
13 #include "Thyra_LinearOpBase_decl.hpp"
14 #include "Thyra_RowStatLinearOpBase.hpp"
15 #include "Thyra_ScaledLinearOpBase.hpp"
16 #include "RTOpPack_RTOpT.hpp"
17 
18 
19 namespace Thyra {
20 
21 
460 template<class Scalar>
461 class MultiVectorBase : virtual public LinearOpBase<Scalar>,
462  virtual public RowStatLinearOpBase<Scalar>,
463  virtual public ScaledLinearOpBase<Scalar>
464 {
465 public:
466 
467 #ifdef THYRA_INJECT_USING_DECLARATIONS
469 #endif
470 
473 
481  void assign(Scalar alpha)
482  { assignImpl(alpha); }
483 
492  { assignMultiVecImpl(mv); }
493 
500  void scale(Scalar alpha)
501  { scaleImpl(alpha); }
502 
511  void update(
512  Scalar alpha,
513  const MultiVectorBase<Scalar>& mv
514  )
515  { updateImpl(alpha, mv); }
516 
543  const ArrayView<const Scalar>& alpha,
544  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
545  const Scalar& beta
546  )
547  { linearCombinationImpl(alpha, mv, beta); }
548 
558  void dots(
559  const MultiVectorBase<Scalar>& mv,
560  const ArrayView<Scalar>& prods
561  ) const
562  { dotsImpl(mv, prods); }
563 
571  void norms_1(
573  ) const
574  { norms1Impl(norms); }
575 
583  void norms_2(
585  ) const
586  { norms2Impl(norms); }
587 
595  void norms_inf(
597  ) const
598  { normsInfImpl(norms); }
599 
601 
604 
610  { return colImpl(j); }
611 
617  { return nonconstColImpl(j); }
618 
620 
623 
629  subView( const Range1D& colRng ) const
630  {
631  return contigSubViewImpl(colRng);
632  }
633 
639  subView( const Range1D& colRng )
640  { return nonconstContigSubViewImpl(colRng); }
641 
647  subView( const ArrayView<const int> &cols ) const
648  { return nonContigSubViewImpl(cols); }
649 
656  { return nonconstNonContigSubViewImpl(cols); }
657 
659 
662 
667  void applyOp(
668  const RTOpPack::RTOpT<Scalar> &primary_op,
669  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
670  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
671  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
672  const Ordinal primary_global_offset
673  ) const
674  {
675  mvMultiReductApplyOpImpl(primary_op, multi_vecs, targ_multi_vecs,
676  reduct_objs, primary_global_offset);
677  }
678 
683  void applyOp(
684  const RTOpPack::RTOpT<Scalar> &primary_op,
685  const RTOpPack::RTOpT<Scalar> &secondary_op,
686  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
687  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
688  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
689  const Ordinal primary_global_offset
690  ) const
691  {
692  mvSingleReductApplyOpImpl(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
693  reduct_obj, primary_global_offset);
694  }
695 
697 
700 
706  const Range1D &rowRng,
707  const Range1D &colRng,
709  ) const
710  { acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv ); }
711 
718  ) const
720 
726  const Range1D &rowRng,
727  const Range1D &colRng,
729  )
730  { acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv); }
731 
738  )
740 
742 
745 
754  virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0;
755 
757 
760 
763 
765 
766 protected:
767 
770 
774  virtual void assignImpl(Scalar alpha) = 0;
775 
779  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv) = 0;
780 
784  virtual void scaleImpl(Scalar alpha) = 0;
785 
789  virtual void updateImpl(
790  Scalar alpha,
791  const MultiVectorBase<Scalar>& mv
792  ) = 0;
793 
797  virtual void linearCombinationImpl(
798  const ArrayView<const Scalar>& alpha,
799  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
800  const Scalar& beta
801  ) = 0;
802 
806  virtual void dotsImpl(
807  const MultiVectorBase<Scalar>& mv,
808  const ArrayView<Scalar>& prods
809  ) const = 0;
810 
814  virtual void norms1Impl(
816  ) const = 0;
817 
821  virtual void norms2Impl(
823  ) const = 0;
824 
828  virtual void normsInfImpl(
830  ) const = 0;
831 
853  virtual RCP<const VectorBase<Scalar> > colImpl(Ordinal j) const;
854 
876 
902  contigSubViewImpl( const Range1D& colRng ) const = 0;
903 
929  nonconstContigSubViewImpl( const Range1D& colRng ) = 0;
930 
956  nonContigSubViewImpl( const ArrayView<const int> &cols ) const = 0;
957 
984 
1006  virtual void mvMultiReductApplyOpImpl(
1007  const RTOpPack::RTOpT<Scalar> &primary_op,
1008  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
1009  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
1010  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
1011  const Ordinal primary_global_offset
1012  ) const = 0;
1013 
1034  virtual void mvSingleReductApplyOpImpl(
1035  const RTOpPack::RTOpT<Scalar> &primary_op,
1036  const RTOpPack::RTOpT<Scalar> &secondary_op,
1037  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
1038  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
1039  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
1040  const Ordinal primary_global_offset
1041  ) const = 0;
1042 
1107  const Range1D &rowRng,
1108  const Range1D &colRng,
1110  ) const = 0;
1111 
1139  ) const = 0;
1140 
1214  const Range1D &rowRng,
1215  const Range1D &colRng,
1217  ) = 0;
1218 
1248  ) = 0;
1249 
1251  virtual bool rowStatIsSupportedImpl(
1252  const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
1253 
1255  virtual void getRowStatImpl(
1256  const RowStatLinearOpBaseUtils::ERowStat rowStat,
1257  const Ptr<VectorBase<Scalar> > &rowStatVec) const;
1258 
1260  virtual bool supportsScaleLeftImpl() const;
1261 
1263  virtual bool supportsScaleRightImpl() const;
1264 
1266  virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling);
1267 
1269  virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling);
1270 
1272 
1280  void absRowSum(const Teuchos::Ptr<Thyra::VectorBase<Scalar> > & output) const;
1281 
1287  void absColSum(const Teuchos::Ptr<Thyra::VectorBase<Scalar> > & output) const;
1288 
1289 public:
1290 
1291 private:
1292 
1293  // Not defined and not to be called
1295  operator=(const MultiVectorBase<Scalar>&);
1296 
1297 };
1298 
1299 
1307 template<class Scalar>
1308 inline
1309 void applyOp(
1310  const RTOpPack::RTOpT<Scalar> &primary_op,
1311  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
1312  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
1313  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
1314  const Ordinal primary_global_offset = 0
1315  )
1316 {
1317  if(multi_vecs.size())
1318  multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
1319  reduct_objs, primary_global_offset);
1320  else if(targ_multi_vecs.size())
1321  targ_multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
1322  reduct_objs, primary_global_offset);
1323 }
1324 
1325 
1333 template<class Scalar>
1334 inline
1335 void applyOp(
1336  const RTOpPack::RTOpT<Scalar> &primary_op,
1337  const RTOpPack::RTOpT<Scalar> &secondary_op,
1338  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
1339  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
1340  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
1341  const Ordinal primary_global_offset = 0
1342  )
1343 {
1344  if(multi_vecs.size())
1345  multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
1346  reduct_obj, primary_global_offset);
1347  else if(targ_multi_vecs.size())
1348  targ_multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
1349  reduct_obj, primary_global_offset);
1350 }
1351 
1352 
1353 } // namespace Thyra
1354 
1355 
1356 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const =0
Virtual implementation for NVI norms_inf().
void dots(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
Column-wise Euclidean dot product.
virtual RCP< const VectorBase< Scalar > > colImpl(Ordinal j) const
Return a non-changeable view of a constituent column vector.
RCP< MultiVectorBase< Scalar > > subView(const ArrayView< const int > &cols)
nonconstNonContigSubViewImpl().
void commitDetachedView(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Calls commitNonconstDetachedMultiVectorViewImpl().
virtual bool supportsScaleLeftImpl() const
RCP< const MultiVectorBase< Scalar > > subView(const ArrayView< const int > &cols) const
nonContigSubViewImpl().
virtual RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const =0
Return a non-changeable sub-view of a contiguous set of columns of the this multi-vector.
void norms_2(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise 2-norms.
virtual RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)=0
Return a changeable sub-view of a contiguous set of columns of the this multi-vector.
virtual bool supportsScaleRightImpl() const
virtual bool rowStatIsSupportedImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat) const
void acquireDetachedView(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Calls acquireNonconstDetachedMultiVectorViewImpl().
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
virtual void assignImpl(Scalar alpha)=0
Virtual implementation for NVI assign(Scalar).
virtual void scaleImpl(Scalar alpha)=0
Virtual implementation for NVI scale().
void releaseDetachedView(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Calls releaseDetachedMultiVectorViewImpl().
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const =0
Free a non-changeable explicit view of a sub-multi-vector.
RCP< const MultiVectorBase< Scalar > > subView(const Range1D &colRng) const
Calls contigSubViewImpl().
virtual RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)=0
Return a changeable view of a constituent column vector.
virtual void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Ptr< VectorBase< Scalar > > &rowStatVec) const
void assign(const MultiVectorBase< Scalar > &mv)
V = mv.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)=0
Virtual implementation for NVI update().
Interface for a collection of column vectors called a multi-vector.
void applyOp(const RTOpPack::RTOpT< Scalar > &primary_op, const RTOpPack::RTOpT< Scalar > &secondary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal primary_global_offset) const
mvSingleReductApplyOpImpl().
RCP< const LinearOpBase< Scalar > > clone() const
This function is simply overridden to return this-&gt;clone_mv().
RCP< VectorBase< Scalar > > col(Ordinal j)
Calls nonconstColImpl().
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
void update(Scalar alpha, const MultiVectorBase< Scalar > &mv)
Abstract interface for finite-dimensional dense vectors.
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
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),
Base class for all linear operators.
void acquireDetachedView(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
Calls acquireDetachedMultiVectorViewImpl().
void absRowSum(const Teuchos::Ptr< Thyra::VectorBase< Scalar > > &output) const
Applies left or right sclaing to the linear operator.
void assign(Scalar alpha)
V = alpha.
void applyOp(const RTOpPack::RTOpT< Scalar > &primary_op, const RTOpPack::RTOpT< Scalar > &secondary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal primary_global_offset=0)
Apply a reduction/transformation operator column by column and reduce the intermediate reduction obje...
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)=0
Get a changeable explicit view of a sub-multi-vector.
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)=0
Virtual implementation for NVI linear_combination().
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)=0
Virtual implementation for NVI assign(MV).
void norms_1(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise 1-norms.
virtual RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const =0
Return a non-changeable sub-view of a non-contiguous set of columns of this multi-vector.
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const =0
Virtual implementation for NVI norms_1().
virtual RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)=0
Return a changeable sub-view of a non-contiguous set of columns of this multi-vector.
Interface for exxtracting row statistics as a VectorBase from a supporting LinearOpBase object...
virtual void mvSingleReductApplyOpImpl(const RTOpPack::RTOpT< Scalar > &primary_op, const RTOpPack::RTOpT< Scalar > &secondary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal primary_global_offset) const =0
Apply a reduction/transformation operator column by column and reduce the intermediate reduction obje...
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
virtual void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const =0
Get a non-changeable explicit view of a sub-multi-vector.
void norms_inf(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
Column-wise infinity-norms.
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)=0
Commit changes for a changeable explicit view of a sub-multi-vector.
virtual RCP< MultiVectorBase< Scalar > > clone_mv() const =0
Clone the multi-vector object (if supported).
virtual void mvMultiReductApplyOpImpl(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 =0
Apply a reduction/transformation operator column by column and return an array of the reduction objec...
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 absColSum(const Teuchos::Ptr< Thyra::VectorBase< Scalar > > &output) const
RCP< MultiVectorBase< Scalar > > subView(const Range1D &colRng)
Calls nonconstContigSubViewImpl().
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const =0
Virtual implementation for NVI norms_2().
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const =0
Virtual implementation for NVI dots().
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...