11 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
12 #define TPETRA_MULTIVECTOR_DECL_HPP
20 #include "Tpetra_DistObject.hpp"
23 #include "Kokkos_DualView.hpp"
24 #include "Teuchos_BLAS_types.hpp"
25 #include "Teuchos_DataAccess.hpp"
26 #include "Teuchos_Range1D.hpp"
27 #include "Kokkos_ArithTraits.hpp"
28 #include "Kokkos_InnerProductSpaceTraits.hpp"
29 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
30 #include "Tpetra_Access.hpp"
31 #include "Tpetra_Details_WrappedDualView.hpp"
32 #include <type_traits>
34 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 template<
class OrdinalType,
class ScalarType>
38 class SerialDenseMatrix;
40 #endif // DOXYGEN_SHOULD_SKIP_THIS
41 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
67 template <
class DS,
class DL,
class DG,
class DN,
68 class SS,
class SL,
class SG,
class SN>
70 deep_copy (MultiVector<DS, DL, DG, DN>& dst,
71 const MultiVector<SS, SL, SG, SN>& src);
73 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
74 template <
class ST,
class LO,
class GO,
class NT>
82 deep_copy (MultiVector<ST, LO, GO, NT>& dst,
83 const Teuchos::SerialDenseMatrix<int, ST>& src);
91 template <
class ST,
class LO,
class GO,
class NT>
93 deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
94 const MultiVector<ST, LO, GO, NT>& src);
95 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
104 template <
class ST,
class LO,
class GO,
class NT>
105 MultiVector<ST, LO, GO, NT>
106 createCopy (
const MultiVector<ST, LO, GO, NT>& src);
117 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
119 createMultiVector (
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node> >& map,
120 const size_t numVectors);
125 template<
class SC,
class LO,
class GO,
class NT>
126 Teuchos::ArrayView<const size_t>
127 getMultiVectorWhichVectors (
const MultiVector<SC, LO, GO, NT>& X);
349 template <
class Scalar,
354 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
378 typename Kokkos::ArithTraits<Scalar>::val_type;
397 typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
405 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
440 using host_view_type =
typename dual_view_type::t_host;
441 using device_view_type =
typename dual_view_type::t_dev;
456 MultiVector (
const Teuchos::RCP<const map_type>& map,
457 const size_t numVecs,
458 const bool zeroOut =
true);
471 const Teuchos::DataAccess copyOrView);
488 MultiVector (
const Teuchos::RCP<const map_type>& map,
489 const Teuchos::ArrayView<const Scalar>& A,
491 const size_t NumVectors);
506 MultiVector (
const Teuchos::RCP<const map_type>& map,
507 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
508 const size_t NumVectors);
522 MultiVector (
const Teuchos::RCP<const map_type>& map,
563 MultiVector (
const Teuchos::RCP<const map_type>& map,
564 const typename dual_view_type::t_dev& d_view);
588 MultiVector (
const Teuchos::RCP<const map_type>& map,
600 MultiVector (
const Teuchos::RCP<const map_type>& map,
632 MultiVector (
const Teuchos::RCP<const map_type>& map,
634 const Teuchos::ArrayView<const size_t>& whichVectors);
653 MultiVector (
const Teuchos::RCP<const map_type>& map,
655 const Teuchos::ArrayView<const size_t>& whichVectors);
685 MultiVector (
const Teuchos::RCP<const map_type>& map,
688 const Teuchos::ArrayView<const size_t>& whichVectors);
751 const Teuchos::RCP<const map_type>& subMap,
762 const size_t offset = 0);
813 #ifdef KOKKOS_ENABLE_SERIAL
814 ! std::is_same<execution_space, Kokkos::Serial>::value;
817 #endif // KOKKOS_ENABLE_SERIAL
887 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
954 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1030 template<
typename T>
1031 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1095 template<
typename T>
1096 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1116 template<
typename T>
1117 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1120 putScalar (static_cast<impl_scalar_type> (value));
1150 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1217 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1257 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1258 subCopy (
const Teuchos::Range1D& colRng)
const;
1261 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1262 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1265 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1266 subView (
const Teuchos::Range1D& colRng)
const;
1269 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1270 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1273 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1277 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1342 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1343 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1344 const size_t offset)
const;
1363 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1365 const size_t offset);
1368 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1372 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1376 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1389 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1390 const size_t LDA)
const;
1399 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1406 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1409 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1423 typename dual_view_type::t_host::const_type
getLocalViewHost(Access::ReadOnlyStruct)
const;
1431 typename dual_view_type::t_host
getLocalViewHost(Access::OverwriteAllStruct);
1435 typename dual_view_type::t_dev::const_type
getLocalViewDevice(Access::ReadOnlyStruct)
const;
1452 template<
class TargetDeviceType>
1454 return view_.getDualView().template need_sync<TargetDeviceType> ();
1491 template<
class TargetDeviceType>
1492 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type::const_type
1495 return view_.template getView<TargetDeviceType>(s);
1499 template<
class TargetDeviceType>
1500 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type
1503 return view_.template getView<TargetDeviceType>(s);
1506 template<
class TargetDeviceType>
1507 typename std::remove_reference<decltype(std::declval<dual_view_type>().
template view<TargetDeviceType>())>::type
1510 return view_.template getView<TargetDeviceType>(s);
1531 dot (
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
1532 const Teuchos::ArrayView<dot_type>& dots)
const;
1545 template <
typename T>
1546 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1548 const Teuchos::ArrayView<T> &dots)
const
1550 const size_t sz =
static_cast<size_t> (dots.size ());
1551 Teuchos::Array<dot_type> dts (sz);
1553 for (
size_t i = 0; i < sz; ++i) {
1560 template <
typename T>
1561 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1563 std::vector<T>& dots)
const
1565 const size_t sz = dots.size ();
1566 Teuchos::Array<dot_type> dts (sz);
1568 for (
size_t i = 0; i < sz; ++i) {
1593 const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms)
const;
1595 template<
class ViewType>
1597 dot (
typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1598 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1600 const ViewType& dots)
const {
1601 const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots(
"Tpetra::Dots",dots.extent(0));
1602 this->
dot (A, h_dots);
1619 template <
typename T>
1620 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1622 const Kokkos::View<T*, device_type>& dots)
const
1624 const size_t numDots = dots.extent (0);
1625 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1652 void scale (
const Scalar& alpha);
1662 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1672 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1683 scale (
const Scalar& alpha,
1693 update (
const Scalar& alpha,
1695 const Scalar& beta);
1704 update (
const Scalar& alpha,
1708 const Scalar& gamma);
1722 norm1 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1724 template<
class ViewType>
1725 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1726 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1727 norm1 (
const ViewType& norms)
const {
1731 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1732 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1733 this->
norm1 (h_norms);
1753 template <
typename T>
1754 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1755 norm1 (
const Kokkos::View<T*, device_type>& norms)
const
1757 const size_t numNorms = norms.extent (0);
1758 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1760 this->
norm1 (tmpNorms);
1773 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1789 template <
typename T>
1790 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1791 norm1 (
const Teuchos::ArrayView<T>& norms)
const
1793 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1794 const size_type sz = norms.size ();
1795 Teuchos::Array<mag_type> theNorms (sz);
1796 this->
norm1 (theNorms);
1797 for (size_type i = 0; i < sz; ++i) {
1799 norms[i] = theNorms[i];
1816 norm2 (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1818 template<
class ViewType>
1819 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1820 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1821 norm2 (
const ViewType& norms)
const {
1825 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1826 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1827 this->
norm2 (h_norms);
1845 template<
typename T>
1846 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1847 norm2 (
const Kokkos::View<T*, device_type>& norms)
const
1849 const size_t numNorms = norms.extent (0);
1850 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1852 this->
norm2 (theNorms);
1865 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1881 template <
typename T>
1882 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1883 norm2 (
const Teuchos::ArrayView<T>& norms)
const
1885 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1886 const size_type sz = norms.size ();
1887 Teuchos::Array<mag_type> theNorms (sz);
1888 this->
norm2 (theNorms);
1889 for (size_type i = 0; i < sz; ++i) {
1891 norms[i] = theNorms[i];
1901 void normInf (
const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms)
const;
1903 template<
class ViewType>
1904 typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1905 std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1906 normInf (
const ViewType& norms)
const {
1910 using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1911 host_norms_view_type h_norms (
"Tpetra::MV::h_norms", norms.extent (0));
1930 template<
typename T>
1931 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1932 normInf (
const Kokkos::View<T*, device_type>& norms)
const
1934 const size_t numNorms = norms.extent (0);
1935 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1951 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1968 template <
typename T>
1969 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1970 normInf (
const Teuchos::ArrayView<T>& norms)
const
1972 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1973 const size_type sz = norms.size ();
1974 Teuchos::Array<mag_type> theNorms (sz);
1975 this->
norm2 (theNorms);
1976 for (size_type i = 0; i < sz; ++i) {
1978 norms[i] = theNorms[i];
1987 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1989 template <
typename T>
1990 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1991 meanValue (
const Teuchos::ArrayView<T>& means)
const
1993 typedef typename Teuchos::Array<T>::size_type size_type;
1994 const size_type numMeans = means.size ();
1996 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1998 for (size_type k = 0; k < numMeans; ++k) {
1999 means[k] =
static_cast<T
> (theMeans[k]);
2010 Teuchos::ETransp transB,
2011 const Scalar& alpha,
2012 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2013 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2014 const Scalar& beta);
2038 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2039 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2069 bool aliases(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& other)
const;
2108 describe (Teuchos::FancyOStream& out,
2109 const Teuchos::EVerbosityLevel verbLevel =
2110 Teuchos::Describable::verbLevel_default)
const override;
2140 TEUCHOS_TEST_FOR_EXCEPTION(
2141 copyOrView == Teuchos::Copy, std::invalid_argument,
2142 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2143 "MultiVector _only_ implements view semantics. You may not call this "
2144 "method with copyOrView = Teuchos::Copy. The only valid argument is "
2157 return Teuchos::View;
2180 Teuchos::RCP<MultiVector<T, LocalOrdinal, GlobalOrdinal, Node> >
2200 template <
class DS,
class DL,
class DG,
class DN,
2201 class SS,
class SL,
class SG,
class SN>
2228 template<
class SC,
class LO,
class GO,
class NT>
2229 friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2268 const std::string& className,
2269 const Teuchos::EVerbosityLevel verbLevel =
2270 Teuchos::Describable::verbLevel_default)
const;
2273 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2280 Teuchos::ArrayRCP<T>
2314 virtual void copyAndPermute(
2316 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2318 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2322 virtual void copyAndPermute(
2324 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2326 const Kokkos::DualView<const local_ordinal_type *, buffer_device_type>
2334 const Kokkos::DualView<
2343 size_t& constantNumPackets,
2349 const Kokkos::DualView<
2358 size_t& constantNumPackets)
override;
2362 (
const Kokkos::DualView<
2371 const size_t constantNumPackets,
2377 (
const Kokkos::DualView<
2386 const size_t constantNumPackets,
2393 template<
class NO=Node>
2394 typename std::enable_if<std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2395 typename NO::device_type::memory_space>::value,
bool>::type
2396 reallocImportsIfNeededImpl (
const size_t newSize,
2398 const std::string* prefix,
2399 const bool areRemoteLIDsContiguous,
2404 template<
class NO=Node>
2405 typename std::enable_if<!std::is_same<typename Tpetra::Details::DefaultTypes::CommBufferMemorySpace<typename NO::execution_space>::type,
2406 typename NO::device_type::memory_space>::value,
bool>::type
2407 reallocImportsIfNeededImpl (
const size_t newSize,
2409 const std::string* prefix,
2410 const bool areRemoteLIDsContiguous,
2417 const std::string* prefix,
2418 const bool areRemoteLIDsContiguous=
false,
2423 bool importsAreAliased();
2426 Kokkos::DualView<impl_scalar_type*, buffer_device_type> unaliased_imports_;
2431 template<
class SC,
class LO,
class GO,
class NT>
2432 Teuchos::ArrayView<const size_t>
2435 return X.whichVectors_ ();
2441 template <
class ST,
class LO,
class GO,
class NT>
2453 template <
class DS,
class DL,
class DG,
class DN,
2454 class SS,
class SL,
class SG,
class SN>
2459 using ::Tpetra::getMultiVectorWhichVectors;
2461 TEUCHOS_TEST_FOR_EXCEPTION(
2462 dst.getGlobalLength () != src.getGlobalLength () ||
2463 dst.getNumVectors () != src.getNumVectors (), std::invalid_argument,
2464 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2465 "objects do not match. src has dimensions [" << src.getGlobalLength ()
2466 <<
"," << src.getNumVectors () <<
"], and dst has dimensions ["
2467 << dst.getGlobalLength () <<
"," << dst.getNumVectors () <<
"].");
2470 TEUCHOS_TEST_FOR_EXCEPTION(
2471 dst.getLocalLength () != src.getLocalLength (), std::invalid_argument,
2472 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2473 "objects do not match. src has " << src.getLocalLength () <<
" row(s) "
2474 <<
" and dst has " << dst.getLocalLength () <<
" row(s).");
2476 const bool srcMostUpToDateOnDevice = ! src.need_sync_device ();
2478 if (src.isConstantStride () && dst.isConstantStride ()) {
2479 if (srcMostUpToDateOnDevice) {
2481 dst.getLocalViewDevice (Access::OverwriteAll),
2482 src.getLocalViewDevice (Access::ReadOnly));
2486 dst.getLocalViewDevice (Access::OverwriteAll),
2487 src.getLocalViewHost (Access::ReadOnly));
2491 auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2492 auto srcWhichVecs = getMultiVectorWhichVectors (src);
2494 if (srcMostUpToDateOnDevice) {
2496 src.getLocalViewDevice (Access::ReadOnly),
2497 dst.isConstantStride (),
2498 src.isConstantStride (),
2504 src.getLocalViewHost (Access::ReadOnly),
2505 dst.isConstantStride (),
2506 src.isConstantStride (),
2519 template<
class SC,
class LO,
class GO,
class NT>
2520 class TypeNameTraits<Tpetra::MultiVector<SC, LO, GO, NT> > {
2522 static std::string name () {
2523 return std::string (
"Tpetra::MultiVector<") +
2524 TypeNameTraits<SC>::name () +
"," +
2525 TypeNameTraits<LO>::name () +
"," +
2526 TypeNameTraits<GO>::name () +
"," +
2527 TypeNameTraits<NT>::name () +
">";
2537 #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.