42#ifndef TPETRA_MULTIVECTOR_DECL_HPP
43#define TPETRA_MULTIVECTOR_DECL_HPP
51#include "Tpetra_DistObject.hpp"
54#include "Kokkos_DualView.hpp"
55#include "Teuchos_BLAS_types.hpp"
56#include "Teuchos_DataAccess.hpp"
57#include "Teuchos_Range1D.hpp"
58#include "Kokkos_ArithTraits.hpp"
59#include "Kokkos_InnerProductSpaceTraits.hpp"
60#include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
61#include "Tpetra_Access.hpp"
62#include "Tpetra_Details_WrappedDualView.hpp"
65#ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
66#ifndef DOXYGEN_SHOULD_SKIP_THIS
68 template<
class OrdinalType,
class ScalarType>
69 class SerialDenseMatrix;
98 template <
class DS,
class DL,
class DG,
class DN,
99 class SS,
class SL,
class SG,
class SN>
104#ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
111 template <
class ST,
class LO,
class GO,
class NT>
114 const Teuchos::SerialDenseMatrix<int, ST>& src);
122 template <
class ST,
class LO,
class GO,
class NT>
124 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
135 template <
class ST,
class LO,
class GO,
class NT>
148 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
151 const size_t numVectors);
156 template<
class SC,
class LO,
class GO,
class NT>
157 Teuchos::ArrayView<const size_t>
380 template <
class Scalar,
385 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
409 typename Kokkos::Details::ArithTraits<Scalar>::val_type;
428 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
436 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
469 using wrapped_dual_view_type = Details::WrappedDualView<dual_view_type>;
471 using host_view_type =
typename dual_view_type::t_host;
472 using device_view_type =
typename dual_view_type::t_dev;
487 MultiVector (
const Teuchos::RCP<const map_type>& map,
488 const size_t numVecs,
489 const bool zeroOut =
true);
502 const Teuchos::DataAccess copyOrView);
519 MultiVector (
const Teuchos::RCP<const map_type>& map,
520 const Teuchos::ArrayView<const Scalar>& A,
522 const size_t NumVectors);
537 MultiVector (
const Teuchos::RCP<const map_type>& map,
538 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
539 const size_t NumVectors);
553 MultiVector (
const Teuchos::RCP<const map_type>& map,
594 MultiVector (
const Teuchos::RCP<const map_type>& map,
595 const typename dual_view_type::t_dev& d_view);
619 MultiVector (
const Teuchos::RCP<const map_type>& map,
631 MultiVector (
const Teuchos::RCP<const map_type>& map,
632 const wrapped_dual_view_type& d_view);
663 MultiVector (
const Teuchos::RCP<const map_type>& map,
665 const Teuchos::ArrayView<const size_t>& whichVectors);
684 MultiVector (
const Teuchos::RCP<const map_type>& map,
685 const wrapped_dual_view_type& view,
686 const Teuchos::ArrayView<const size_t>& whichVectors);
716 MultiVector (
const Teuchos::RCP<const map_type>& map,
719 const Teuchos::ArrayView<const size_t>& whichVectors);
782 const Teuchos::RCP<const map_type>& subMap,
793 const size_t offset = 0);
844#ifdef KOKKOS_ENABLE_SERIAL
845 ! std::is_same<execution_space, Kokkos::Serial>::value;
918 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
985 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1061 template<
typename T>
1062 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1126 template<
typename T>
1127 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1147 template<
typename T>
1148 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1181 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1248 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1288 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1289 subCopy (
const Teuchos::Range1D& colRng)
const;
1292 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1293 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1296 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1297 subView (
const Teuchos::Range1D& colRng)
const;
1300 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1301 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1304 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1308 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1373 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1374 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1375 const size_t offset)
const;
1394 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1396 const size_t offset);
1399 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1403 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1407 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1420 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1421 const size_t LDA)
const;
1430 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1437 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1440 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1454 typename dual_view_type::t_host::const_type
getLocalViewHost(Access::ReadOnlyStruct)
const;
1462 typename dual_view_type::t_host
getLocalViewHost(Access::OverwriteAllStruct);
1466 typename dual_view_type::t_dev::const_type
getLocalViewDevice(Access::ReadOnlyStruct)
const;
1477 template<
class TargetDeviceType>
1479 return view_.getDualView().template need_sync<TargetDeviceType> ();
1516 template<
class TargetDeviceType>
1517 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type::const_type
1520 return view_.template getView<TargetDeviceType>(s);
1524 template<
class TargetDeviceType>
1525 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type
1528 return view_.template getView<TargetDeviceType>(s);
1531 template<
class TargetDeviceType>
1532 typename std::remove_reference<decltype(std::declval<dual_view_type>().template view<TargetDeviceType>())>::type
1535 return view_.template getView<TargetDeviceType>(s);
1556 dot (
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1557 const Teuchos::ArrayView<dot_type>& dots)
const;
1570 template <
typename T>
1571 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1573 const Teuchos::ArrayView<T> &dots)
const
1575 const size_t sz =
static_cast<size_t> (dots.size ());
1576 Teuchos::Array<dot_type> dts (sz);
1578 for (
size_t i = 0; i < sz; ++i) {
1585 template <
typename T>
1586 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1588 std::vector<T>& dots)
const
1590 const size_t sz = dots.size ();
1591 Teuchos::Array<dot_type> dts (sz);
1593 for (
size_t i = 0; i < sz; ++i) {
1618 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1620 template<
class ViewType>
1622 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1623 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1625 const ViewType& dots)
const {
1626 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1627 this->
dot (A, h_dots);
1629 Kokkos::deep_copy(dots,h_dots);
1644 template <
typename T>
1645 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1647 const Kokkos::View<T*, device_type>& dots)
const
1649 const size_t numDots = dots.extent (0);
1650 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1661 Kokkos::deep_copy (dots, dts);
1677 void scale (
const Scalar& alpha);
1687 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1697 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1708 scale (
const Scalar& alpha,
1718 update (
const Scalar& alpha,
1720 const Scalar& beta);
1729 update (
const Scalar& alpha,
1733 const Scalar& gamma);
1747 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1749 template<
class ViewType>
1750 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1751 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1752 norm1 (
const ViewType& norms)
const {
1756 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1757 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1758 this->
norm1 (h_norms);
1778 template <
typename T>
1779 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1780 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1782 const size_t numNorms = norms.extent (0);
1783 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1785 this->
norm1 (tmpNorms);
1792 Kokkos::deep_copy (norms, tmpNorms);
1798 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1814 template <
typename T>
1815 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1816 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1818 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1819 const size_type sz = norms.size ();
1820 Teuchos::Array<mag_type> theNorms (sz);
1821 this->
norm1 (theNorms);
1822 for (size_type i = 0; i < sz; ++i) {
1824 norms[i] = theNorms[i];
1841 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1843 template<
class ViewType>
1844 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1845 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1846 norm2 (
const ViewType& norms)
const {
1850 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1851 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1852 this->
norm2 (h_norms);
1854 Kokkos::deep_copy (norms, h_norms);
1870 template<
typename T>
1871 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1872 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
1874 const size_t numNorms = norms.extent (0);
1875 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1877 this->
norm2 (theNorms);
1884 Kokkos::deep_copy (norms, theNorms);
1890 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1906 template <
typename T>
1907 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1908 norm2 (
const Teuchos::ArrayView<T>& norms)
const
1910 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1911 const size_type sz = norms.size ();
1912 Teuchos::Array<mag_type> theNorms (sz);
1913 this->
norm2 (theNorms);
1914 for (size_type i = 0; i < sz; ++i) {
1916 norms[i] = theNorms[i];
1926 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1928 template<
class ViewType>
1929 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1930 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1931 normInf (
const ViewType& norms)
const {
1935 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1936 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1955 template<
typename T>
1956 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1957 normInf (
const Kokkos::View<T*, device_type>& norms)
const
1959 const size_t numNorms = norms.extent (0);
1960 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1969 Kokkos::deep_copy (norms, theNorms);
1976 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1993 template <
typename T>
1994 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1995 normInf (
const Teuchos::ArrayView<T>& norms)
const
1997 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1998 const size_type sz = norms.size ();
1999 Teuchos::Array<mag_type> theNorms (sz);
2000 this->
norm2 (theNorms);
2001 for (size_type i = 0; i < sz; ++i) {
2003 norms[i] = theNorms[i];
2012 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
2014 template <
typename T>
2015 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
2016 meanValue (
const Teuchos::ArrayView<T>& means)
const
2018 typedef typename Teuchos::Array<T>::size_type size_type;
2019 const size_type numMeans = means.size ();
2021 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
2023 for (size_type k = 0; k < numMeans; ++k) {
2024 means[k] =
static_cast<T
> (theMeans[k]);
2035 Teuchos::ETransp transB,
2036 const Scalar& alpha,
2037 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2038 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2039 const Scalar& beta);
2063 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2064 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2094 bool aliases(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& other)
const;
2133 describe (Teuchos::FancyOStream& out,
2134 const Teuchos::EVerbosityLevel verbLevel =
2135 Teuchos::Describable::verbLevel_default)
const;
2165 TEUCHOS_TEST_FOR_EXCEPTION(
2166 copyOrView == Teuchos::Copy, std::invalid_argument,
2167 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2168 "MultiVector _only_ implements view semantics. You may not call this "
2169 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2182 return Teuchos::View;
2205 Teuchos::RCP<MultiVector<T, LocalOrdinal, GlobalOrdinal, Node> >
2225 template <
class DS,
class DL,
class DG,
class DN,
2226 class SS,
class SL,
class SG,
class SN>
2253 template<
class SC,
class LO,
class GO,
class NT>
2254 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2293 const std::string& className,
2294 const Teuchos::EVerbosityLevel verbLevel =
2295 Teuchos::Describable::verbLevel_default)
const;
2298 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2305 Teuchos::ArrayRCP<T>
2341 const size_t numSameIDs,
2342 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2343 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
2349 const Kokkos::DualView<
2358 size_t& constantNumPackets);
2362 (
const Kokkos::DualView<
2371 const size_t constantNumPackets,
2378 template<
class NO=Node>
2379 typename std::enable_if<std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2380 typename NO::device_type::memory_space>::value,
bool>::type
2381 reallocImportsIfNeededImpl (
const size_t newSize,
2383 const std::string* prefix,
2384 const bool areRemoteLIDsContiguous,
2389 template<
class NO=Node>
2390 typename std::enable_if<!std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2391 typename NO::device_type::memory_space>::value,
bool>::type
2392 reallocImportsIfNeededImpl (
const size_t newSize,
2394 const std::string* prefix,
2395 const bool areRemoteLIDsContiguous,
2402 const std::string* prefix,
2403 const bool areRemoteLIDsContiguous=
false,
2408 bool importsAreAliased();
2411 Kokkos::DualView<impl_scalar_type*, buffer_device_type> unaliased_imports_;
2416 template<
class SC,
class LO,
class GO,
class NT>
2417 Teuchos::ArrayView<const size_t>
2426 template <
class ST,
class LO,
class GO,
class NT>
2438 template <
class DS,
class DL,
class DG,
class DN,
2439 class SS,
class SL,
class SG,
class SN>
2444 using ::Tpetra::getMultiVectorWhichVectors;
2446 TEUCHOS_TEST_FOR_EXCEPTION(
2449 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2450 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2451 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions ["
2455 TEUCHOS_TEST_FOR_EXCEPTION(
2457 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2458 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) "
2464 if (srcMostUpToDateOnDevice) {
2476 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2477 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2479 if (srcMostUpToDateOnDevice) {
2504 template<
class SC,
class LO,
class GO,
class NT>
2505 class TypeNameTraits<
Tpetra::MultiVector<SC, LO, GO, NT> > {
2507 static std::string name () {
2508 return std::string (
"Tpetra::MultiVector<") +
2509 TypeNameTraits<SC>::name () +
"," +
2510 TypeNameTraits<LO>::name () +
"," +
2511 TypeNameTraits<GO>::name () +
"," +
2512 TypeNameTraits<NT>::name () +
">";
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Forward declaration of Tpetra::FEMultiVector.
Forward declaration of Tpetra::Map.
Forward declaration of Tpetra::MultiVector.
Forward declaration of Tpetra::Vector.
Base class for distributed Tpetra objects that support data redistribution.
A parallel distribution of indices over processes.
Node node_type
Legacy typedef that will go away at some point.
GlobalOrdinal global_ordinal_type
The type of global indices.
LocalOrdinal local_ordinal_type
The type of local indices.
typename Node::device_type device_type
This class' Kokkos::Device specialization.
One or more distributed dense vectors.
typename map_type::global_ordinal_type global_ordinal_type
The type of global indices that this class uses.
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,...
void normInf(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a host View.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A, const size_t LDA) const
Fill the given array with a copy of this multivector's local values.
size_t getStride() const
Stride between columns in the multivector.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
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.
void randomize()
Set all values in the multivector to pseudorandom numbers.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Map and their communicator.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type replaceGlobalValue(GlobalOrdinal globalRow, size_t col, const T &value)
Like the above replaceGlobalValue, but only enabled if T differs from impl_scalar_type.
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< dot_type > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
void describeImpl(Teuchos::FancyOStream &out, const std::string &className, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Implementation of describe() for this class, and its subclass Vector.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetView(const Teuchos::RCP< const map_type > &subMap, const size_t offset) const
Return a const view of a subset of rows.
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &src)
Copy the contents of src into *this (deep copy).
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
void meanValue(const Teuchos::ArrayView< impl_scalar_type > &means) const
Compute mean (average) value of each column.
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
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).
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
wrapped_dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
virtual void copyAndPermute(const SrcDistObject &sourceObj, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM)
Perform copies and permutations that are local to the calling (MPI) process.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const map_type &subMap, const size_t offset=0)
"Offset view" constructor, that takes the new Map as a const Map& rather than by RCP.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using local (row) index.
std::remove_reference< decltype(std::declval< dual_view_type >().templateview< TargetDeviceType >())>::type::const_type getLocalView(Access::ReadOnlyStruct s) const
Return a view of the local data on a specific device, with the given access mode. The return type is ...
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type putScalar(const T &value)
Set all values in the multivector with the given value.
void swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Swap contents of mv with contents of *this.
size_t getLocalLength() const
Local number of rows on the calling process.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const T &val, const bool atomic=useAtomicUpdatesByDefault)
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
typename DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(const size_t j) const
Return a Vector which is a const view of column j.
Scalar scalar_type
The type of each entry in the MultiVector.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
void norm2(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the two-norm of each vector (column), storing the result in a host View.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
Teuchos::ArrayRCP< T > getSubArrayRCP(Teuchos::ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using global row index.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, device_type > dual_view_type
Kokkos::DualView specialization used by this class.
virtual bool reallocImportsIfNeeded(const size_t newSize, const bool verbose, const std::string *prefix, const bool areRemoteLIDsContiguous=false, const CombineMode CM=INSERT)
Reallocate imports_ if needed.
typename map_type::device_type device_type
This class' preferred Kokkos device type.
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.
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.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
size_t getNumVectors() const
Number of columns in the multivector.
void sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &val, const bool atomic=useAtomicUpdatesByDefault)
Update (+=) a value in host memory, using local row index.
void replaceMap(const Teuchos::RCP< const map_type > &map)
Replace the underlying Map in place.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
Teuchos::RCP< MultiVector< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another MultiVector with the same entries, but converted to a different Scalar type T.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
dual_view_type::t_dev::const_type getLocalViewDevice(Access::ReadOnlyStruct) const
Return a read-only, up-to-date view of this MultiVector's local data on device. This requires that th...
typename device_type::execution_space execution_space
Type of the (new) Kokkos execution space.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
void norm1(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the one-norm of each vector (column), storing the result in a host view.
void get2dCopy(const Teuchos::ArrayView< const Teuchos::ArrayView< Scalar > > &ArrayOfPtrs) const
Fill the given array with a copy of this multivector's local values.
void sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value, const bool atomic=useAtomicUpdatesByDefault)
Update (+=) a value in host memory, using global row index.
bool aliases(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &other) const
Whether this multivector's memory might alias other. This is conservative: if either this or other is...
dual_view_type::t_host::const_type getLocalViewHost(Access::ReadOnlyStruct) const
Return a read-only, up-to-date view of this MultiVector's local data on host. This requires that ther...
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
MultiVector(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor (shallow move).
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const Teuchos::RCP< const map_type > &subMap, const local_ordinal_type rowOffset=0)
"Offset view" constructor; make a view of a contiguous subset of rows on each process.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const T &val)
Like the above replaceLocalValue, but only enabled if T differs from impl_scalar_type.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > offsetViewNonConst(const Teuchos::RCP< const map_type > &subMap, const size_t offset)
Return a nonconst view of a subset of rows.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string.
std::enable_if<!std::is_same< T, impl_scalar_type >::value &&std::is_convertible< T, impl_scalar_type >::value, void >::type sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const T &val, const bool atomic=useAtomicUpdatesByDefault)
Like the above sumIntoLocalValue, but only enabled if T differs from impl_scalar_type.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
MultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor (shallow copy).
Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > get2dView() const
Return const persisting pointers to values.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
Abstract base class for objects that can be the source of an Import or Export operation.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t numVectors)
Nonmember MultiVector "constructor": Create a MultiVector from a given Map.
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
void localDeepCopy(const DstViewType &dst, const SrcViewType &src, const bool dstConstStride, const bool srcConstStride, const DstWhichVecsType &dstWhichVecs, const SrcWhichVecsType &srcWhichVecs)
Implementation of Tpetra::MultiVector deep copy of local data.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
size_t global_size_t
Global size_t object.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
CombineMode
Rule for combining data in an Import or Export.
@ INSERT
Insert new values that don't currently exist.