42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP 43 #define TPETRA_MULTIVECTOR_DECL_HPP 54 #include "Tpetra_DistObject.hpp" 56 #include "Kokkos_DualView.hpp" 57 #include "Teuchos_BLAS_types.hpp" 58 #include "Teuchos_DataAccess.hpp" 59 #include "Teuchos_Range1D.hpp" 60 #include "Kokkos_ArithTraits.hpp" 61 #include "Kokkos_InnerProductSpaceTraits.hpp" 62 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp" 63 #include <type_traits> 67 #ifndef DOXYGEN_SHOULD_SKIP_THIS 69 template<
class LO,
class GO,
class N>
class Map;
72 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class Vector;
75 template<
class S,
class LO,
class GO,
class N, const
bool classic>
class MultiVector;
76 #endif // DOXYGEN_SHOULD_SKIP_THIS 104 template<
class DstMultiVectorType,
class SrcMultiVectorType>
106 typedef DstMultiVectorType dst_mv_type;
107 typedef SrcMultiVectorType src_mv_type;
109 static Teuchos::RCP<dst_mv_type>
110 clone (
const src_mv_type& X,
111 const Teuchos::RCP<typename dst_mv_type::node_type>& node2);
136 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
137 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
149 template <
class ST,
class LO,
class GO,
class NT, const
bool classic = NT::
classic>
162 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
163 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
165 const size_t numVectors);
388 class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
390 const bool classic = Node::classic>
392 public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
394 static_assert (! classic,
"The 'classic' version of Tpetra was deprecated long ago, and has been removed.");
439 typedef typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type
dot_type;
447 typedef typename Kokkos::Details::ArithTraits<impl_scalar_type>::mag_type
mag_type;
498 MultiVector (
const Teuchos::RCP<const map_type>& map,
499 const size_t numVecs,
500 const bool zeroOut =
true);
514 const Teuchos::DataAccess copyOrView);
531 MultiVector (
const Teuchos::RCP<const map_type>& map,
532 const Teuchos::ArrayView<const Scalar>& A,
534 const size_t NumVectors);
549 MultiVector (
const Teuchos::RCP<const map_type>& map,
550 const Teuchos::ArrayView<
const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
551 const size_t NumVectors);
565 MultiVector (
const Teuchos::RCP<const map_type>& map,
606 MultiVector (
const Teuchos::RCP<const map_type>& map,
607 const typename dual_view_type::t_dev& d_view);
631 MultiVector (
const Teuchos::RCP<const map_type>& map,
652 MultiVector (
const Teuchos::RCP<const map_type>& map,
654 const Teuchos::ArrayView<const size_t>& whichVectors);
683 MultiVector (
const Teuchos::RCP<const map_type>& map,
686 const Teuchos::ArrayView<const size_t>& whichVectors);
748 const size_t offset = 0);
758 template <
class Node2>
759 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
760 clone (
const Teuchos::RCP<Node2>& node2)
const;
775 #ifdef KOKKOS_HAVE_SERIAL 776 ! std::is_same<execution_space, Kokkos::Serial>::value;
779 #endif // KOKKOS_HAVE_SERIAL 848 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
851 const T& value)
const 913 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
988 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1050 template<
typename T>
1051 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1071 template<
typename T>
1072 typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value,
void>::type
1075 putScalar (static_cast<impl_scalar_type> (value));
1105 void randomize (
const Scalar& minVal,
const Scalar& maxVal);
1172 void replaceMap (
const Teuchos::RCP<const map_type>& map);
1216 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1217 subCopy (
const Teuchos::Range1D& colRng)
const;
1220 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1221 subCopy (
const Teuchos::ArrayView<const size_t>& cols)
const;
1224 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1225 subView (
const Teuchos::Range1D& colRng)
const;
1228 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1229 subView (
const Teuchos::ArrayView<const size_t>& cols)
const;
1232 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1236 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1301 Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1302 offsetView (
const Teuchos::RCP<const map_type>& subMap,
1303 const size_t offset)
const;
1322 Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1324 const size_t offset);
1327 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1331 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
1335 Teuchos::ArrayRCP<const Scalar>
getData (
size_t j)
const;
1348 get1dCopy (
const Teuchos::ArrayView<Scalar>& A,
1349 const size_t LDA)
const;
1358 get2dCopy (
const Teuchos::ArrayView<
const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs)
const;
1365 Teuchos::ArrayRCP<const Scalar>
get1dView ()
const;
1368 Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> >
get2dView ()
const;
1414 template<
class TargetDeviceType>
1416 getDualView ().template sync<TargetDeviceType> ();
1420 template<
class TargetDeviceType>
1422 return getDualView ().template need_sync<TargetDeviceType> ();
1430 template<
class TargetDeviceType>
1432 getDualView ().template modify<TargetDeviceType> ();
1466 template<
class TargetDeviceType>
1467 typename Kokkos::Impl::if_c<
1469 typename device_type::memory_space,
1470 typename TargetDeviceType::memory_space>::value,
1471 typename dual_view_type::t_dev,
1472 typename dual_view_type::t_host>::type
1474 return getDualView ().template view<TargetDeviceType> ();
1496 const Teuchos::ArrayView<dot_type>& dots)
const;
1509 template <
typename T>
1510 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1512 const Teuchos::ArrayView<T> &dots)
const 1514 const size_t sz =
static_cast<size_t> (dots.size ());
1515 Teuchos::Array<dot_type> dts (sz);
1517 for (
size_t i = 0; i < sz; ++i) {
1524 template <
typename T>
1525 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1527 std::vector<T>& dots)
const 1529 const size_t sz = dots.size ();
1530 Teuchos::Array<dot_type> dts (sz);
1532 for (
size_t i = 0; i < sz; ++i) {
1557 const Kokkos::View<dot_type*, device_type>& dots)
const;
1571 template <
typename T>
1572 typename std::enable_if< ! (std::is_same<dot_type, T>::value),
void >::type
1574 const Kokkos::View<T*, device_type>& dots)
const 1576 const size_t numDots = dots.dimension_0 ();
1577 Kokkos::View<dot_type*, device_type> dts (
"MV::dot tmp", numDots);
1602 void scale (
const Scalar& alpha);
1612 void scale (
const Teuchos::ArrayView<const Scalar>& alpha);
1622 void scale (
const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1633 scale (
const Scalar& alpha,
1643 update (
const Scalar& alpha,
1645 const Scalar& beta);
1654 update (
const Scalar& alpha,
1658 const Scalar& gamma);
1671 void norm1 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1686 template <
typename T>
1687 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1688 norm1 (
const Kokkos::View<T*, device_type>& norms)
const 1690 const size_t numNorms = norms.dimension_0 ();
1691 Kokkos::View<mag_type*, device_type> tmpNorms (
"MV::norm1 tmp", numNorms);
1693 this->
norm1 (tmpNorms);
1708 void norm1 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1722 template <
typename T>
1723 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1724 norm1 (
const Teuchos::ArrayView<T>& norms)
const 1726 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1727 const size_type sz = norms.size ();
1728 Teuchos::Array<mag_type> theNorms (sz);
1729 this->
norm1 (theNorms);
1730 for (size_type i = 0; i < sz; ++i) {
1732 norms[i] = theNorms[i];
1748 void norm2 (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1761 template<
typename T>
1762 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1763 norm2 (
const Kokkos::View<T*, device_type>& norms)
const 1765 const size_t numNorms = norms.dimension_0 ();
1766 Kokkos::View<mag_type*, device_type> theNorms (
"MV::norm2 tmp", numNorms);
1768 this->
norm2 (theNorms);
1783 void norm2 (
const Teuchos::ArrayView<mag_type>& norms)
const;
1797 template <
typename T>
1798 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1799 norm2 (
const Teuchos::ArrayView<T>& norms)
const 1801 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1802 const size_type sz = norms.size ();
1803 Teuchos::Array<mag_type> theNorms (sz);
1804 this->
norm2 (theNorms);
1805 for (size_type i = 0; i < sz; ++i) {
1807 norms[i] = theNorms[i];
1817 void normInf (
const Kokkos::View<mag_type*, device_type>& norms)
const;
1830 template<
typename T>
1831 typename std::enable_if< ! (std::is_same<mag_type, T>::value),
void >::type
1832 normInf (
const Kokkos::View<T*, device_type>& norms)
const 1834 const size_t numNorms = norms.dimension_0 ();
1835 Kokkos::View<mag_type*, device_type> theNorms (
"MV::normInf tmp", numNorms);
1851 void normInf (
const Teuchos::ArrayView<mag_type>& norms)
const;
1865 template <
typename T>
1866 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1867 normInf (
const Teuchos::ArrayView<T>& norms)
const 1869 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1870 const size_type sz = norms.size ();
1871 Teuchos::Array<mag_type> theNorms (sz);
1872 this->
norm2 (theNorms);
1873 for (size_type i = 0; i < sz; ++i) {
1875 norms[i] = theNorms[i];
1885 void TPETRA_DEPRECATED
1887 const Teuchos::ArrayView<mag_type>& norms)
const;
1905 template <
typename T>
1906 typename std::enable_if< ! (std::is_same<mag_type,T>::value),
void >::type
1909 const Teuchos::ArrayView<T>& norms)
const 1911 typedef typename Teuchos::ArrayView<T>::size_type size_type;
1912 const size_type sz = norms.size ();
1913 Teuchos::Array<mag_type> theNorms (sz);
1915 for (size_type i = 0; i < sz; ++i) {
1917 norms[i] = theNorms[i];
1925 void meanValue (
const Teuchos::ArrayView<impl_scalar_type>& means)
const;
1927 template <
typename T>
1928 typename std::enable_if<! std::is_same<impl_scalar_type, T>::value,
void>::type
1929 meanValue (
const Teuchos::ArrayView<T>& means)
const 1931 typedef typename Teuchos::Array<T>::size_type size_type;
1932 const size_type numMeans = means.size ();
1934 Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1936 for (size_type k = 0; k < numMeans; ++k) {
1937 means[k] =
static_cast<T
> (theMeans[k]);
1948 Teuchos::ETransp transB,
1949 const Scalar& alpha,
1950 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>& A,
1951 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>& B,
1952 const Scalar& beta);
1976 const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>& A,
1977 const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>& B,
2041 describe (Teuchos::FancyOStream& out,
2042 const Teuchos::EVerbosityLevel verbLevel =
2043 Teuchos::Describable::verbLevel_default)
const;
2073 TEUCHOS_TEST_FOR_EXCEPTION(
2074 copyOrView == Teuchos::Copy, std::invalid_argument,
2075 "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of " 2076 "MultiVector _only_ implements view semantics. You may not call this " 2077 "method with copyOrView = Teuchos::Copy. The only valid argument is " 2092 return Teuchos::View;
2113 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2114 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2190 normImpl (
const Kokkos::View<mag_type*, device_type>& norms,
2230 const std::string& className,
2231 const Teuchos::EVerbosityLevel verbLevel =
2232 Teuchos::Describable::verbLevel_default)
const;
2235 bool vectorIndexOutOfRange (
const size_t VectorIndex)
const;
2242 Teuchos::ArrayRCP<T>
2270 const size_t numSameIDs,
2271 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteToLIDs,
2272 const Kokkos::DualView<const local_ordinal_type*, device_type>& permuteFromLIDs);
2276 const Kokkos::DualView<const local_ordinal_type*, device_type>& exportLIDs,
2277 Kokkos::DualView<impl_scalar_type*, device_type>& exports,
2278 const Kokkos::DualView<size_t*, device_type>& ,
2279 size_t& constantNumPackets,
2283 unpackAndCombineNew (
const Kokkos::DualView<const LocalOrdinal*, device_type>& importLIDs,
2284 const Kokkos::DualView<const impl_scalar_type*, device_type>& imports,
2285 const Kokkos::DualView<const size_t*, device_type>& ,
2286 const size_t constantNumPackets,
2294 template<
class DstMultiVectorType,
2295 class SrcMultiVectorType>
2296 Teuchos::RCP<typename MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::dst_mv_type>
2297 MultiVectorCloner<DstMultiVectorType, SrcMultiVectorType>::
2298 clone (
const src_mv_type& X,
2299 const Teuchos::RCP<typename dst_mv_type::node_type>& node2)
2302 typedef typename src_mv_type::map_type src_map_type;
2303 typedef typename dst_mv_type::map_type dst_map_type;
2304 typedef typename dst_mv_type::node_type dst_node_type;
2305 typedef typename dst_mv_type::dual_view_type dst_dual_view_type;
2308 RCP<const src_map_type> map1 = X.getMap ();
2309 RCP<const dst_map_type> map2 = map1.is_null () ?
2310 Teuchos::null : map1->template clone<dst_node_type> (node2);
2312 const size_t lclNumRows = X.getLocalLength ();
2313 const size_t numCols = X.getNumVectors ();
2314 dst_dual_view_type Y_view (
"MV::dual_view", lclNumRows, numCols);
2316 RCP<dst_mv_type> Y (
new dst_mv_type (map2, Y_view));
2326 template <
class ST,
class LO,
class GO,
class NT, const
bool classic>
2338 template <
class DS,
class DL,
class DG,
class DN,
const bool dstClassic,
2339 class SS,
class SL,
class SG,
class SN,
const bool srcClassic>
2344 typedef typename DN::device_type DD;
2347 TEUCHOS_TEST_FOR_EXCEPTION(
2350 "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector " 2351 "objects do not match. src has dimensions [" << src.
getGlobalLength ()
2352 <<
"," << src.
getNumVectors () <<
"], and dst has dimensions [" 2356 TEUCHOS_TEST_FOR_EXCEPTION(
2358 "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector " 2359 "objects do not match. src has " << src.
getLocalLength () <<
" row(s) " 2367 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2369 if (! useHostVersion) {
2371 dst.template modify<DES> ();
2373 Details::localDeepCopyConstStride (dst.template getLocalView<DES> (),
2374 src.template getLocalView<typename SN::device_type> ());
2375 dst.template sync<HES> ();
2378 dst.template modify<HES> ();
2380 Details::localDeepCopyConstStride (dst.template getLocalView<Kokkos::HostSpace> (),
2381 src.template getLocalView<Kokkos::HostSpace> ());
2382 dst.template sync<DES> ();
2386 typedef Kokkos::DualView<SL*, DD> whichvecs_type;
2387 typedef typename whichvecs_type::t_dev::execution_space DES;
2388 typedef typename whichvecs_type::t_host::execution_space HES;
2391 const SL numWhichVecs =
static_cast<SL
> (src.
whichVectors_.size ());
2392 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2399 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2401 if (! useHostVersion) {
2404 whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2405 whichVecs.template modify<HES> ();
2406 for (SL i = 0; i < numWhichVecs; ++i) {
2407 whichVecs.h_view(i) =
static_cast<SL
> (src.
whichVectors_[i]);
2410 whichVecs.template sync<DES> ();
2413 dst.template modify<DES> ();
2415 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2416 src.template getLocalView<typename SN::device_type> (),
2423 dst.template sync<HES> ();
2430 typedef Kokkos::View<SL*, HES> the_whichvecs_type;
2431 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2432 for (SL i = 0; i < numWhichVecs; ++i) {
2438 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2439 src.template getLocalView<Kokkos::HostSpace> (),
2442 whichVecs, whichVecs);
2444 dst.template sync<DES> ();
2451 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2453 if (! useHostVersion) {
2456 typedef Kokkos::DualView<DL*, DES> the_whichvecs_type;
2457 const std::string whichVecsLabel (
"MV::deep_copy::whichVecs");
2458 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2459 the_whichvecs_type whichVecs (whichVecsLabel, numWhichVecs);
2460 whichVecs.template modify<HES> ();
2461 for (DL i = 0; i < numWhichVecs; ++i) {
2465 whichVecs.template sync<DES> ();
2468 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2469 src.template getLocalView<typename SN::device_type> (),
2479 dst.template sync<HES> ();
2486 typedef Kokkos::View<DL*, HES> the_whichvecs_type;
2487 const DL numWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2488 the_whichvecs_type whichVecs (
"MV::deep_copy::whichVecs", numWhichVecs);
2489 for (DL i = 0; i < numWhichVecs; ++i) {
2493 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2494 src.template getLocalView<Kokkos::HostSpace> (),
2497 whichVecs, whichVecs);
2502 dst.template sync<DES> ();
2508 const bool useHostVersion = src.template need_sync<typename SN::device_type> ();
2510 if (! useHostVersion) {
2513 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2514 Kokkos::DualView<DL*, DES> whichVecsDst (
"MV::deep_copy::whichVecsDst",
2516 whichVecsDst.template modify<HES> ();
2517 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2518 whichVecsDst.h_view(i) =
static_cast<DL
> (dst.
whichVectors_[i]);
2521 whichVecsDst.template sync<DES> ();
2527 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2528 Kokkos::DualView<DL*, DES> whichVecsSrc (
"MV::deep_copy::whichVecsSrc",
2530 whichVecsSrc.template modify<HES> ();
2531 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2532 whichVecsSrc.h_view(i) =
static_cast<DL
> (src.
whichVectors_[i]);
2535 whichVecsSrc.template sync<DES> ();
2539 Details::localDeepCopy (dst.template getLocalView<typename DN::device_type> (),
2540 src.template getLocalView<typename SN::device_type> (),
2543 whichVecsDst.d_view,
2544 whichVecsSrc.d_view);
2547 const DL dstNumWhichVecs =
static_cast<DL
> (dst.
whichVectors_.size ());
2548 Kokkos::View<DL*, HES> whichVectorsDst (
"dstWhichVecs", dstNumWhichVecs);
2549 for (DL i = 0; i < dstNumWhichVecs; ++i) {
2554 const DL srcNumWhichVecs =
static_cast<DL
> (src.
whichVectors_.size ());
2555 Kokkos::View<DL*, HES> whichVectorsSrc (
"srcWhichVecs", srcNumWhichVecs);
2556 for (DL i = 0; i < srcNumWhichVecs; ++i) {
2562 Details::localDeepCopy (dst.template getLocalView<Kokkos::HostSpace> (),
2563 src.template getLocalView<Kokkos::HostSpace> (),
2566 whichVectorsDst, whichVectorsSrc);
2572 dst.template sync<HES> ();
2585 template<
class SC,
class LO,
class GO,
class NT, const
bool classic>
2586 class TypeNameTraits<
Tpetra::MultiVector<SC, LO, GO, NT, classic> > {
2588 static std::string name () {
2589 return std::string (
"Tpetra::MultiVector<") +
2590 TypeNameTraits<SC>::name () +
"," +
2591 TypeNameTraits<LO>::name () +
"," +
2592 TypeNameTraits<GO>::name () +
"," +
2593 TypeNameTraits<NT>::name () +
">";
2603 #endif // TPETRA_MULTIVECTOR_DECL_HPP void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
void TPETRA_DEPRECATED normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &weights, const Teuchos::ArrayView< mag_type > &norms) const
Compute Weighted 2-norm (RMS Norm) of each column.
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 normInf(const Kokkos::View< mag_type *, device_type > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a device view...
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > offsetView(const Teuchos::RCP< const map_type > &subMap, const size_t offset) const
Return a const view of a subset of rows.
Node node_type
This class' fourth template parameter; the Kokkos Node type.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > subViewNonConst(const Teuchos::Range1D &colRng)
Return a MultiVector with views of selected columns.
size_t getStride() const
Stride between columns in the multivector.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Teuchos::RCP< Node2 > &node2) const
Return a deep copy of this MultiVector, with a different Node type.
dual_view_type getDualView() const
Get the Kokkos::DualView which implements local storage.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
void sync()
Update data on device or host only if data in the other space has been marked as modified.
Teuchos::ArrayRCP< T > getSubArrayRCP(Teuchos::ArrayRCP< T > arr, size_t j) const
Persisting view of j-th column in the given ArrayRCP.
friend void deep_copy(MultiVector< DS, DL, DG, DN, dstClassic > &dst, const MultiVector< SS, SL, SG, SN, srcClassic > &src)
Copy the contents of the MultiVector src into dst.
void sumIntoGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value, const bool atomic=useAtomicUpdatesByDefault) const
Update (+=) a value in host memory, using global row index.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Map and their communicator.
Teuchos::RCP< const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > subView(const Teuchos::Range1D &colRng) const
Return a const MultiVector with const views of selected columns.
MultiVector< ST, LO, GO, NT, classic > createCopy(const MultiVector< ST, LO, GO, NT, classic > &src)
Return a deep copy of the given MultiVector.
Kokkos::Impl::if_c< std::is_same< typename device_type::memory_space, typename TargetDeviceType::memory_space >::value, typename dual_view_type::t_dev, typename dual_view_type::t_host >::type getLocalView() const
Return a view of the local data on a specific device.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
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.
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A, const Teuchos::ArrayView< dot_type > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this)
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.
One or more distributed dense vectors.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
void deep_copy(MultiVector< ST, LO, GO, NT, classic > &dst, const MultiVector< ST, LO, GO, NT, classic > &src)
Specialization of deep_copy for MultiVector objects with the same template parameters.
void deep_copy(MultiVector< DS, DL, DG, DN, dstClassic > &dst, const MultiVector< SS, SL, SG, SN, srcClassic > &src)
Copy the contents of the MultiVector src into dst.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > getVector(const size_t j) const
Return a Vector which is a const view of column j.
Node::device_type device_type
The Kokkos device type.
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.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The type of the Map specialization used by this class.
virtual void unpackAndCombineNew(const Kokkos::DualView< const LocalOrdinal *, device_type > &importLIDs, const Kokkos::DualView< const impl_scalar_type *, device_type > &imports, const Kokkos::DualView< const size_t *, device_type > &, const size_t constantNumPackets, Distributor &, const CombineMode CM)
Perform any unpacking and combining after communication (new version that uses Kokkos data structures...
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > offsetViewNonConst(const Teuchos::RCP< const map_type > &subMap, const size_t offset)
Return a nonconst view of a subset of rows.
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) const
Like the above sumIntoGlobalValue, but only enabled if T differs from impl_scalar_type.
void randomize()
Set all values in the multivector to pseudorandom numbers.
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
dual_view_type view_
The Kokkos::DualView containing the MultiVector's data.
Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< const Scalar > > get2dView() const
Return const persisting pointers to values.
virtual bool useNewInterface()
Whether this class implements the old or new interface of DistObject.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > 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 modify()
Mark data as modified on the given device TargetDeviceType.
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 replaceMap(const Teuchos::RCP< const map_type > &map)
Replace the underlying Map in place.
Implementation details of Tpetra.
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.
void norm2(const Kokkos::View< mag_type *, device_type > &norms) const
Compute the two-norm of each vector (column), storing the result in a device view.
void reduce()
Sum values of a locally replicated multivector across all processes.
size_t global_size_t
Global size_t object.
Declarations for the Tpetra::Map class and related nonmember constructors.
void sumIntoLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &val, const bool atomic=useAtomicUpdatesByDefault) const
Update (+=) a value in host memory, using local row index.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process' verbose describe() information to the returned string. ...
Scalar scalar_type
This class' first template parameter; the type of each entry in the MultiVector.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
Teuchos::ArrayRCP< const Scalar > get1dView() const
Const persisting (1-D) view of this multivector's local values.
size_t getLocalLength() const
Local number of rows on the calling process.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
Node::execution_space execution_space
Type of the (new) Kokkos execution space.
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &source)
Shallow copy: assign source to *this.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using local (row) index.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
Abstract base class for objects that can be the source of an Import or Export operation.
double scalar_type
Default value of Scalar template parameter.
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector's local values.
void normImpl(const Kokkos::View< mag_type *, device_type > &norms, const EWhichNorm whichNorm) const
Compute the norm of each vector (column), storing the result in a device View.
void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
void meanValue(const Teuchos::ArrayView< impl_scalar_type > &means) const
Compute mean (average) value of each column.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
virtual ~MultiVector()
Destructor (virtual for memory safety of derived classes).
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) const
Like the above sumIntoLocalValue, but only enabled if T differs from impl_scalar_type.
Implementation of Tpetra::MultiVector::clone().
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, typename execution_space::execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
Describes a parallel distribution of objects over processes.
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) const
Like the above replaceGlobalValue, but only enabled if T differs from impl_scalar_type.
size_t getNumVectors() const
Number of columns in the multivector.
virtual std::string description() const
A simple one-line description of this object.
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) const
Like the above replaceLocalValue, but only enabled if T differs from impl_scalar_type.
void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &src)
Copy the contents of src into *this (deep copy).
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
size_t getOrigNumLocalRows() const
"Original" number of rows in the (local) data.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
EWhichNorm
Input argument for normImpl() (which see).
size_t getOrigNumLocalCols() const
"Original" number of columns in the (local) data.
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > getVectorNonConst(const size_t j)
Return a Vector which is a nonconst view of column j.
void norm1(const Kokkos::View< mag_type *, device_type > &norms) const
Compute the one-norm of each vector (column), storing the result in a device view.
Base class for distributed Tpetra objects that support data redistribution.
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
GlobalOrdinal global_ordinal_type
This class' third template parameter; the type of global indices.
dual_view_type origView_
The "original view" of the MultiVector's data.
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using global row index.