40 #ifndef TPETRA_CRSMATRIX_DECL_HPP
41 #define TPETRA_CRSMATRIX_DECL_HPP
52 #include "Tpetra_LocalCrsMatrixOperator_fwd.hpp"
53 #include "Tpetra_RowMatrix_decl.hpp"
54 #include "Tpetra_Exceptions.hpp"
55 #include "Tpetra_DistObject.hpp"
56 #include "Tpetra_CrsGraph.hpp"
57 #include "Tpetra_Vector.hpp"
59 #include "KokkosSparse_CrsMatrix.hpp"
65 #include "KokkosSparse_sor_sequential_impl.hpp"
72 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsMatrix_Swap_Tester;
125 template<
class CrsMatrixType>
126 Teuchos::RCP<CrsMatrixType>
128 const Import<
typename CrsMatrixType::local_ordinal_type,
129 typename CrsMatrixType::global_ordinal_type,
130 typename CrsMatrixType::node_type>& importer,
131 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
132 typename CrsMatrixType::global_ordinal_type,
133 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
134 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
135 typename CrsMatrixType::global_ordinal_type,
136 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
137 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
192 template<
class CrsMatrixType>
193 Teuchos::RCP<CrsMatrixType>
195 const Import<
typename CrsMatrixType::local_ordinal_type,
196 typename CrsMatrixType::global_ordinal_type,
197 typename CrsMatrixType::node_type>& rowImporter,
198 const Import<
typename CrsMatrixType::local_ordinal_type,
199 typename CrsMatrixType::global_ordinal_type,
200 typename CrsMatrixType::node_type>& domainImporter,
201 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
202 typename CrsMatrixType::global_ordinal_type,
203 typename CrsMatrixType::node_type> >& domainMap,
204 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
205 typename CrsMatrixType::global_ordinal_type,
206 typename CrsMatrixType::node_type> >& rangeMap,
207 const Teuchos::RCP<Teuchos::ParameterList>& params);
242 template<
class CrsMatrixType>
243 Teuchos::RCP<CrsMatrixType>
245 const Export<
typename CrsMatrixType::local_ordinal_type,
246 typename CrsMatrixType::global_ordinal_type,
247 typename CrsMatrixType::node_type>& exporter,
248 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
249 typename CrsMatrixType::global_ordinal_type,
250 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
251 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
252 typename CrsMatrixType::global_ordinal_type,
253 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
254 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
289 template<
class CrsMatrixType>
290 Teuchos::RCP<CrsMatrixType>
292 const Export<
typename CrsMatrixType::local_ordinal_type,
293 typename CrsMatrixType::global_ordinal_type,
294 typename CrsMatrixType::node_type>& rowExporter,
295 const Export<
typename CrsMatrixType::local_ordinal_type,
296 typename CrsMatrixType::global_ordinal_type,
297 typename CrsMatrixType::node_type>& domainExporter,
298 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
299 typename CrsMatrixType::global_ordinal_type,
300 typename CrsMatrixType::node_type> >& domainMap,
301 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
302 typename CrsMatrixType::global_ordinal_type,
303 typename CrsMatrixType::node_type> >& rangeMap,
304 const Teuchos::RCP<Teuchos::ParameterList>& params);
309 template<
class SC,
class LO,
class GO,
class NO>
310 void residual(
const Operator<SC,LO,GO,NO> & A,
311 const MultiVector<SC,LO,GO,NO> & X,
312 const MultiVector<SC,LO,GO,NO> & B,
313 MultiVector<SC,LO,GO,NO> & R);
429 template <
class Scalar,
434 public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
435 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>
473 using mag_type =
typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
497 typename local_graph_type::size_type>;
511 GlobalOrdinal, Node>&) =
default;
515 GlobalOrdinal, Node>&&) =
default;
520 GlobalOrdinal, Node>&) =
default;
525 GlobalOrdinal, Node>&&) =
default;
542 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
543 const size_t maxNumEntriesPerRow,
544 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
545 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
561 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
562 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
563 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
564 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
587 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
588 const Teuchos::RCP<const map_type>& colMap,
589 const size_t maxNumEntPerRow,
590 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
591 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
613 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
614 const Teuchos::RCP<const map_type>& colMap,
615 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
616 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
617 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
644 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
645 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
675 explicit CrsMatrix (
const Teuchos::RCP<const crs_graph_type>& graph,
676 const typename local_matrix_type::values_type& values,
677 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
705 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
706 const Teuchos::RCP<const map_type>& colMap,
707 const typename local_matrix_type::row_map_type& rowPointers,
708 const typename local_graph_type::entries_type::non_const_type& columnIndices,
709 const typename local_matrix_type::values_type& values,
710 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
738 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
739 const Teuchos::RCP<const map_type>& colMap,
740 const Teuchos::ArrayRCP<size_t>& rowPointers,
741 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
742 const Teuchos::ArrayRCP<Scalar>& values,
743 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
766 CrsMatrix (
const Teuchos::RCP<const map_type>& rowMap,
767 const Teuchos::RCP<const map_type>& colMap,
769 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
802 const Teuchos::RCP<const map_type>& rowMap,
803 const Teuchos::RCP<const map_type>& colMap,
804 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
805 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
806 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
813 const Teuchos::RCP<const map_type>& rowMap,
814 const Teuchos::RCP<const map_type>& colMap,
815 const Teuchos::RCP<const map_type>& domainMap,
816 const Teuchos::RCP<const map_type>& rangeMap,
817 const Teuchos::RCP<const import_type>& importer,
818 const Teuchos::RCP<const export_type>& exporter,
819 const Teuchos::RCP<Teuchos::ParameterList>& params =
826 const Teuchos::DataAccess copyOrView);
840 template <
class S2,
class LO2,
class GO2,
class N2>
844 template <
class S2,
class LO2,
class GO2,
class N2>
851 template <
class MatrixArray,
class MultiVectorArray>
853 const typename std::remove_pointer<typename MultiVectorArray::value_type>::type & X,
855 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type alpha,
856 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type beta,
857 Teuchos::RCP<Teuchos::ParameterList> params);
934 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
935 const Teuchos::ArrayView<const Scalar>& vals);
953 const LocalOrdinal numEnt,
955 const GlobalOrdinal inds[]);
999 const Teuchos::ArrayView<const LocalOrdinal> &cols,
1000 const Teuchos::ArrayView<const Scalar> &vals);
1018 const LocalOrdinal numEnt,
1019 const Scalar vals[],
1020 const LocalOrdinal cols[]);
1037 const GlobalOrdinal inds[],
1039 const LocalOrdinal numElts)
const;
1081 const Kokkos::View<const global_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1082 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals)
const;
1088 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1089 const Teuchos::ArrayView<const Scalar>& vals)
const;
1107 const LocalOrdinal numEnt,
1108 const Scalar vals[],
1109 const GlobalOrdinal cols[])
const;
1126 const LocalOrdinal inds[],
1128 const LocalOrdinal numElts)
const;
1169 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1170 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals)
const;
1177 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1178 const Teuchos::ArrayView<const Scalar>& vals)
const;
1199 const LocalOrdinal numEnt,
1200 const Scalar inputVals[],
1201 const LocalOrdinal inputCols[])
const;
1208 static const bool useAtomicUpdatesByDefault =
1209 #ifdef KOKKOS_ENABLE_SERIAL
1210 ! std::is_same<execution_space, Kokkos::Serial>::value;
1213 #endif // KOKKOS_ENABLE_SERIAL
1242 const GlobalOrdinal inds[],
1244 const LocalOrdinal numElts,
1245 const bool atomic = useAtomicUpdatesByDefault)
const;
1286 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1287 const Teuchos::ArrayView<const Scalar>& vals,
1288 const bool atomic = useAtomicUpdatesByDefault);
1314 const LocalOrdinal numEnt,
1315 const Scalar vals[],
1316 const GlobalOrdinal cols[],
1317 const bool atomic = useAtomicUpdatesByDefault);
1336 const LocalOrdinal inds[],
1338 const LocalOrdinal numElts,
1339 const bool atomic = useAtomicUpdatesByDefault)
const;
1381 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1382 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals,
1383 const bool atomic = useAtomicUpdatesByDefault)
const;
1416 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1417 const Teuchos::ArrayView<const Scalar>& vals,
1418 const bool atomic = useAtomicUpdatesByDefault)
const;
1443 const LocalOrdinal numEnt,
1444 const Scalar vals[],
1445 const LocalOrdinal cols[],
1446 const bool atomic = useAtomicUpdatesByDefault)
const;
1483 const LocalOrdinal inds[],
1485 const LocalOrdinal numElts,
1487 const bool atomic = useAtomicUpdatesByDefault)
const;
1523 const GlobalOrdinal inds[],
1525 const LocalOrdinal numElts,
1527 const bool atomic = useAtomicUpdatesByDefault)
const;
1556 transformLocalValues (
const LocalOrdinal lclRow,
1557 const LocalOrdinal numInputEnt,
1559 const LocalOrdinal inputCols[],
1561 const bool atomic = useAtomicUpdatesByDefault)
const;
1590 transformGlobalValues (
const GlobalOrdinal gblRow,
1591 const LocalOrdinal numInputEnt,
1593 const GlobalOrdinal inputCols[],
1595 const bool atomic = useAtomicUpdatesByDefault)
const;
1641 template<
class LocalIndicesViewType,
1642 class ImplScalarViewType,
1643 class BinaryFunction>
1646 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1647 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1649 const bool atomic = useAtomicUpdatesByDefault)
const
1657 static_assert (Kokkos::is_view<LocalIndicesViewType>::value,
1658 "First template parameter LocalIndicesViewType must be "
1660 static_assert (Kokkos::is_view<ImplScalarViewType>::value,
1661 "Second template parameter ImplScalarViewType must be a "
1663 static_assert (static_cast<int> (LocalIndicesViewType::rank) == 1,
1664 "First template parameter LocalIndicesViewType must "
1666 static_assert (static_cast<int> (ImplScalarViewType::rank) == 1,
1667 "Second template parameter ImplScalarViewType must have "
1669 static_assert (std::is_same<
1670 typename LocalIndicesViewType::non_const_value_type,
1672 "First template parameter LocalIndicesViewType must "
1673 "contain values of type local_ordinal_type.");
1674 static_assert (std::is_same<
1675 typename ImplScalarViewType::non_const_value_type,
1677 "Second template parameter ImplScalarViewType must "
1678 "contain values of type impl_scalar_type.");
1679 typedef LocalOrdinal LO;
1680 const LO numInputEnt = inputInds.extent (0);
1681 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1682 return Teuchos::OrdinalTraits<LO>::invalid ();
1684 return this->transformLocalValues (lclRow,
1733 template<
class BinaryFunction,
class InputMemorySpace>
1736 const Kokkos::View<
const GlobalOrdinal*,
1738 Kokkos::MemoryUnmanaged>& inputInds,
1741 Kokkos::MemoryUnmanaged>& inputVals,
1743 const bool atomic = useAtomicUpdatesByDefault)
const
1745 typedef LocalOrdinal LO;
1746 const LO numInputEnt = inputInds.extent (0);
1747 if (static_cast<LO> (inputVals.extent (0)) != numInputEnt) {
1748 return Teuchos::OrdinalTraits<LO>::invalid ();
1750 return this->transformGlobalValues (gblRow,
1762 void scale (
const Scalar& alpha);
1789 setAllValues (
const typename local_matrix_type::row_map_type& ptr,
1790 const typename local_graph_type::entries_type::non_const_type& ind,
1791 const typename local_matrix_type::values_type& val);
1819 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
1820 const Teuchos::ArrayRCP<Scalar>& val);
1823 getAllValues (Teuchos::ArrayRCP<const size_t>& rowPointers,
1824 Teuchos::ArrayRCP<const LocalOrdinal>& columnIndices,
1825 Teuchos::ArrayRCP<const Scalar>& values)
const;
1874 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1934 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
1935 const Teuchos::RCP<const map_type>& rangeMap,
1936 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1965 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1995 const Teuchos::RCP<const map_type>& rangeMap,
1996 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
1997 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
1998 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2018 replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
2103 const Teuchos::RCP<const map_type>& newColMap,
2104 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2105 const bool sortEachRow =
true);
2121 Teuchos::RCP<const import_type>& newImporter);
2144 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2148 Teuchos::RCP<const map_type>
getRowMap ()
const override;
2151 Teuchos::RCP<const map_type>
getColMap ()
const override;
2154 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2158 Teuchos::RCP<const crs_graph_type>
getCrsGraph ()
const;
2453 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
2454 const Teuchos::ArrayView<Scalar>& Values,
2455 size_t& NumEntries)
const override;
2474 const Teuchos::ArrayView<LocalOrdinal>& colInds,
2475 const Teuchos::ArrayView<Scalar>& vals,
2476 size_t& numEntries)
const override;
2492 Teuchos::ArrayView<const GlobalOrdinal>& indices,
2493 Teuchos::ArrayView<const Scalar>& values)
const override;
2509 Teuchos::ArrayView<const LocalOrdinal>& indices,
2510 Teuchos::ArrayView<const Scalar>& values)
const override;
2538 LocalOrdinal& numEnt,
2539 const LocalOrdinal*& lclColInds,
2540 const Scalar*& vals)
const override;
2567 LocalOrdinal& numEnt,
2569 const LocalOrdinal*& ind)
const;
2578 template<
class OutputScalarType>
2579 typename std::enable_if<! std::is_same<OutputScalarType, impl_scalar_type>::value &&
2580 std::is_convertible<impl_scalar_type, OutputScalarType>::value,
2583 LocalOrdinal& numEnt,
2584 const OutputScalarType*& val,
2585 const LocalOrdinal*& ind)
const
2588 const LocalOrdinal err = this->
getLocalRowView (lclRow, numEnt, valTmp, ind);
2591 val =
reinterpret_cast<const OutputScalarType*
> (valTmp);
2673 Kokkos::MemoryUnmanaged>& offsets)
const;
2699 const Teuchos::ArrayView<const size_t>& offsets)
const;
2783 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
2784 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one (),
2785 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero ())
const;
2811 template <
class DomainScalar,
class RangeScalar>
2816 const RangeScalar& dampingFactor,
2819 typedef LocalOrdinal LO;
2820 typedef GlobalOrdinal GO;
2823 typedef typename Node::device_type::memory_space dev_mem_space;
2824 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
2826 typedef typename k_local_graph_type::size_type offset_type;
2827 const char prefix[] =
"Tpetra::CrsMatrix::localGaussSeidel: ";
2829 TEUCHOS_TEST_FOR_EXCEPTION
2831 prefix <<
"The matrix is not fill complete.");
2834 TEUCHOS_TEST_FOR_EXCEPTION
2836 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
2838 TEUCHOS_TEST_FOR_EXCEPTION
2841 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2846 const_cast<DMV&
> (B).sync_host ();
2849 const_cast<MMV&
> (D).sync_host ();
2851 auto B_lcl = B.template getLocalView<host_mem_space> ();
2852 auto X_lcl = X.template getLocalView<host_mem_space> ();
2853 auto D_lcl = D.template getLocalView<host_mem_space> ();
2855 offset_type B_stride[8], X_stride[8], D_stride[8];
2856 B_lcl.stride (B_stride);
2857 X_lcl.stride (X_stride);
2858 D_lcl.stride (D_stride);
2861 k_local_graph_type lclGraph = lclMatrix.graph;
2862 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2863 typename local_matrix_type::index_type ind = lclGraph.entries;
2864 typename local_matrix_type::values_type val = lclMatrix.values;
2865 const offset_type*
const ptrRaw = ptr.data ();
2866 const LO*
const indRaw = ind.data ();
2869 const std::string dir ((direction == Forward) ?
"F" :
"B");
2875 KokkosSparse::Impl::Sequential::gaussSeidel (static_cast<LO> (lclNumRows),
2876 static_cast<LO> (numVecs),
2877 ptrRaw, indRaw, valRaw,
2878 B_lcl.data (), B_stride[1],
2879 X_lcl.data (), X_stride[1],
2883 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
2884 X.template sync<dev_mem_space> ();
2885 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
2914 template <
class DomainScalar,
class RangeScalar>
2919 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
2920 const RangeScalar& dampingFactor,
2923 typedef LocalOrdinal LO;
2924 typedef GlobalOrdinal GO;
2927 typedef typename Node::device_type::memory_space dev_mem_space;
2928 typedef typename MMV::dual_view_type::t_host::device_type host_mem_space;
2930 typedef typename k_local_graph_type::size_type offset_type;
2931 const char prefix[] =
"Tpetra::CrsMatrix::reorderedLocalGaussSeidel: ";
2933 TEUCHOS_TEST_FOR_EXCEPTION
2935 prefix <<
"The matrix is not fill complete.");
2938 TEUCHOS_TEST_FOR_EXCEPTION
2940 prefix <<
"B.getNumVectors() = " << numVecs <<
" != "
2942 TEUCHOS_TEST_FOR_EXCEPTION
2945 <<
" != this->getNodeNumRows() = " << lclNumRows <<
".");
2946 TEUCHOS_TEST_FOR_EXCEPTION
2947 (static_cast<size_t> (rowIndices.size ()) < lclNumRows,
2948 std::invalid_argument, prefix <<
"rowIndices.size() = "
2949 << rowIndices.size () <<
" < this->getNodeNumRows() = "
2950 << lclNumRows <<
".");
2955 const_cast<DMV&
> (B).sync_host ();
2958 const_cast<MMV&
> (D).sync_host ();
2960 auto B_lcl = B.template getLocalView<host_mem_space> ();
2961 auto X_lcl = X.template getLocalView<host_mem_space> ();
2962 auto D_lcl = D.template getLocalView<host_mem_space> ();
2964 offset_type B_stride[8], X_stride[8], D_stride[8];
2965 B_lcl.stride (B_stride);
2966 X_lcl.stride (X_stride);
2967 D_lcl.stride (D_stride);
2971 typename local_matrix_type::index_type ind = lclGraph.entries;
2972 typename local_matrix_type::row_map_type ptr = lclGraph.row_map;
2973 typename local_matrix_type::values_type val = lclMatrix.values;
2974 const offset_type*
const ptrRaw = ptr.data ();
2975 const LO*
const indRaw = ind.data ();
2978 const std::string dir = (direction == Forward) ?
"F" :
"B";
2983 KokkosSparse::Impl::Sequential::reorderedGaussSeidel (static_cast<LO> (lclNumRows),
2984 static_cast<LO> (numVecs),
2985 ptrRaw, indRaw, valRaw,
2991 rowIndices.getRawPtr (),
2992 static_cast<LO
> (lclNumRows),
2993 static_cast<impl_scalar_type> (dampingFactor),
2995 const_cast<DMV&
> (B).
template sync<dev_mem_space> ();
2996 X.template sync<dev_mem_space> ();
2997 const_cast<MMV&
> (D).
template sync<dev_mem_space> ();
3003 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
3023 Teuchos::ETransp mode = Teuchos::NO_TRANS,
3024 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
3025 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
3037 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
3045 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
3119 const Scalar& dampingFactor,
3121 const int numSweeps)
const;
3193 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3194 const Scalar& dampingFactor,
3196 const int numSweeps)
const;
3230 const Scalar& dampingFactor,
3232 const int numSweeps,
3233 const bool zeroInitialGuess)
const;
3268 const Teuchos::ArrayView<LocalOrdinal>& rowIndices,
3269 const Scalar& dampingFactor,
3271 const int numSweeps,
3272 const bool zeroInitialGuess)
const;
3284 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
3285 add (
const Scalar& alpha,
3290 const Teuchos::RCP<Teuchos::ParameterList>& params)
const override;
3302 describe (Teuchos::FancyOStream& out,
3303 const Teuchos::EVerbosityLevel verbLevel =
3304 Teuchos::Describable::verbLevel_default)
const override;
3314 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
3323 const bool verbose);
3327 copyAndPermuteStaticGraph(
3329 const size_t numSameIDs,
3330 const LocalOrdinal permuteToLIDs[],
3331 const LocalOrdinal permuteFromLIDs[],
3332 const size_t numPermutes);
3335 copyAndPermuteNonStaticGraph(
3337 const size_t numSameIDs,
3338 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs_dv,
3339 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs_dv,
3340 const size_t numPermutes);
3346 const size_t numSameIDs,
3347 const Kokkos::DualView<
3350 const Kokkos::DualView<
3357 const Kokkos::DualView<
3360 Kokkos::DualView<char*, buffer_device_type>& exports,
3361 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3362 size_t& constantNumPackets,
3369 unpackAndCombineImpl(
3372 Kokkos::DualView<char*, buffer_device_type> imports,
3373 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3374 const size_t constantNumPackets,
3377 const bool verbose);
3382 unpackAndCombineImplNonStatic(
3385 Kokkos::DualView<char*, buffer_device_type> imports,
3386 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3387 const size_t constantNumPackets,
3403 (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3404 Kokkos::DualView<char*, buffer_device_type> imports,
3405 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3406 const size_t constantNumPackets,
3518 packNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3519 Kokkos::DualView<char*, buffer_device_type>& exports,
3520 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3521 size_t& constantNumPackets,
3532 packNonStaticNew (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3533 Kokkos::DualView<char*, buffer_device_type>& exports,
3534 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3535 size_t& constantNumPackets,
3568 packRow (
char exports[],
3569 const size_t offset,
3570 const size_t numEnt,
3571 const GlobalOrdinal gidsIn[],
3573 const size_t numBytesPerValue)
const;
3599 packRowStatic (
char*
const numEntOut,
3602 const size_t numEnt,
3603 const LocalOrdinal lclRow)
const;
3631 unpackRow (GlobalOrdinal gidsOut[],
3633 const char imports[],
3634 const size_t offset,
3635 const size_t numBytes,
3636 const size_t numEnt,
3637 const size_t numBytesPerValue);
3648 allocatePackSpaceNew (Kokkos::DualView<char*, buffer_device_type>& exports,
3649 size_t& totalNumEntries,
3662 template<
class CrsMatrixType>
3663 friend Teuchos::RCP<CrsMatrixType>
3665 const Import<
typename CrsMatrixType::local_ordinal_type,
3666 typename CrsMatrixType::global_ordinal_type,
3667 typename CrsMatrixType::node_type>& importer,
3668 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3669 typename CrsMatrixType::global_ordinal_type,
3670 typename CrsMatrixType::node_type> >& domainMap,
3671 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3672 typename CrsMatrixType::global_ordinal_type,
3673 typename CrsMatrixType::node_type> >& rangeMap,
3674 const Teuchos::RCP<Teuchos::ParameterList>& params);
3677 template<
class CrsMatrixType>
3678 friend Teuchos::RCP<CrsMatrixType>
3680 const Import<
typename CrsMatrixType::local_ordinal_type,
3681 typename CrsMatrixType::global_ordinal_type,
3682 typename CrsMatrixType::node_type>& rowImporter,
3683 const Import<
typename CrsMatrixType::local_ordinal_type,
3684 typename CrsMatrixType::global_ordinal_type,
3685 typename CrsMatrixType::node_type>& domainImporter,
3686 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3687 typename CrsMatrixType::global_ordinal_type,
3688 typename CrsMatrixType::node_type> >& domainMap,
3689 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3690 typename CrsMatrixType::global_ordinal_type,
3691 typename CrsMatrixType::node_type> >& rangeMap,
3692 const Teuchos::RCP<Teuchos::ParameterList>& params);
3696 template<
class CrsMatrixType>
3697 friend Teuchos::RCP<CrsMatrixType>
3699 const Export<
typename CrsMatrixType::local_ordinal_type,
3700 typename CrsMatrixType::global_ordinal_type,
3701 typename CrsMatrixType::node_type>& exporter,
3702 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3703 typename CrsMatrixType::global_ordinal_type,
3704 typename CrsMatrixType::node_type> >& domainMap,
3705 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3706 typename CrsMatrixType::global_ordinal_type,
3707 typename CrsMatrixType::node_type> >& rangeMap,
3708 const Teuchos::RCP<Teuchos::ParameterList>& params);
3711 template<
class CrsMatrixType>
3712 friend Teuchos::RCP<CrsMatrixType>
3714 const Export<
typename CrsMatrixType::local_ordinal_type,
3715 typename CrsMatrixType::global_ordinal_type,
3716 typename CrsMatrixType::node_type>& rowExporter,
3717 const Export<
typename CrsMatrixType::local_ordinal_type,
3718 typename CrsMatrixType::global_ordinal_type,
3719 typename CrsMatrixType::node_type>& domainExporter,
3720 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3721 typename CrsMatrixType::global_ordinal_type,
3722 typename CrsMatrixType::node_type> >& domainMap,
3723 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3724 typename CrsMatrixType::global_ordinal_type,
3725 typename CrsMatrixType::node_type> >& rangeMap,
3726 const Teuchos::RCP<Teuchos::ParameterList>& params);
3747 const Teuchos::RCP<const map_type>& domainMap,
3748 const Teuchos::RCP<const map_type>& rangeMap,
3749 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3770 const Teuchos::RCP<const map_type>& domainMap,
3771 const Teuchos::RCP<const map_type>& rangeMap,
3772 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3793 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3794 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3795 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3816 const Teuchos::RCP<const map_type>& domainMap,
3817 const Teuchos::RCP<const map_type>& rangeMap,
3818 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
3844 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3845 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
3846 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3847 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3848 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
3864 const GlobalOrdinal gblColInds[],
3866 const size_t numInputEnt);
3878 insertGlobalValuesFiltered(
3879 const GlobalOrdinal globalRow,
3880 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3881 const Teuchos::ArrayView<const Scalar>& values,
3887 insertGlobalValuesFilteredChecked(
3888 const GlobalOrdinal globalRow,
3889 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3890 const Teuchos::ArrayView<const Scalar>& values,
3891 const char*
const prefix,
3893 const bool verbose);
3907 combineGlobalValues(
3908 const GlobalOrdinal globalRowIndex,
3909 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3910 const Teuchos::ArrayView<const Scalar>& values,
3912 const char*
const prefix,
3914 const bool verbose);
3938 combineGlobalValuesRaw(
const LocalOrdinal lclRow,
3939 const LocalOrdinal numEnt,
3941 const GlobalOrdinal cols[],
3943 const char*
const prefix,
3945 const bool verbose);
3958 template<
class BinaryFunction>
3960 transformGlobalValues (
const GlobalOrdinal globalRow,
3961 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3962 const Teuchos::ArrayView<const Scalar>& values,
3964 const bool atomic = useAtomicUpdatesByDefault)
const
3967 typedef LocalOrdinal LO;
3968 typedef GlobalOrdinal GO;
3970 const LO numInputEnt =
static_cast<LO
> (indices.size ());
3971 if (static_cast<LO> (values.size ()) != numInputEnt) {
3972 return Teuchos::OrdinalTraits<LO>::invalid ();
3975 const GO*
const inputCols = indices.getRawPtr ();
3976 const IST*
const inputVals =
3977 reinterpret_cast<const IST*
> (values.getRawPtr ());
3978 return this->transformGlobalValues (globalRow, numInputEnt, inputVals,
3979 inputCols, f, atomic);
3989 insertNonownedGlobalValues (
const GlobalOrdinal globalRow,
3990 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3991 const Teuchos::ArrayView<const Scalar>& values);
4038 const typename crs_graph_type::SLocalGlobalViews& newInds,
4039 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
4040 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
4041 const ELocalGlobal lg,
4042 const ELocalGlobal I);
4045 typedef DistObject<char, LocalOrdinal, GlobalOrdinal, Node> dist_object_type;
4049 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
4050 typedef Kokkos::Details::ArithTraits<impl_scalar_type> STS;
4051 typedef Kokkos::Details::ArithTraits<mag_type> STM;
4052 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
4053 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
4057 enum GraphAllocationStatus {
4058 GraphAlreadyAllocated,
4059 GraphNotYetAllocated
4082 const bool verbose);
4095 const RowInfo& rowInfo);
4186 const bool force =
false)
const;
4211 const bool force =
false)
const;
4224 const Teuchos::ETransp mode,
4250 LocalOrdinal& numEnt,
4251 const RowInfo& rowinfo)
const;
4273 LocalOrdinal& numEnt,
4274 const RowInfo& rowinfo)
const;
4283 Teuchos::ArrayView<const impl_scalar_type>
getView (
RowInfo rowinfo)
const;
4296 Teuchos::ArrayView<impl_scalar_type>
4307 Kokkos::View<const impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4308 getRowView (
const RowInfo& rowInfo)
const;
4321 Kokkos::View<impl_scalar_type*, execution_space, Kokkos::MemoryUnmanaged>
4322 getRowViewNonConst (
const RowInfo& rowInfo)
const;
4328 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4343 void fillLocalMatrix (
const Teuchos::RCP<Teuchos::ParameterList>& params);
4367 Teuchos::RCP<const Graph> staticGraph_;
4368 Teuchos::RCP< Graph> myGraph_;
4390 Details::STORAGE_1D_UNPACKED;
4422 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4437 template<
class ViewType,
class OffsetViewType>
4438 struct pack_functor {
4442 OffsetViewType src_offset_;
4443 OffsetViewType dst_offset_;
4444 typedef typename OffsetViewType::non_const_value_type scalar_index_type;
4446 pack_functor (ViewType dst, ViewType src,
4447 OffsetViewType dst_offset, OffsetViewType src_offset) :
4450 src_offset_ (src_offset),
4451 dst_offset_ (dst_offset)
4454 KOKKOS_INLINE_FUNCTION
4455 void operator () (
const LocalOrdinal row)
const {
4456 scalar_index_type srcPos = src_offset_(row);
4457 const scalar_index_type dstEnd = dst_offset_(row+1);
4458 scalar_index_type dstPos = dst_offset_(row);
4459 for ( ; dstPos < dstEnd; ++dstPos, ++srcPos) {
4460 dst_(dstPos) = src_(srcPos);
4470 template<
class Scalar,
4472 class GlobalOrdinal,
4474 Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4477 const size_t maxNumEntriesPerRow = 0,
4478 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
4482 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE;
4483 return Teuchos::rcp(
new matrix_type(map, maxNumEntriesPerRow,
4487 template<
class CrsMatrixType>
4488 Teuchos::RCP<CrsMatrixType>
4490 const Import<
typename CrsMatrixType::local_ordinal_type,
4491 typename CrsMatrixType::global_ordinal_type,
4492 typename CrsMatrixType::node_type>& importer,
4493 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4494 typename CrsMatrixType::global_ordinal_type,
4495 typename CrsMatrixType::node_type> >& domainMap,
4496 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4497 typename CrsMatrixType::global_ordinal_type,
4498 typename CrsMatrixType::node_type> >& rangeMap,
4499 const Teuchos::RCP<Teuchos::ParameterList>& params)
4501 Teuchos::RCP<CrsMatrixType> destMatrix;
4502 sourceMatrix->importAndFillComplete (destMatrix, importer, domainMap, rangeMap, params);
4506 template<
class CrsMatrixType>
4507 Teuchos::RCP<CrsMatrixType>
4509 const Import<
typename CrsMatrixType::local_ordinal_type,
4510 typename CrsMatrixType::global_ordinal_type,
4511 typename CrsMatrixType::node_type>& rowImporter,
4512 const Import<
typename CrsMatrixType::local_ordinal_type,
4513 typename CrsMatrixType::global_ordinal_type,
4514 typename CrsMatrixType::node_type>& domainImporter,
4515 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4516 typename CrsMatrixType::global_ordinal_type,
4517 typename CrsMatrixType::node_type> >& domainMap,
4518 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4519 typename CrsMatrixType::global_ordinal_type,
4520 typename CrsMatrixType::node_type> >& rangeMap,
4521 const Teuchos::RCP<Teuchos::ParameterList>& params)
4523 Teuchos::RCP<CrsMatrixType> destMatrix;
4524 sourceMatrix->importAndFillComplete (destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
4528 template<
class CrsMatrixType>
4529 Teuchos::RCP<CrsMatrixType>
4531 const Export<
typename CrsMatrixType::local_ordinal_type,
4532 typename CrsMatrixType::global_ordinal_type,
4533 typename CrsMatrixType::node_type>& exporter,
4534 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4535 typename CrsMatrixType::global_ordinal_type,
4536 typename CrsMatrixType::node_type> >& domainMap,
4537 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4538 typename CrsMatrixType::global_ordinal_type,
4539 typename CrsMatrixType::node_type> >& rangeMap,
4540 const Teuchos::RCP<Teuchos::ParameterList>& params)
4542 Teuchos::RCP<CrsMatrixType> destMatrix;
4543 sourceMatrix->exportAndFillComplete (destMatrix, exporter, domainMap, rangeMap, params);
4547 template<
class CrsMatrixType>
4548 Teuchos::RCP<CrsMatrixType>
4550 const Export<
typename CrsMatrixType::local_ordinal_type,
4551 typename CrsMatrixType::global_ordinal_type,
4552 typename CrsMatrixType::node_type>& rowExporter,
4553 const Export<
typename CrsMatrixType::local_ordinal_type,
4554 typename CrsMatrixType::global_ordinal_type,
4555 typename CrsMatrixType::node_type>& domainExporter,
4556 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4557 typename CrsMatrixType::global_ordinal_type,
4558 typename CrsMatrixType::node_type> >& domainMap,
4559 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4560 typename CrsMatrixType::global_ordinal_type,
4561 typename CrsMatrixType::node_type> >& rangeMap,
4562 const Teuchos::RCP<Teuchos::ParameterList>& params)
4564 Teuchos::RCP<CrsMatrixType> destMatrix;
4565 sourceMatrix->exportAndFillComplete (destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
4578 #endif // TPETRA_CRSMATRIX_DECL_HPP
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
bool hasColMap() const override
Whether the matrix has a well-defined column Map.
global_size_t getGlobalNumCols() const override
The number of global columns in the matrix.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
Abstract interface for local operators (e.g., matrices and preconditioners).
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
size_t getNodeNumCols() const override
The number of columns connected to the locally owned rows of this matrix.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
The CrsGraph specialization suitable for this CrsMatrix specialization.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
virtual bool supportsRowViews() const override
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
LocalOrdinal getViewRaw(impl_scalar_type *&vals, LocalOrdinal &numEnt, const RowInfo &rowinfo) const
Nonconst pointer to all entries (including extra space) in the given row.
void replaceDomainMapAndImporter(const Teuchos::RCP< const map_type > &newDomainMap, Teuchos::RCP< const import_type > &newImporter)
Replace the current domain Map and Import with the given objects.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type > local_graph_type
The type of the part of the sparse graph on each MPI process.
std::enable_if<!std::is_same< OutputScalarType, impl_scalar_type >::value &&std::is_convertible< impl_scalar_type, OutputScalarType >::value, LocalOrdinal >::type getLocalRowView(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const OutputScalarType *&val, const LocalOrdinal *&ind) const
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices...
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, device_type, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
global_size_t getGlobalNumRows() const override
Number of global elements in the row map of this matrix.
std::map< GlobalOrdinal, std::pair< Teuchos::Array< GlobalOrdinal >, Teuchos::Array< Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
void sortAndMergeIndicesAndValues(const bool sorted, const bool merged)
Sort and merge duplicate local column indices in all rows on the calling process, along with their co...
typename device_type::execution_space execution_space
The Kokkos execution space.
void getLocalRowCopy(LocalOrdinal localRow, const Teuchos::ArrayView< LocalOrdinal > &colInds, const Teuchos::ArrayView< Scalar > &vals, size_t &numEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row...
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
size_t getNumVectors() const
Number of columns in the multivector.
size_t getLocalLength() const
Local number of rows on the calling process.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
One or more distributed dense vectors.
size_t getNodeNumEntries() const override
The local number of entries in this matrix.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
size_t getNodeNumRows() const override
The number of matrix rows owned by the calling process.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the left with the given Vector.
GlobalOrdinal global_ordinal_type
The type of each global index in the matrix.
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
virtual ~CrsMatrix()=default
Destructor (virtual for memory safety of derived classes).
void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< char *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, Distributor &distor, const CombineMode CM) override
Unpack the imported column indices and values, and combine into matrix.
void reindexColumns(crs_graph_type *const graph, const Teuchos::RCP< const map_type > &newColMap, const Teuchos::RCP< const import_type > &newImport=Teuchos::null, const bool sortEachRow=true)
Reindex the column indices in place, and replace the column Map. Optionally, replace the Import objec...
Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization suitable for this CrsMatrix specialization.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row...
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, over all processes in the matrix's communicator...
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T...
Scalar scalar_type
The type of each entry in the matrix.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
void swap(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix)
Swaps the data from *this with the data and maps from crsMatrix.
void fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local matrix.
void globalAssemble()
Communicate nonlocal contributions to other processes.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const override
Get a copy of the diagonal entries of the matrix.
std::shared_ptr< local_multiply_op_type > lclMatrix_
The local sparse matrix, wrapped in a multiply operator.
void gaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
"Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
bool isFillActive() const
Whether the matrix is not fill complete.
Teuchos::RCP< MV > importMV_
Column Map MultiVector used in apply() and gaussSeidel().
typename Kokkos::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
size_t global_size_t
Global size_t object.
bool hasTransposeApply() const override
Whether apply() allows applying the transpose or conjugate transpose.
void clearGlobalConstants()
Clear matrix properties that require collectives.
void gaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of gaussSeidel(), with fewer requirements on X.
LocalOrdinal getLocalRowViewRaw(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const LocalOrdinal *&lclColInds, const Scalar *&vals) const override
Get a constant, nonpersisting, locally indexed view of the given row of the matrix, using "raw" pointers instead of Teuchos::ArrayView.
LocalOrdinal transformLocalValues(const LocalOrdinal lclRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault) const
Transform CrsMatrix entries in place, using local indices to select the entries in the row to transfo...
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const export_type &exporter, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Export from this to the given destination matrix, and make the result fill complete.
local_matrix_type::values_type k_values1D_
Sparse matrix values, as part of compressed sparse row ("1-D") storage.
bool isFillComplete() const override
Whether the matrix is fill complete.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which the matrix is distributed.
void sync_host()
Synchronize to Host.
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const import_type &importer, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Import from this to the given destination matrix, and make the result fill complete.
local_ordinal_type replaceGlobalValues(const global_ordinal_type globalRow, const Kokkos::View< const global_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals) const
Replace one or more entries' values, using global indices.
Abstract interface for operators (e.g., matrices and preconditioners).
void packNew(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< char *, buffer_device_type > &exports, const Kokkos::DualView< size_t *, buffer_device_type > &numPacketsPerLID, size_t &constantNumPackets, Distributor &dist) const
Pack this object's data for an Import or Export.
void reorderedGaussSeidelCopy(MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of reorderedGaussSeidel(), with fewer requirements on X.
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
local_ordinal_type replaceLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals) const
Replace one or more entries' values, using local row and column indices.
GlobalOrdinal getIndexBase() const override
The index base for global indices for this matrix.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
typename crs_graph_type::local_graph_type local_graph_type
The part of the sparse matrix's graph on each MPI process.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Create an empty CrsMatrix given a row map and a single integer upper bound on the number of stored en...
Node node_type
This class' Kokkos Node type.
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
Keep track of how much more space a CrsGraph or CrsMatrix needs, when the graph or matrix is the targ...
Sets up and executes a communication plan for a Tpetra DistObject.
mag_type frobNorm_
Cached Frobenius norm of the (global) matrix.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print this object with the given verbosity level to the given output stream.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const override
This matrix's graph, as a RowGraph.
CombineMode
Rule for combining data in an Import or Export.
DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
bool isGloballyIndexed() const override
Whether the matrix is globally indexed on the calling process.
Forward declaration of Tpetra::CrsMatrix.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using global indices.
void localGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const RangeScalar &dampingFactor, const ESweepDirection direction) const
Gauss-Seidel or SOR on .
bool fillComplete_
Whether the matrix is fill complete.
virtual Teuchos::RCP< RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms) const override
Implementation of RowMatrix::add: return alpha*A + beta*this.
local_ordinal_type sumIntoLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals, const bool atomic=useAtomicUpdatesByDefault) const
Sum into one or more sparse matrix entries, using local row and column indices.
Abstract base class for objects that can be the source of an Import or Export operation.
typename Node::device_type device_type
The Kokkos device type.
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Number of entries in the sparse matrix in the given local row, on the calling (MPI) process...
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
std::string description() const override
A one-line description of this object.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
Compute a sparse matrix-MultiVector multiply.
void computeGlobalConstants()
Compute matrix properties that require collectives.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
void insertGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using global column indices.
void modify_host()
Mark data as modified on the host side.
local_matrix_type::values_type getLocalValuesView() const
Get the Kokkos local values.
ProfileType getProfileType() const
Returns true if the matrix was allocated with static data structures.
void getGlobalRowView(GlobalOrdinal GlobalRow, Teuchos::ArrayView< const GlobalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const override
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices...
LocalOrdinal transformGlobalValues(const GlobalOrdinal gblRow, const Kokkos::View< const GlobalOrdinal *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputInds, const Kokkos::View< const impl_scalar_type *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault) const
Transform CrsMatrix entries in place, using global indices to select the entries in the row to transf...
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
void insertLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using local column indices.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
A parallel distribution of indices over processes.
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
Teuchos::ArrayView< const impl_scalar_type > getView(RowInfo rowinfo) const
Constant view of all entries (including extra space) in the given row.
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_graph_type::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
Set the local matrix using three (compressed sparse row) arrays.
Details::EStorageStatus storageStatus_
Status of the matrix's storage, when not in a fill-complete state.
A read-only, row-oriented interface to a sparse matrix.
local_matrix_type getLocalMatrix() const
The local sparse matrix.
void getLocalRowView(LocalOrdinal LocalRow, Teuchos::ArrayView< const LocalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const override
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices...
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the right with the given Vector.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
A distributed dense vector.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
void applyTranspose(const MV &X_in, MV &Y_in, const Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
Special case of apply() for mode != Teuchos::NO_TRANS.
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas, const bool verbose)
Allocate values (and optionally indices) using the Node.
void expertStaticFillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer=Teuchos::null, const Teuchos::RCP< const export_type > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Perform a fillComplete on a matrix that already has data.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Number of entries in the sparse matrix in the given global row, on the calling (MPI) process...
void residual(const Operator< SC, LO, GO, NO > &A, const MultiVector< SC, LO, GO, NO > &X, const MultiVector< SC, LO, GO, NO > &B, MultiVector< SC, LO, GO, NO > &R)
Computes R = B - A * X.
size_t mergeRowIndicesAndValues(crs_graph_type &graph, const RowInfo &rowInfo)
Merge duplicate row indices in the given row, along with their corresponding values.
bool isLocallyIndexed() const override
Whether the matrix is locally indexed on the calling process.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
void reorderedGaussSeidel(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps) const
Reordered "Hybrid" Jacobi + (Gauss-Seidel or SOR) on .
friend void batchedApply(const MatrixArray &Matrices, const typename std::remove_pointer< typename MultiVectorArray::value_type >::type &X, MultiVectorArray &Y, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type alpha, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type beta, Teuchos::RCP< Teuchos::ParameterList > params)
Does multiply matrix apply() calls with a single X vector.
Teuchos::ArrayView< impl_scalar_type > getViewNonConst(const RowInfo &rowinfo) const
Nonconst view of all entries (including extra space) in the given row.
Base class for distributed Tpetra objects that support data redistribution.
std::shared_ptr< local_multiply_op_type > getLocalMultiplyOperator() const
The local sparse matrix operator (a wrapper of getLocalMatrix() that supports local matrix-vector mul...
LocalOrdinal local_ordinal_type
The type of each local index in the matrix.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
mag_type getFrobeniusNorm() const override
Compute and return the Frobenius norm of the matrix.
void localApply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, const Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar &alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar &beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Compute the local part of a sparse matrix-(Multi)Vector multiply.
void reorderedLocalGaussSeidel(const MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &D, const Teuchos::ArrayView< LocalOrdinal > &rowIndices, const RangeScalar &dampingFactor, const ESweepDirection direction) const
Reordered Gauss-Seidel or SOR on .
LocalOrdinal getViewRawConst(const impl_scalar_type *&vals, LocalOrdinal &numEnt, const RowInfo &rowinfo) const
Const pointer to all entries (including extra space) in the given row.
bool isStorageOptimized() const
Returns true if storage has been optimized.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
Teuchos::RCP< MV > exportMV_
Row Map MultiVector used in apply().
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.
global_size_t getGlobalNumEntries() const override
The global number of entries in this matrix.