43 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
44 #define TPETRA_MULTIVECTOR_DECL_HPP
52 #include "Tpetra_DistObject.hpp"
55 #include "Kokkos_DualView.hpp"
56 #include "Teuchos_BLAS_types.hpp"
57 #include "Teuchos_DataAccess.hpp"
58 #include "Teuchos_Range1D.hpp"
59 #include "Kokkos_ArithTraits.hpp"
60 #include "Kokkos_InnerProductSpaceTraits.hpp"
61 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
62 #include "Tpetra_Access.hpp"
63 #include "Tpetra_Details_WrappedDualView.hpp"
64 #include <type_traits>
66 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
67 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69 template<
class OrdinalType,
class ScalarType>
70 class SerialDenseMatrix;
72 #endif // DOXYGEN_SHOULD_SKIP_THIS
73 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
99 template <
class DS,
class DL,
class DG,
class DN,
100 class SS,
class SL,
class SG,
class SN>
102 deep_copy (MultiVector<DS, DL, DG, DN>& dst,
103 const MultiVector<SS, SL, SG, SN>& src);
105 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
106 template <
class ST,
class LO,
class GO,
class NT>
114 deep_copy (MultiVector<ST, LO, GO, NT>& dst,
115 const Teuchos::SerialDenseMatrix<int, ST>& src);
123 template <
class ST,
class LO,
class GO,
class NT>
125 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
126 const MultiVector<ST, LO, GO, NT>& src);
127 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
136 template <
class ST,
class LO,
class GO,
class NT>
137 MultiVector<ST, LO, GO, NT>
138 createCopy (
const MultiVector<ST, LO, GO, NT>& src);
149 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
150 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
151 createMultiVector (
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node> >& map,
152 const size_t numVectors);
157 template<
class SC,
class LO,
class GO,
class NT>
158 Teuchos::ArrayView<const size_t>
159 getMultiVectorWhichVectors (
const MultiVector<SC, LO, GO, NT>& X);
381 template <
class Scalar,
386 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
410 typename Kokkos::ArithTraits<Scalar>::val_type;
429 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
437 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
472 using host_view_type =
typename dual_view_type::t_host;
473 using device_view_type =
typename dual_view_type::t_dev;
488 MultiVector (
const Teuchos::RCP<const map_type>& map,
489 const size_t numVecs,
490 const bool zeroOut =
true);
503 const Teuchos::DataAccess copyOrView);
520 MultiVector (
const Teuchos::RCP<const map_type>& map,
521 const Teuchos::ArrayView<const Scalar>& A,
523 const size_t NumVectors);
538 MultiVector (
const Teuchos::RCP<const map_type>& map,
539 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
540 const size_t NumVectors);
554 MultiVector (
const Teuchos::RCP<const map_type>& map,
595 MultiVector (
const Teuchos::RCP<const map_type>& map,
596 const typename dual_view_type::t_dev& d_view);
620 MultiVector (
const Teuchos::RCP<const map_type>& map,
632 MultiVector (
const Teuchos::RCP<const map_type>& map,
664 MultiVector (
const Teuchos::RCP<const map_type>& map,
666 const Teuchos::ArrayView<const size_t>& whichVectors);
685 MultiVector (
const Teuchos::RCP<const map_type>& map,
687 const Teuchos::ArrayView<const size_t>& whichVectors);
717 MultiVector (
const Teuchos::RCP<const map_type>& map,
720 const Teuchos::ArrayView<const size_t>& whichVectors);
783 const Teuchos::RCP<const map_type>& subMap,
794 const size_t offset = 0);
845 #ifdef KOKKOS_ENABLE_SERIAL
846 ! std::is_same<execution_space, Kokkos::Serial>::value;
849 #endif // KOKKOS_ENABLE_SERIAL
919 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
986 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1062 template<
typename T>
1063 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1127 template<
typename T>
1128 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1148 template<
typename T>
1149 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1152 putScalar (static_cast<impl_scalar_type> (value));
1182 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1249 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1289 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1290 subCopy (
const Teuchos::Range1D& colRng)
const;
1293 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1294 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1297 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1298 subView (
const Teuchos::Range1D& colRng)
const;
1301 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1302 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1305 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1309 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1374 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1375 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1376 const size_t offset)
const;
1395 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1397 const size_t offset);
1400 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1404 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1408 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1421 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1422 const size_t LDA)
const;
1431 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1438 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1441 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1455 typename dual_view_type::t_host::const_type
getLocalViewHost(Access::ReadOnlyStruct)
const;
1463 typename dual_view_type::t_host
getLocalViewHost(Access::OverwriteAllStruct);
1467 typename dual_view_type::t_dev::const_type
getLocalViewDevice(Access::ReadOnlyStruct)
const;
1484 template<
class TargetDeviceType>
1486 return view_.getDualView().template need_sync<TargetDeviceType> ();
1523 template<
class TargetDeviceType>
1524 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type::const_type
1527 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);
1538 template<
class TargetDeviceType>
1539 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type
1542 return view_.template getView<TargetDeviceType>(s);
1563 dot (
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1564 const Teuchos::ArrayView<dot_type>& dots)
const;
1577 template <
typename T>
1578 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1580 const Teuchos::ArrayView<T> &dots)
const
1582 const size_t sz =
static_cast<size_t> (dots.size ());
1583 Teuchos::Array<dot_type> dts (sz);
1585 for (
size_t i = 0; i < sz; ++i) {
1592 template <
typename T>
1593 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1595 std::vector<T>& dots)
const
1597 const size_t sz = dots.size ();
1598 Teuchos::Array<dot_type> dts (sz);
1600 for (
size_t i = 0; i < sz; ++i) {
1625 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1627 template<
class ViewType>
1629 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1630 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1632 const ViewType& dots)
const {
1633 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1634 this->
dot (A, h_dots);
1651 template <
typename T>
1652 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1654 const Kokkos::View<T*, device_type>& dots)
const
1656 const size_t numDots = dots.extent (0);
1657 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1684 void scale (
const Scalar& alpha);
1694 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1704 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1715 scale (
const Scalar& alpha,
1725 update (
const Scalar& alpha,
1727 const Scalar& beta);
1736 update (
const Scalar& alpha,
1740 const Scalar& gamma);
1754 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1756 template<
class ViewType>
1757 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1758 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1759 norm1 (
const ViewType& norms)
const {
1763 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1764 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1765 this->
norm1 (h_norms);
1785 template <
typename T>
1786 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1787 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1789 const size_t numNorms = norms.extent (0);
1790 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1792 this->
norm1 (tmpNorms);
1805 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1821 template <
typename T>
1822 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1823 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1825 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1826 const size_type sz = norms.size ();
1827 Teuchos::Array<mag_type> theNorms (sz);
1828 this->
norm1 (theNorms);
1829 for (size_type i = 0; i < sz; ++i) {
1831 norms[i] = theNorms[i];
1848 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1850 template<
class ViewType>
1851 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1852 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1853 norm2 (
const ViewType& norms)
const {
1857 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1858 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1859 this->
norm2 (h_norms);
1877 template<
typename T>
1878 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1879 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
1881 const size_t numNorms = norms.extent (0);
1882 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1884 this->
norm2 (theNorms);
1897 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1913 template <
typename T>
1914 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1915 norm2 (
const Teuchos::ArrayView<T>& norms)
const
1917 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1918 const size_type sz = norms.size ();
1919 Teuchos::Array<mag_type> theNorms (sz);
1920 this->
norm2 (theNorms);
1921 for (size_type i = 0; i < sz; ++i) {
1923 norms[i] = theNorms[i];
1933 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1935 template<
class ViewType>
1936 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1937 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1938 normInf (
const ViewType& norms)
const {
1942 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1943 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1962 template<
typename T>
1963 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1964 normInf (
const Kokkos::View<T*, device_type>& norms)
const
1966 const size_t numNorms = norms.extent (0);
1967 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1983 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
2000 template <
typename T>
2001 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
2002 normInf (
const Teuchos::ArrayView<T>& norms)
const
2004 typedef typename Teuchos::ArrayView<T>::size_type size_type;
2005 const size_type sz = norms.size ();
2006 Teuchos::Array<mag_type> theNorms (sz);
2007 this->
norm2 (theNorms);
2008 for (size_type i = 0; i < sz; ++i) {
2010 norms[i] = theNorms[i];
2019 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
2021 template <
typename T>
2022 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
2023 meanValue (
const Teuchos::ArrayView<T>& means)
const
2025 typedef typename Teuchos::Array<T>::size_type size_type;
2026 const size_type numMeans = means.size ();
2028 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
2030 for (size_type k = 0; k < numMeans; ++k) {
2031 means[k] =
static_cast<T
> (theMeans[k]);
2042 Teuchos::ETransp transB,
2043 const Scalar& alpha,
2044 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2045 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2046 const Scalar& beta);
2070 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2071 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2101 bool aliases(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& other)
const;
2140 describe (Teuchos::FancyOStream& out,
2141 const Teuchos::EVerbosityLevel verbLevel =
2142 Teuchos::Describable::verbLevel_default)
const override;
2172 TEUCHOS_TEST_FOR_EXCEPTION(
2173 copyOrView == Teuchos::Copy, std::invalid_argument,
2174 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2175 "MultiVector _only_ implements view semantics. You may not call this "
2176 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2189 return Teuchos::View;
2212 Teuchos::RCP<MultiVector<T, LocalOrdinal, GlobalOrdinal, Node> >
2232 template <
class DS,
class DL,
class DG,
class DN,
2233 class SS,
class SL,
class SG,
class SN>
2260 template<
class SC,
class LO,
class GO,
class NT>
2261 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2300 const std::string& className,
2301 const Teuchos::EVerbosityLevel verbLevel =
2302 Teuchos::Describable::verbLevel_default)
const;
2305 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2312 Teuchos::ArrayRCP<T>
2346 virtual void copyAndPermute(
2348 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2350 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2354 virtual void copyAndPermute(
2356 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2358 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2366 const Kokkos::DualView<
2375 size_t& constantNumPackets,
2381 const Kokkos::DualView<
2390 size_t& constantNumPackets)
override;
2394 (
const Kokkos::DualView<
2403 const size_t constantNumPackets,
2409 (
const Kokkos::DualView<
2418 const size_t constantNumPackets,
2425 template<
class NO=Node>
2426 typename std::enable_if<std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2427 typename NO::device_type::memory_space>::value,
bool>::type
2428 reallocImportsIfNeededImpl (
const size_t newSize,
2430 const std::string* prefix,
2431 const bool areRemoteLIDsContiguous,
2436 template<
class NO=Node>
2437 typename std::enable_if<!std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2438 typename NO::device_type::memory_space>::value,
bool>::type
2439 reallocImportsIfNeededImpl (
const size_t newSize,
2441 const std::string* prefix,
2442 const bool areRemoteLIDsContiguous,
2449 const std::string* prefix,
2450 const bool areRemoteLIDsContiguous=
false,
2455 bool importsAreAliased();
2458 Kokkos::DualView<impl_scalar_type*, buffer_device_type> unaliased_imports_;
2463 template<
class SC,
class LO,
class GO,
class NT>
2464 Teuchos::ArrayView<const size_t>
2467 return X.whichVectors_ ();
2473 template <
class ST,
class LO,
class GO,
class NT>
2485 template <
class DS,
class DL,
class DG,
class DN,
2486 class SS,
class SL,
class SG,
class SN>
2491 using ::Tpetra::getMultiVectorWhichVectors;
2493 TEUCHOS_TEST_FOR_EXCEPTION(
2494 dst.getGlobalLength () != src.getGlobalLength () ||
2495 dst.getNumVectors () != src.getNumVectors (), std::invalid_argument,
2496 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2497 "objects do not match. src has dimensions [" << src.getGlobalLength ()
2498 <<
"," << src.getNumVectors () <<
"], and dst has dimensions ["
2499 << dst.getGlobalLength () <<
"," << dst.getNumVectors () <<
"].");
2502 TEUCHOS_TEST_FOR_EXCEPTION(
2503 dst.getLocalLength () != src.getLocalLength (), std::invalid_argument,
2504 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2505 "objects do not match. src has " << src.getLocalLength () <<
" row(s) "
2506 <<
" and dst has " << dst.getLocalLength () <<
" row(s).");
2508 const bool srcMostUpToDateOnDevice = ! src.need_sync_device ();
2510 if (src.isConstantStride () && dst.isConstantStride ()) {
2511 if (srcMostUpToDateOnDevice) {
2513 dst.getLocalViewDevice (Access::OverwriteAll),
2514 src.getLocalViewDevice (Access::ReadOnly));
2518 dst.getLocalViewDevice (Access::OverwriteAll),
2519 src.getLocalViewHost (Access::ReadOnly));
2523 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2524 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2526 if (srcMostUpToDateOnDevice) {
2528 src.getLocalViewDevice (Access::ReadOnly),
2529 dst.isConstantStride (),
2530 src.isConstantStride (),
2536 src.getLocalViewHost (Access::ReadOnly),
2537 dst.isConstantStride (),
2538 src.isConstantStride (),
2551 template<
class SC,
class LO,
class GO,
class NT>
2552 class TypeNameTraits<Tpetra::MultiVector<SC, LO, GO, NT> > {
2554 static std::string name () {
2555 return std::string (
"Tpetra::MultiVector<") +
2556 TypeNameTraits<SC>::name () +
"," +
2557 TypeNameTraits<LO>::name () +
"," +
2558 TypeNameTraits<GO>::name () +
"," +
2559 TypeNameTraits<NT>::name () +
">";
2569 #endif // TPETRA_MULTIVECTOR_DECL_HPP
typename map_type::global_ordinal_type global_ordinal_type
The type of global indices that this class uses.
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.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
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.
LocalOrdinal local_ordinal_type
The type of local indices.
typename device_type::execution_space execution_space
Type of the (new) Kokkos execution space.
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.
GlobalOrdinal global_ordinal_type
The type of global indices.
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
void meanValue(const Teuchos::ArrayView< impl_scalar_type > &means) const
Compute mean (average) value of each column.
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.
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 localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
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 replaceMap(const Teuchos::RCP< const map_type > &map)
Replace the underlying Map in place.
virtual size_t constantNumberOfPackets() const override
Number of packets to send per LID.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
typename map_type::device_type device_type
This class' preferred Kokkos device type.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string. ...
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
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.
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.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using local (row) index.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
std::remove_reference< decltype(std::declval< dual_view_type >).template view< 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 ...
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
size_t global_size_t
Global size_t object.
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.
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...
Insert new values that don't currently exist.
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.
wrapped_dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
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.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &src)
Copy the contents of src into *this (deep copy).
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
virtual bool reallocImportsIfNeeded(const size_t newSize, const bool verbose, const std::string *prefix, const bool areRemoteLIDsContiguous=false, const CombineMode CM=INSERT) override
Reallocate imports_ if needed.
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.
CombineMode
Rule for combining data in an Import or Export.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print the object with the given verbosity level to a FancyOStream.
Forward declaration of Tpetra::MultiVector.
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.
Scalar scalar_type
The type of each entry in the MultiVector.
Teuchos::RCP< MultiVector< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another MultiVector with the same entries, but converted to a different Scalar type T...
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.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
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.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, device_type > dual_view_type
Kokkos::DualView specialization used by this class.
virtual bool checkSizes(const SrcDistObject &sourceObj) override
Whether data redistribution between sourceObj and this object is legal.
void swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Swap contents of mv with contents of *this.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value)
Replace value in host memory, using global row index.
void randomize()
Set all values in the multivector to pseudorandom numbers.
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.
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...
virtual std::string description() const override
A simple one-line description of this object.
Teuchos::ArrayRCP< T > getSubArrayRCP(Teuchos::ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
Forward declaration of Tpetra::Vector.
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.
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.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
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...
Forward declaration of Tpetra::FEMultiVector.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
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.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
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.
A parallel distribution of indices over processes.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Map and their communicator.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
size_t getStride() const
Stride between columns in the multivector.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
void reduce()
Sum values of a locally replicated multivector across all processes.
wrapped_dual_view_type getWrappedDualView() const
Return the wrapped dual view holding this MultiVector's local data.
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.
typename DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
typename Node::device_type device_type
This class' Kokkos::Device specialization.
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 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.
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.
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.
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)
Node node_type
Legacy typedef that will go away at some point.
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
Forward declaration of Tpetra::Map.
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.