Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_MultiVector_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_MULTIVECTOR_DECL_HPP
43 #define TPETRA_MULTIVECTOR_DECL_HPP
44 
53 
55 #include "Tpetra_Vector_fwd.hpp"
57 #include "Tpetra_DistObject.hpp"
58 #include "Tpetra_Map_fwd.hpp"
59 #include "Kokkos_DualView.hpp"
60 #include "Teuchos_BLAS_types.hpp"
61 #include "Teuchos_DataAccess.hpp"
62 #include "Teuchos_Range1D.hpp"
63 #include "Kokkos_ArithTraits.hpp"
64 #include "Kokkos_InnerProductSpaceTraits.hpp"
65 #include "Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp"
66 #include <type_traits>
67 
68 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70 namespace Teuchos {
71  template<class OrdinalType, class ScalarType>
72  class SerialDenseMatrix; // forward declaration
73 }
74 #endif // DOXYGEN_SHOULD_SKIP_THIS
75 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
76 
77 namespace Tpetra {
78 
79 
100  template <class DS, class DL, class DG, class DN,
101  class SS, class SL, class SG, class SN>
102  void
103  deep_copy (MultiVector<DS, DL, DG, DN>& dst,
104  const MultiVector<SS, SL, SG, SN>& src);
105 
106 #ifdef HAVE_TPETRACORE_TEUCHOSNUMERICS
107  template <class ST, class LO, class GO, class NT>
114  void
115  deep_copy (MultiVector<ST, LO, GO, NT>& dst,
116  const Teuchos::SerialDenseMatrix<int, ST>& src);
117 
124  template <class ST, class LO, class GO, class NT>
125  void
126  deep_copy (Teuchos::SerialDenseMatrix<int, ST>& dst,
127  const MultiVector<ST, LO, GO, NT>& src);
128 #endif // HAVE_TPETRACORE_TEUCHOSNUMERICS
129 
137  template <class ST, class LO, class GO, class NT>
138  MultiVector<ST, LO, GO, NT>
139  createCopy (const MultiVector<ST, LO, GO, NT>& src);
140 
150  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
151  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
152  createMultiVector (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map,
153  const size_t numVectors);
154 
155  // WARNING NOT FOR USERS
156  // This means we don't need to make MultiVector a friend of
157  // Vector or of itself (with different template parameters).
158  template<class SC, class LO, class GO, class NT>
159  Teuchos::ArrayView<const size_t>
160  getMultiVectorWhichVectors (const MultiVector<SC, LO, GO, NT>& X);
161 
381  template <class Scalar,
382  class LocalOrdinal,
383  class GlobalOrdinal,
384  class Node>
385  class MultiVector :
386  public DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>
387  {
388  public:
390 
391 
393  using scalar_type = Scalar;
409  using impl_scalar_type =
410  typename Kokkos::Details::ArithTraits<Scalar>::val_type;
411 
421  using node_type = typename map_type::node_type;
422 
428  using dot_type =
429  typename Kokkos::Details::InnerProductSpaceTraits<impl_scalar_type>::dot_type;
430 
437  using mag_type = typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
438 
443  using execution_space = typename device_type::execution_space;
444 
467  using dual_view_type = Kokkos::DualView<impl_scalar_type**,
468  Kokkos::LayoutLeft,
470 
472 
474 
476  MultiVector ();
477 
484  MultiVector (const Teuchos::RCP<const map_type>& map,
485  const size_t numVecs,
486  const bool zeroOut = true);
487 
499  const Teuchos::DataAccess copyOrView);
500 
516  MultiVector (const Teuchos::RCP<const map_type>& map,
517  const Teuchos::ArrayView<const Scalar>& A,
518  const size_t LDA,
519  const size_t NumVectors);
520 
534  MultiVector (const Teuchos::RCP<const map_type>& map,
535  const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> >&ArrayOfPtrs,
536  const size_t NumVectors);
537 
550  MultiVector (const Teuchos::RCP<const map_type>& map,
551  const dual_view_type& view);
552 
591  MultiVector (const Teuchos::RCP<const map_type>& map,
592  const typename dual_view_type::t_dev& d_view);
593 
616  MultiVector (const Teuchos::RCP<const map_type>& map,
617  const dual_view_type& view,
618  const dual_view_type& origView);
619 
620  protected:
621 
627  const size_t j);
628 
629  public:
630 
648  MultiVector (const Teuchos::RCP<const map_type>& map,
649  const dual_view_type& view,
650  const Teuchos::ArrayView<const size_t>& whichVectors);
651 
679  MultiVector (const Teuchos::RCP<const map_type>& map,
680  const dual_view_type& view,
681  const dual_view_type& origView,
682  const Teuchos::ArrayView<const size_t>& whichVectors);
683 
745  const Teuchos::RCP<const map_type>& subMap,
746  const local_ordinal_type rowOffset = 0);
747 
755  const map_type& subMap,
756  const size_t offset = 0);
757 
767 
770 
778 
782 
792  virtual ~MultiVector () = default;
793 
796 
798 
800 
801  protected:
806  static const bool useAtomicUpdatesByDefault =
807 #ifdef KOKKOS_ENABLE_SERIAL
808  ! std::is_same<execution_space, Kokkos::Serial>::value;
809 #else
810  true;
811 #endif // KOKKOS_ENABLE_SERIAL
812 
813  public:
842  void
843  replaceGlobalValue (const GlobalOrdinal gblRow,
844  const size_t col,
845  const impl_scalar_type& value) const;
846 
879  template<typename T>
880  typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value, void>::type
881  replaceGlobalValue (GlobalOrdinal globalRow,
882  size_t col,
883  const T& value) const
884  {
885  replaceGlobalValue (globalRow, col, static_cast<impl_scalar_type> (value));
886  }
887 
911  void
912  sumIntoGlobalValue (const GlobalOrdinal gblRow,
913  const size_t col,
914  const impl_scalar_type& value,
915  const bool atomic = useAtomicUpdatesByDefault) const;
916 
944  template<typename T>
945  typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value, void>::type
946  sumIntoGlobalValue (const GlobalOrdinal gblRow,
947  const size_t col,
948  const T& val,
949  const bool atomic = useAtomicUpdatesByDefault) const
950  {
951  sumIntoGlobalValue (gblRow, col, static_cast<impl_scalar_type> (val), atomic);
952  }
953 
982  void
983  replaceLocalValue (const LocalOrdinal lclRow,
984  const size_t col,
985  const impl_scalar_type& value) const;
986 
1019  template<typename T>
1020  typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value, void>::type
1021  replaceLocalValue (const LocalOrdinal lclRow,
1022  const size_t col,
1023  const T& val) const
1024  {
1025  replaceLocalValue (lclRow, col, static_cast<impl_scalar_type> (val));
1026  }
1027 
1051  void
1052  sumIntoLocalValue (const LocalOrdinal lclRow,
1053  const size_t col,
1054  const impl_scalar_type& val,
1055  const bool atomic = useAtomicUpdatesByDefault) const;
1056 
1082  template<typename T>
1083  typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value, void>::type
1084  sumIntoLocalValue (const LocalOrdinal lclRow,
1085  const size_t col,
1086  const T& val,
1087  const bool atomic = useAtomicUpdatesByDefault) const
1088  {
1089  sumIntoLocalValue (lclRow, col, static_cast<impl_scalar_type> (val), atomic);
1090  }
1091 
1093  void putScalar (const Scalar& value);
1094 
1103  template<typename T>
1104  typename std::enable_if<! std::is_same<T, impl_scalar_type>::value && std::is_convertible<T, impl_scalar_type>::value, void>::type
1105  putScalar (const T& value)
1106  {
1107  putScalar (static_cast<impl_scalar_type> (value));
1108  }
1109 
1122  void randomize();
1123 
1137  void randomize (const Scalar& minVal, const Scalar& maxVal);
1138 
1204  void replaceMap (const Teuchos::RCP<const map_type>& map);
1205 
1212  void reduce();
1213 
1215 
1241 
1242 
1244  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1245  subCopy (const Teuchos::Range1D& colRng) const;
1246 
1248  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1249  subCopy (const Teuchos::ArrayView<const size_t>& cols) const;
1250 
1252  Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1253  subView (const Teuchos::Range1D& colRng) const;
1254 
1256  Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1257  subView (const Teuchos::ArrayView<const size_t>& cols) const;
1258 
1260  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1261  subViewNonConst (const Teuchos::Range1D& colRng);
1262 
1264  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1265  subViewNonConst (const Teuchos::ArrayView<const size_t>& cols);
1266 
1329  Teuchos::RCP<const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1330  offsetView (const Teuchos::RCP<const map_type>& subMap,
1331  const size_t offset) const;
1332 
1350  Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1351  offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
1352  const size_t offset);
1353 
1355  Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1356  getVector (const size_t j) const;
1357 
1359  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
1360  getVectorNonConst (const size_t j);
1361 
1363  Teuchos::ArrayRCP<const Scalar> getData (size_t j) const;
1364 
1366  Teuchos::ArrayRCP<Scalar> getDataNonConst (size_t j);
1367 
1375  void
1376  get1dCopy (const Teuchos::ArrayView<Scalar>& A,
1377  const size_t LDA) const;
1378 
1385  void
1386  get2dCopy (const Teuchos::ArrayView<const Teuchos::ArrayView<Scalar> >& ArrayOfPtrs) const;
1387 
1393  Teuchos::ArrayRCP<const Scalar> get1dView () const;
1394 
1396  Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > get2dView () const;
1397 
1403  Teuchos::ArrayRCP<Scalar> get1dViewNonConst ();
1404 
1406  Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > get2dViewNonConst ();
1407 
1408 
1410  void clear_sync_state ();
1411 
1430  template<class TargetDeviceType>
1431  void sync () {
1432  view_.template sync<TargetDeviceType> ();
1433  }
1434 
1436  void sync_host ();
1437 
1439  void sync_device ();
1440 
1442  template<class TargetDeviceType>
1443  bool need_sync () const {
1444  return view_.template need_sync<TargetDeviceType> ();
1445  }
1446 
1448  bool need_sync_host () const;
1449 
1451  bool need_sync_device () const;
1452 
1458  template<class TargetDeviceType>
1459  void modify () {
1460  view_.template modify<TargetDeviceType> ();
1461  }
1462 
1464  void modify_device ();
1465 
1467  void modify_host ();
1468 
1500  template<class TargetDeviceType>
1501  typename Kokkos::Impl::if_c<
1502  std::is_same<
1503  typename device_type::memory_space,
1504  typename TargetDeviceType::memory_space>::value,
1505  typename dual_view_type::t_dev,
1506  typename dual_view_type::t_host>::type
1507  getLocalView () const {
1508  return view_.template view<TargetDeviceType> ();
1509  }
1510 
1512  typename dual_view_type::t_host getLocalViewHost () const;
1513 
1515  typename dual_view_type::t_dev getLocalViewDevice () const;
1516 
1518 
1520 
1534  void
1536  const Teuchos::ArrayView<dot_type>& dots) const;
1537 
1549  template <typename T>
1550  typename std::enable_if< ! (std::is_same<dot_type, T>::value), void >::type
1552  const Teuchos::ArrayView<T> &dots) const
1553  {
1554  const size_t sz = static_cast<size_t> (dots.size ());
1555  Teuchos::Array<dot_type> dts (sz);
1556  this->dot (A, dts);
1557  for (size_t i = 0; i < sz; ++i) {
1558  // If T and dot_type differ, this does an implicit conversion.
1559  dots[i] = dts[i];
1560  }
1561  }
1562 
1564  template <typename T>
1565  typename std::enable_if< ! (std::is_same<dot_type, T>::value), void >::type
1567  std::vector<T>& dots) const
1568  {
1569  const size_t sz = dots.size ();
1570  Teuchos::Array<dot_type> dts (sz);
1571  this->dot (A, dts);
1572  for (size_t i = 0; i < sz; ++i) {
1573  // If T and dot_type differ, this does an implicit conversion.
1574  dots[i] = dts[i];
1575  }
1576  }
1577 
1595  void
1597  const Kokkos::View<dot_type*, Kokkos::HostSpace>& norms) const;
1598 
1599  template<class ViewType>
1600  void
1601  dot (typename std::enable_if<std::is_same<typename ViewType::value_type,dot_type>::value &&
1602  std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value,
1604  const ViewType& dots) const {
1605  const Kokkos::View<dot_type*, Kokkos::HostSpace> h_dots("Tpetra::Dots",dots.extent(0));
1606  this->dot (A, h_dots);
1607  Kokkos::deep_copy(dots,h_dots);
1608  }
1609 
1622  template <typename T>
1623  typename std::enable_if< ! (std::is_same<dot_type, T>::value), void >::type
1625  const Kokkos::View<T*, device_type>& dots) const
1626  {
1627  const size_t numDots = dots.extent (0);
1628  Kokkos::View<dot_type*, device_type> dts ("MV::dot tmp", numDots);
1629  // Call overload that takes a Kokkos::View<dot_type*, device_type>.
1630  this->dot (A, dts);
1631  // FIXME (mfh 14 Jul 2014) Does this actually work if dot_type
1632  // and T differ? We would need a test for this, but only the
1633  // Sacado and Stokhos packages are likely to care about this use
1634  // case. It could also come up for Kokkos::complex ->
1635  // std::complex conversions, but those two implementations
1636  // should generally be bitwise compatible.
1637  // CT: no this can't possible work .....
1638  Kokkos::deep_copy (dots, dts);
1639  }
1640 
1643 
1646 
1654  void scale (const Scalar& alpha);
1655 
1664  void scale (const Teuchos::ArrayView<const Scalar>& alpha);
1665 
1674  void scale (const Kokkos::View<const impl_scalar_type*, device_type>& alpha);
1675 
1684  void
1685  scale (const Scalar& alpha,
1687 
1694  void
1695  update (const Scalar& alpha,
1697  const Scalar& beta);
1698 
1705  void
1706  update (const Scalar& alpha,
1708  const Scalar& beta,
1710  const Scalar& gamma);
1711 
1723  void
1724  norm1 (const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms) const;
1725 
1726  template<class ViewType>
1727  typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1728  std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1729  norm1 (const ViewType& norms) const {
1730  // FIXME (mfh 11 Apr 2019) The enable_ifs make it useless for
1731  // this method to be templated. (It only exists in case
1732  // HostSpace = device_type::memory_space.)
1733  using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1734  host_norms_view_type h_norms ("Tpetra::MV::h_norms", norms.extent (0));
1735  this->norm1 (h_norms);
1736  Kokkos::deep_copy (norms, h_norms);
1737  }
1738 
1754  template <typename T>
1755  typename std::enable_if< ! (std::is_same<mag_type, T>::value), void >::type
1756  norm1 (const Kokkos::View<T*, device_type>& norms) const
1757  {
1758  const size_t numNorms = norms.extent (0);
1759  Kokkos::View<mag_type*, device_type> tmpNorms ("MV::norm1 tmp", numNorms);
1760  // Call overload that takes a Kokkos::View<mag_type*, device_type>.
1761  this->norm1 (tmpNorms);
1762  // FIXME (mfh 15 Jul 2014) Does this actually work if mag_type
1763  // and T differ? We would need a test for this, but only the
1764  // Sacado and Stokhos packages are likely to care about this use
1765  // case. It could also come up with Kokkos::complex ->
1766  // std::complex conversion.
1767  Kokkos::deep_copy (norms, tmpNorms);
1768  }
1769 
1773  void norm1 (const Teuchos::ArrayView<mag_type>& norms) const;
1774 
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
1792  {
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) {
1798  // If T and mag_type differ, this does an implicit conversion.
1799  norms[i] = theNorms[i];
1800  }
1801  }
1802 
1815  void
1816  norm2 (const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms) const;
1817 
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 {
1822  // FIXME (mfh 11 Apr 2019) The enable_ifs make it useless for
1823  // this method to be templated. (It only exists in case
1824  // HostSpace = device_type::memory_space.)
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);
1828  Kokkos::deep_copy (norms, h_norms);
1829  }
1830 
1844  template<typename T>
1845  typename std::enable_if< ! (std::is_same<mag_type, T>::value), void >::type
1846  norm2 (const Kokkos::View<T*, device_type>& norms) const
1847  {
1848  const size_t numNorms = norms.extent (0);
1849  Kokkos::View<mag_type*, device_type> theNorms ("MV::norm2 tmp", numNorms);
1850  // Call overload that takes a Kokkos::View<mag_type*, device_type>.
1851  this->norm2 (theNorms);
1852  // FIXME (mfh 14 Jul 2014) Does this actually work if mag_type
1853  // and T differ? We would need a test for this, but only the
1854  // Sacado and Stokhos packages are likely to care about this use
1855  // case. This could also come up with Kokkos::complex ->
1856  // std::complex conversion.
1857  Kokkos::deep_copy (norms, theNorms);
1858  }
1859 
1863  void norm2 (const Teuchos::ArrayView<mag_type>& norms) const;
1864 
1879  template <typename T>
1880  typename std::enable_if< ! (std::is_same<mag_type,T>::value), void >::type
1881  norm2 (const Teuchos::ArrayView<T>& norms) const
1882  {
1883  typedef typename Teuchos::ArrayView<T>::size_type size_type;
1884  const size_type sz = norms.size ();
1885  Teuchos::Array<mag_type> theNorms (sz);
1886  this->norm2 (theNorms);
1887  for (size_type i = 0; i < sz; ++i) {
1888  // If T and mag_type differ, this does an implicit conversion.
1889  norms[i] = theNorms[i];
1890  }
1891  }
1892 
1899  void normInf (const Kokkos::View<mag_type*, Kokkos::HostSpace>& norms) const;
1900 
1901  template<class ViewType>
1902  typename std::enable_if<std::is_same<typename ViewType::value_type,mag_type>::value &&
1903  std::is_same<typename ViewType::memory_space,typename device_type::memory_space>::value>::type
1904  normInf (const ViewType& norms) const {
1905  // FIXME (mfh 11 Apr 2019) The enable_ifs make it useless for
1906  // this method to be templated. (It only exists in case
1907  // HostSpace = device_type::memory_space.)
1908  using host_norms_view_type = Kokkos::View<mag_type*, Kokkos::HostSpace>;
1909  host_norms_view_type h_norms ("Tpetra::MV::h_norms", norms.extent (0));
1910  this->normInf (h_norms);
1911  Kokkos::deep_copy (norms, h_norms);
1912  }
1913 
1927  template<typename T>
1928  typename std::enable_if< ! (std::is_same<mag_type, T>::value), void >::type
1929  normInf (const Kokkos::View<T*, device_type>& norms) const
1930  {
1931  const size_t numNorms = norms.extent (0);
1932  Kokkos::View<mag_type*, device_type> theNorms ("MV::normInf tmp", numNorms);
1933  // Call overload that takes a Kokkos::View<mag_type*, device_type>.
1934  this->normInf (theNorms);
1935  // FIXME (mfh 15 Jul 2014) Does this actually work if mag_type
1936  // and T differ? We would need a test for this, but only the
1937  // Sacado and Stokhos packages are likely to care about this use
1938  // case. This could also come up with Kokkos::complex ->
1939  // std::complex conversion.
1940  Kokkos::deep_copy (norms, theNorms);
1941  }
1942 
1947  void normInf (const Teuchos::ArrayView<mag_type>& norms) const;
1948 
1964  template <typename T>
1965  typename std::enable_if< ! (std::is_same<mag_type,T>::value), void >::type
1966  normInf (const Teuchos::ArrayView<T>& norms) const
1967  {
1968  typedef typename Teuchos::ArrayView<T>::size_type size_type;
1969  const size_type sz = norms.size ();
1970  Teuchos::Array<mag_type> theNorms (sz);
1971  this->norm2 (theNorms);
1972  for (size_type i = 0; i < sz; ++i) {
1973  // If T and mag_type differ, this does an implicit conversion.
1974  norms[i] = theNorms[i];
1975  }
1976  }
1977 
1978 
1983  void meanValue (const Teuchos::ArrayView<impl_scalar_type>& means) const;
1984 
1985  template <typename T>
1986  typename std::enable_if<! std::is_same<impl_scalar_type, T>::value, void>::type
1987  meanValue (const Teuchos::ArrayView<T>& means) const
1988  {
1989  typedef typename Teuchos::Array<T>::size_type size_type;
1990  const size_type numMeans = means.size ();
1991 
1992  Teuchos::Array<impl_scalar_type> theMeans (numMeans);
1993  this->meanValue (theMeans ());
1994  for (size_type k = 0; k < numMeans; ++k) {
1995  means[k] = static_cast<T> (theMeans[k]);
1996  }
1997  }
1998 
2004  void
2005  multiply (Teuchos::ETransp transA,
2006  Teuchos::ETransp transB,
2007  const Scalar& alpha,
2008  const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2009  const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2010  const Scalar& beta);
2011 
2032  void
2033  elementWiseMultiply (Scalar scalarAB,
2034  const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
2035  const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& B,
2036  Scalar scalarThis);
2038 
2040 
2042  size_t getNumVectors() const;
2043 
2045  size_t getLocalLength() const;
2046 
2049 
2055  size_t getStride() const;
2056 
2060  bool isConstantStride() const;
2061 
2063 
2065 
2066 
2068  virtual std::string description() const;
2069 
2098  virtual void
2099  describe (Teuchos::FancyOStream& out,
2100  const Teuchos::EVerbosityLevel verbLevel =
2101  Teuchos::Describable::verbLevel_default) const;
2103 
2117  virtual void
2118  removeEmptyProcessesInPlace (const Teuchos::RCP<const map_type>& newMap);
2119 
2130  void setCopyOrView (const Teuchos::DataAccess copyOrView) {
2131  TEUCHOS_TEST_FOR_EXCEPTION(
2132  copyOrView == Teuchos::Copy, std::invalid_argument,
2133  "Tpetra::MultiVector::setCopyOrView: The Kokkos refactor version of "
2134  "MultiVector _only_ implements view semantics. You may not call this "
2135  "method with copyOrView = Teuchos::Copy. The only valid argument is "
2136  "Teuchos::View.");
2137  }
2138 
2142  // This method ONLY exists for the circa 2014 "Kokkos refactor"
2143  // effort. It ALWAYS returns Teuchos::View.
2147  Teuchos::DataAccess getCopyOrView () const {
2148  return Teuchos::View;
2149  }
2150 
2165  void
2167 
2168 
2169  // \brief Checks to see if the local length, number of vectors and size of Scalar type match
2178 
2179  private:
2181  using base_type = DistObject<scalar_type, local_ordinal_type,
2183 
2184  protected:
2185  template <class DS, class DL, class DG, class DN,
2186  class SS, class SL, class SG, class SN>
2187  friend void
2189  const MultiVector<SS, SL, SG, SN>& src);
2190 
2198 
2229 
2242  Teuchos::Array<size_t> whichVectors_;
2243 
2244  template<class SC, class LO, class GO, class NT>
2245  friend ::Teuchos::ArrayView<const size_t> getMultiVectorWhichVectors (const ::Tpetra::MultiVector<SC, LO, GO, NT>& X);
2246 
2248 
2250 
2257  std::string
2258  descriptionImpl (const std::string& className) const;
2259 
2266  std::string
2267  localDescribeToString (const Teuchos::EVerbosityLevel vl) const;
2268 
2282  void
2283  describeImpl (Teuchos::FancyOStream& out,
2284  const std::string& className,
2285  const Teuchos::EVerbosityLevel verbLevel =
2286  Teuchos::Describable::verbLevel_default) const;
2287 
2288  // Return true if and only if VectorIndex is a valid column index.
2289  bool vectorIndexOutOfRange (const size_t VectorIndex) const;
2290 
2295  template <class T>
2296  Teuchos::ArrayRCP<T>
2297  getSubArrayRCP (Teuchos::ArrayRCP<T> arr, size_t j) const;
2298 
2300  size_t getOrigNumLocalRows () const;
2301 
2303  size_t getOrigNumLocalCols () const;
2304 
2306 
2308 
2313  using buffer_device_type =
2314  typename DistObject<scalar_type,
2318 
2323  virtual bool
2324  checkSizes (const SrcDistObject& sourceObj);
2325 
2327  virtual size_t constantNumberOfPackets () const;
2328 
2329  virtual void
2330  copyAndPermute
2331  (const SrcDistObject& sourceObj,
2332  const size_t numSameIDs,
2333  const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
2334  const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs);
2335 
2336  virtual void
2337  packAndPrepare
2338  (const SrcDistObject& sourceObj,
2339  const Kokkos::DualView<
2340  const local_ordinal_type*,
2341  buffer_device_type>& exportLIDs,
2342  Kokkos::DualView<
2344  buffer_device_type>& exports,
2345  Kokkos::DualView<
2346  size_t*,
2347  buffer_device_type> /* numPacketsPerLID */,
2348  size_t& constantNumPackets,
2349  Distributor& /* distor */);
2350 
2351  virtual void
2352  unpackAndCombine
2353  (const Kokkos::DualView<
2354  const local_ordinal_type*,
2355  buffer_device_type>& importLIDs,
2356  Kokkos::DualView<
2358  buffer_device_type> imports,
2359  Kokkos::DualView<
2360  size_t*,
2361  buffer_device_type> /* numPacketsPerLID */,
2362  const size_t constantNumPackets,
2363  Distributor& /* distor */,
2364  const CombineMode CM);
2366  }; // class MultiVector
2367 
2368  template<class SC, class LO, class GO, class NT>
2369  Teuchos::ArrayView<const size_t>
2370  getMultiVectorWhichVectors (const MultiVector<SC, LO, GO, NT>& X)
2371  {
2372  return X.whichVectors_ ();
2373  }
2374 
2375 
2378  template <class ST, class LO, class GO, class NT>
2379  void
2381  const MultiVector<ST, LO, GO, NT>& src)
2382  {
2383  // NOTE (mfh 11 Sep 2014) We can't implement deep_copy with
2384  // shallow-copy operator=, because that would invalidate existing
2385  // views of dst!
2386  dst.assign (src);
2387  }
2388 
2389  // Implementation of the most generic version of MultiVector deep_copy.
2390  template <class DS, class DL, class DG, class DN,
2391  class SS, class SL, class SG, class SN>
2392  void
2394  const MultiVector<SS, SL, SG, SN>& src)
2395  {
2396  using ::Tpetra::getMultiVectorWhichVectors;
2397 
2398  TEUCHOS_TEST_FOR_EXCEPTION(
2399  dst.getGlobalLength () != src.getGlobalLength () ||
2400  dst.getNumVectors () != src.getNumVectors (), std::invalid_argument,
2401  "Tpetra::deep_copy: Global dimensions of the two Tpetra::MultiVector "
2402  "objects do not match. src has dimensions [" << src.getGlobalLength ()
2403  << "," << src.getNumVectors () << "], and dst has dimensions ["
2404  << dst.getGlobalLength () << "," << dst.getNumVectors () << "].");
2405 
2406  // FIXME (mfh 28 Jul 2014) Don't throw; just set a local error flag.
2407  TEUCHOS_TEST_FOR_EXCEPTION(
2408  dst.getLocalLength () != src.getLocalLength (), std::invalid_argument,
2409  "Tpetra::deep_copy: The local row counts of the two Tpetra::MultiVector "
2410  "objects do not match. src has " << src.getLocalLength () << " row(s) "
2411  << " and dst has " << dst.getLocalLength () << " row(s).");
2412 
2413  const bool srcMostUpToDateOnDevice = ! src.need_sync_device ();
2414  dst.clear_sync_state ();
2415  dst.modify_device ();
2416 
2417  if (src.isConstantStride () && dst.isConstantStride ()) {
2418  if (srcMostUpToDateOnDevice) {
2420  src.getLocalViewDevice ());
2421  }
2422  else {
2424  src.getLocalViewHost ());
2425  }
2426  }
2427  else {
2428  auto dstWhichVecs = getMultiVectorWhichVectors (dst);
2429  auto srcWhichVecs = getMultiVectorWhichVectors (src);
2430 
2431  if (srcMostUpToDateOnDevice) {
2433  src.getLocalViewDevice (),
2434  dst.isConstantStride (),
2435  src.isConstantStride (),
2436  dstWhichVecs,
2437  srcWhichVecs);
2438  }
2439  else {
2441  src.getLocalViewHost (),
2442  dst.isConstantStride (),
2443  src.isConstantStride (),
2444  dstWhichVecs,
2445  srcWhichVecs);
2446  }
2447  }
2448  }
2449 } // namespace Tpetra
2450 
2451 
2452 namespace Teuchos {
2453 
2454  // Give Teuchos::TypeNameTraits<Tpetra::MultiVector<...> > a
2455  // human-readable definition.
2456  template<class SC, class LO, class GO, class NT>
2457  class TypeNameTraits<Tpetra::MultiVector<SC, LO, GO, NT> > {
2458  public:
2459  static std::string name () {
2460  return std::string ("Tpetra::MultiVector<") +
2461  TypeNameTraits<SC>::name () + "," +
2462  TypeNameTraits<LO>::name () + "," +
2463  TypeNameTraits<GO>::name () + "," +
2464  TypeNameTraits<NT>::name () + ">";
2465  }
2466 
2467  static std::string
2468  concreteName (const Tpetra::MultiVector<SC, LO, GO, NT>&) {
2469  return name ();
2470  }
2471  };
2472 } // namespace Teuchos
2473 
2474 #endif // TPETRA_MULTIVECTOR_DECL_HPP
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t numVectors)
Nonmember MultiVector &quot;constructor&quot;: 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.
dual_view_type::t_host getLocalViewHost() const
A local Kokkos::View of host memory.
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.
LocalOrdinal local_ordinal_type
The type of local indices.
dual_view_type view_
The Kokkos::DualView containing the MultiVector&#39;s data.
Node node_type
The Node type. If you don&#39;t know what this is, don&#39;t use it.
GlobalOrdinal global_ordinal_type
The type of global indices.
Teuchos::ArrayRCP< Scalar > get1dViewNonConst()
Nonconst persisting (1-D) view of this multivector&#39;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&#39;s local values.
typename map_type::node_type node_type
Legacy thing that you should not use any more.
void clear_sync_state()
Clear &quot;modified&quot; flags on both host and device sides.
void localDeepCopyConstStride(const DstViewType &dst, const SrcViewType &src)
Implementation of Tpetra::MultiVector deep copy of local data, for when both the source and destinati...
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
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.
Teuchos::ArrayRCP< Teuchos::ArrayRCP< Scalar > > get2dViewNonConst()
Return non-const persisting pointers to values.
bool isConstantStride() const
Whether this multivector has constant stride between columns.
std::string localDescribeToString(const Teuchos::EVerbosityLevel vl) const
Print the calling process&#39; verbose describe() information to the returned string. ...
One or more distributed dense vectors.
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > subCopy(const Teuchos::Range1D &colRng) const
Return a MultiVector with copies of selected columns.
void modify()
Mark data as modified on the given device TargetDeviceType.
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.
bool need_sync() const
Whether this MultiVector needs synchronization to the given space.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A, const size_t LDA) const
Fill the given array with a copy of this multivector&#39;s local values.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &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.
void setCopyOrView(const Teuchos::DataAccess copyOrView)
Set whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assigment (shallow copy).
void sync()
Update data on device or host only if data in the other space has been marked as modified.
typename Node::device_type device_type
The Kokkos Device type.
bool need_sync_device() const
Whether this MultiVector needs synchronization to the device.
GO global_ordinal_type
The type of global indices.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getOrigNumLocalCols() const
&quot;Original&quot; number of columns in the (local) data.
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.
typename device_type::execution_space execution_space
The Kokkos execution space.
void sync_host()
Synchronize to Host.
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.
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).
dual_view_type origView_
The &quot;original view&quot; of the MultiVector&#39;s data.
std::string descriptionImpl(const std::string &className) const
Implementation of description() for this class, and its subclass Vector.
void normInf(const Kokkos::View< mag_type *, Kokkos::HostSpace > &norms) const
Compute the infinity-norm of each vector (column), storing the result in a host View.
void replaceGlobalValue(const GlobalOrdinal gblRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using global row index.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner (&quot;dot&quot;) product result.
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.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
typename DistObject< scalar_type, local_ordinal_type, global_ordinal_type, node_type >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
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.
virtual ~MultiVector()=default
Destructor (virtual for memory safety of derived classes).
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.
virtual size_t constantNumberOfPackets() const
Number of packets to send per LID.
bool need_sync_host() const
Whether this MultiVector needs synchronization to the host.
void modify_device()
Mark data as modified on the device side.
typename map_type::global_ordinal_type global_ordinal_type
The type of global 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 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.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
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.
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 swap(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &mv)
Swap contents of mv with contents of *this.
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.
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.
void modify_host()
Mark data as modified on the host side.
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.
MultiVector()
Default constructor: makes a MultiVector with no rows or columns.
Forward declaration of Tpetra::FEMultiVector.
Scalar scalar_type
The type of each entry in the MultiVector.
void replaceLocalValue(const LocalOrdinal lclRow, const size_t col, const impl_scalar_type &value) const
Replace value in host memory, using local (row) index.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
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.
size_t getStride() const
Stride between columns in the multivector.
virtual std::string description() const
A simple one-line description of this object.
void reduce()
Sum values of a locally replicated multivector across all processes.
void 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 map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
virtual bool checkSizes(const SrcDistObject &sourceObj)
Whether data redistribution between sourceObj and this object is legal.
typename Node::device_type device_type
This class&#39; Kokkos::Device specialization.
dual_view_type::t_dev getLocalViewDevice() const
A local Kokkos::View of device memory.
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.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Teuchos::DataAccess getCopyOrView() const
Get whether this has copy (copyOrView = Teuchos::Copy) or view (copyOrView = Teuchos::View) semantics...
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&#39;s local values.
Forward declaration of Tpetra::Map.
size_t getOrigNumLocalRows() const
&quot;Original&quot; number of rows in the (local) data.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes owning zero rows from the Map and their communicator.
void sync_device()
Synchronize to Device.
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.
Teuchos::Array< size_t > whichVectors_
Indices of columns this multivector is viewing.