46#ifndef XPETRA_MULTIVECTOR_DECL_HPP
47#define XPETRA_MULTIVECTOR_DECL_HPP
50#include <Teuchos_LabeledObject.hpp>
61 #include <Kokkos_Core.hpp>
62 #include <Kokkos_DualView.hpp>
63 #include <Kokkos_ArithTraits.hpp>
68#ifndef DOXYGEN_SHOULD_SKIP_THIS
70template<
class S,
class LO,
class GO,
class N>
class Vector;
79 :
public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
116 virtual void replaceGlobalValue(GlobalOrdinal globalRow,
size_t vectorIndex,
const Scalar& value) = 0;
120 virtual void sumIntoGlobalValue(GlobalOrdinal globalRow,
size_t vectorIndex,
const Scalar& value) = 0;
124 virtual void replaceLocalValue(LocalOrdinal myRow,
size_t vectorIndex,
const Scalar& value) = 0;
128 virtual void sumIntoLocalValue(LocalOrdinal myRow,
size_t vectorIndex,
const Scalar& value) = 0;
176 virtual void scale(
const Scalar& alpha) = 0;
190 const Scalar& gamma) = 0;
216 const Scalar& beta) = 0;
249 Scalar scalarThis) = 0;
302 virtual void randomize(
bool bUseXpetraImplementation =
false) = 0;
305 virtual void randomize(
const Scalar& minVal,
const Scalar& maxVal,
bool bUseXpetraImplementation =
false) = 0;
315 using dual_view_type = Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged>;
316 using dual_view_type_const = Kokkos::DualView<const impl_scalar_type**, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged>;
322 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
324 typename dual_view_type::t_host_um test;
332 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
334 typename dual_view_type::t_dev_um test;
341 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
343 typename dual_view_type::t_host_um test;
351 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
353 typename dual_view_type::t_dev_um test;
360 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
362 typename dual_view_type::t_host_um test;
370 throw std::runtime_error(
"Dummy function getHostLocalView, should be overwritten at"+std::string(__FILE__)+
":"+std::to_string(__LINE__));
372 typename dual_view_type::t_dev_um test;
396#define XPETRA_MULTIVECTOR_SHORT
static const EVerbosityLevel verbLevel_default
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)=0
Replace value, using global (row) index.
virtual void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=false)=0
Set multi-vector values to random numbers.
virtual size_t getNumVectors() const =0
Number of columns in the multivector.
Kokkos::DualView< const impl_scalar_type **, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged > dual_view_type_const
virtual void putScalar(const Scalar &value)=0
Set all values in the multivector with the given value.
virtual dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
virtual void replaceMap(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)=0
GlobalOrdinal global_ordinal_type
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const =0
Const view of the local values in a particular vector of this multivector.
virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const =0
Compute 1-norm of each vector in multi-vector.
typename dual_view_type::t_dev::execution_space dev_execution_space
virtual void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)=0
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
virtual dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const
virtual void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)=0
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,...
virtual dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const
typename dual_view_type::host_mirror_space host_execution_space
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Assignment operator: Does a deep copy.
virtual 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)=0
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)=0
Add value to existing value, using local (row) index.
virtual Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)=0
Return a Vector which is a nonconst view of column j.
virtual size_t getLocalLength() const =0
Local number of rows on the calling process.
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma)=0
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
virtual Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const =0
Return a Vector which is a const view of column j.
virtual void scale(Teuchos::ArrayView< const Scalar > alpha)=0
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)=0
Add value to existing value, using global (row) index.
virtual dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const
virtual void randomize(bool bUseXpetraImplementation=false)=0
Set multi-vector values to random numbers.
virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const =0
Compute Inf-norm of each vector in multi-vector.
virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const =0
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged > dual_view_type
virtual void scale(const Scalar &alpha)=0
Scale the current values of a multi-vector, this = alpha*this.
virtual std::string description() const =0
A simple one-line description of this object.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)=0
Implementation of the assignment operator (operator=); does a deep copy.
virtual void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const =0
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)=0
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual void meanValue(const Teuchos::ArrayView< Scalar > &means) const =0
virtual dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const
virtual void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)=0
Multiply a Vector A elementwise by a MultiVector B.
virtual ~MultiVector()
Destructor.
LocalOrdinal local_ordinal_type
virtual void setSeed(unsigned int seed)=0
Set seed for Random function.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0
Print the object with the given verbosity level to a FancyOStream.
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)=0
View of the local values in a particular vector of this multivector.
virtual dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const
virtual global_size_t getGlobalLength() const =0
Global number of rows in the multivector.
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)=0
Replace value, using local (row) index.
virtual bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const =0
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
size_t global_size_t
Global size_t object.