42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
43 #define TPETRA_MULTIVECTOR_DECL_HPP
45 #include <Teuchos_DataAccess.hpp>
46 #include <Teuchos_Range1D.hpp>
47 #include "Tpetra_ConfigDefs.hpp"
48 #include "Tpetra_DistObject.hpp"
49 #include "Tpetra_ViewAccepter.hpp"
50 #include <Kokkos_MultiVector.hpp>
51 #include <Teuchos_BLAS_types.hpp>
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 template<
class KokkosMultiVectorType>
57 class DefaultArithmetic;
58 #endif // DOXYGEN_SHOULD_SKIP_THIS
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
65 template<
class S,
class LO,
class GO,
class N>
class Vector;
68 template<
class LO,
class GO,
class N>
class Map;
69 #endif // DOXYGEN_SHOULD_SKIP_THIS
319 template<
class Scalar,
320 class LocalOrdinal=int,
321 class GlobalOrdinal=LocalOrdinal,
322 class Node=Kokkos::DefaultNode::DefaultNodeType>
324 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
372 const Teuchos::ArrayView<const Scalar>& A,
390 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
411 const Scalar &value);
424 const Scalar &value);
437 const Scalar &value);
450 const Scalar &value);
577 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
578 subCopy (
const Teuchos::Range1D &colRng)
const;
581 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
582 subCopy (
const Teuchos::ArrayView<const size_t> &cols)
const;
585 Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
586 subView (
const Teuchos::Range1D &colRng)
const;
589 Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
590 subView (
const Teuchos::ArrayView<const size_t> &cols)
const;
593 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
597 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
612 Teuchos::RCP<const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
614 size_t offset)
const;
628 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
633 Teuchos::RCP<const Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
637 Teuchos::RCP<Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
641 Teuchos::ArrayRCP<const Scalar>
getData(
size_t j)
const;
652 void get1dCopy (Teuchos::ArrayView<Scalar> A,
size_t LDA)
const;
659 void get2dCopy (Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> > ArrayOfPtrs)
const;
666 Teuchos::ArrayRCP<const Scalar>
get1dView()
const;
669 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView()
const;
682 const Kokkos::MultiVector<Scalar,Node> &
getLocalMV()
const;
708 void scale (
const Scalar &alpha);
718 void scale (Teuchos::ArrayView<const Scalar> alpha);
729 scale (
const Scalar& alpha,
739 update (
const Scalar& alpha,
750 update (
const Scalar& alpha,
754 const Scalar& gamma);
757 void norm1(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const;
761 void norm2(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const;
764 void normInf(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const;
772 void meanValue(
const Teuchos::ArrayView<Scalar> &means)
const;
781 Teuchos::ETransp transB,
866 describe (Teuchos::FancyOStream& out,
867 const Teuchos::EVerbosityLevel verbLevel =
868 Teuchos::Describable::verbLevel_default)
const;
889 typedef Kokkos::MultiVector<Scalar,Node> KMV;
890 typedef Kokkos::DefaultArithmetic<KMV> MVT;
912 template <
class S,
class LO,
class GO,
class N>
913 friend RCP<MultiVector<S,LO,GO,N> >
914 createMultiVectorFromView (
const Teuchos::RCP<
const Map<LO,GO,N> >&,
const Teuchos::ArrayRCP<S>&,
size_t,
size_t);
926 const Teuchos::ArrayRCP<Scalar>& view,
929 EPrivateHostViewConstructor );
931 bool vectorIndexOutOfRange (
size_t VectorIndex)
const;
943 Teuchos::ArrayRCP<Scalar> data,
945 Teuchos::ArrayView<const size_t> whichVectors,
946 EPrivateComputeViewConstructor );
950 Teuchos::ArrayRCP<Scalar> data,
953 EPrivateComputeViewConstructor );
963 const Kokkos::MultiVector<Scalar, Node>& localMultiVector,
964 EPrivateComputeViewConstructor );
974 const Kokkos::MultiVector<Scalar, Node>& localMultiVector,
975 Teuchos::ArrayView<const size_t> whichVectors,
976 EPrivateComputeViewConstructor );
992 const ArrayView<const LocalOrdinal>& permuteToLIDs,
993 const ArrayView<const LocalOrdinal>& permuteFromLIDs);
1000 const ArrayView<const LocalOrdinal>& exportLIDs,
1001 Array<Scalar>& exports,
1002 const ArrayView<size_t>& numExportPacketsPerLID,
1003 size_t& constantNumPackets,
1007 unpackAndCombine (
const ArrayView<const LocalOrdinal>& importLIDs,
1008 const ArrayView<const Scalar>& imports,
1009 const ArrayView<size_t>& numPacketsPerLID,
1010 size_t constantNumPackets,
1045 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1046 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
1053 const bool initToZero =
true;
1054 return rcp (
new MV (map, numVectors, initToZero));
1082 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1083 Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
1085 const Teuchos::ArrayRCP<Scalar>& view,
1098 return rcp (
new MV (map, VAN::template acceptView<Scalar> (view),
1099 LDA, numVectors, HOST_VIEW_CONSTRUCTOR));
1105 #endif // TPETRA_MULTIVECTOR_DECL_HPP
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetView(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &subMap, size_t offset) const
Return a const MultiVector view of a subset of rows.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
ArrayRCP< Scalar > ncview_
Nonconst host view created in createViewsNonConst().
void releaseViews() const
Hook for releasing views.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t numVectors)
Nonmember MultiVector constructor: make a MultiVector from a given Map.
void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
ViewAccepter provides support for compile-time detection based on Node type, of support for accepting...
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
size_t getNumVectors() const
Number of columns in the multivector.
size_t getLocalLength() const
Local number of rows on the calling process.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
One or more distributed dense vectors.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
bool createViewsNonConstRaisedEfficiencyWarning_
Whether createViewsNonConst() has yet raised an efficiency warning.
GlobalOrdinal global_ordinal_type
The type of global indices.
void replaceMap(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
virtual ~MultiVector()
Destructor (virtual for memory safety of derived classes).
void get1dCopy(Teuchos::ArrayView< Scalar > A, size_t LDA) const
Fill the given array with a copy of this multivector's local values.
Scalar scalar_type
The type of entries in the vector(s).
void get2dCopy(Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > ArrayOfPtrs) const
Fill the given array with a copy of this multivector's local values.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
bool createViewsRaisedEfficiencyWarning_
Whether createViews() has yet raised an efficiency warning.
void createViewsNonConst(Kokkos::ReadWriteOption rwo)
Hook for creating a nonconst view.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
size_t global_size_t
Global size_t object.
void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
ArrayRCP< T > getSubArrayRCP(ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
Node node_type
The Kokkos Node type.
void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Tpetra::Combine Mode enumerable type.
LocalOrdinal local_ordinal_type
The type of local indices.
bool releaseViewsRaisedEfficiencyWarning_
Whether releaseViews() has yet raised an efficiency warning.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVectorFromView(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayRCP< Scalar > &view, size_t LDA, size_t numVectors)
Nonmember MultiVector constructor with view semantics using user-allocated data.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
ArrayRCP< const Scalar > cview_
Const host view created in createViews().
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]) ...
Abstract base class for objects that can be the source of an Import or Export operation.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
Assign the contents of source to this multivector (deep copy).
void randomize()
Set all values in the multivector to pseudorandom numbers.
const Kokkos::MultiVector< Scalar, Node > & getLocalMV() const
Return a const reference to the underlying Kokkos::MultiVector object (advanced use only) ...
KMV lclMV_
The Kokkos::MultiVector containing the compute buffer of data.
Describes a parallel distribution of objects over processes.
void meanValue(const Teuchos::ArrayView< Scalar > &means) const
Compute mean (average) value of each vector in multi-vector. The outcome of this routine is undefined...
size_t getStride() const
Stride between columns in the multivector.
MultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic constuctor.
A distributed dense vector.
virtual std::string description() const
A simple one-line description of this object.
void reduce()
Sum values of a locally replicated multivector across all processes.
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetViewNonConst(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &subMap, size_t offset)
Return a non-const MultiVector view of a subset of rows.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > get2dView() const
Return const persisting pointers to values.
void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
Base class for distributed Tpetra objects that support data redistribution.
Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
Kokkos::MultiVector< Scalar, Node > & getLocalMVNonConst()
Return a non-const reference to the underlying Kokkos::MultiVector object (advanced use only) ...
void createViews() const
Hook for creating a const view.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
Remove processes owning zero rows from the Map and their communicator.