10#ifndef TPETRA_CRSMATRIX_DECL_HPP
11#define TPETRA_CRSMATRIX_DECL_HPP
18#include "KokkosSparse_Utils.hpp"
19#include "KokkosSparse_CrsMatrix.hpp"
20#include "Tpetra_Details_MatrixApplyHelper.hpp"
21#include "Tpetra_RowMatrix_decl.hpp"
22#include "Tpetra_Exceptions.hpp"
23#include "Tpetra_DistObject.hpp"
24#include "Tpetra_CrsGraph.hpp"
25#include "Tpetra_Vector.hpp"
27#include "Tpetra_Details_ExecutionSpacesUser.hpp"
28#include "Teuchos_DataAccess.hpp"
35template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36class crsMatrix_Swap_Tester;
89template <
class CrsMatrixType>
90Teuchos::RCP<CrsMatrixType>
92 const Import<
typename CrsMatrixType::local_ordinal_type,
93 typename CrsMatrixType::global_ordinal_type,
94 typename CrsMatrixType::node_type>&
importer,
95 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
96 typename CrsMatrixType::global_ordinal_type,
97 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
98 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
99 typename CrsMatrixType::global_ordinal_type,
100 typename CrsMatrixType::node_type> >&
rangeMap = Teuchos::null,
101 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
156template <
class CrsMatrixType>
157Teuchos::RCP<CrsMatrixType>
159 const Import<
typename CrsMatrixType::local_ordinal_type,
160 typename CrsMatrixType::global_ordinal_type,
162 const Import<
typename CrsMatrixType::local_ordinal_type,
163 typename CrsMatrixType::global_ordinal_type,
165 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
166 typename CrsMatrixType::global_ordinal_type,
167 typename CrsMatrixType::node_type> >& domainMap,
168 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
169 typename CrsMatrixType::global_ordinal_type,
170 typename CrsMatrixType::node_type> >&
rangeMap,
171 const Teuchos::RCP<Teuchos::ParameterList>&
params);
206template <
class CrsMatrixType>
207Teuchos::RCP<CrsMatrixType>
209 const Export<
typename CrsMatrixType::local_ordinal_type,
210 typename CrsMatrixType::global_ordinal_type,
211 typename CrsMatrixType::node_type>&
exporter,
212 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
213 typename CrsMatrixType::global_ordinal_type,
214 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
215 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
216 typename CrsMatrixType::global_ordinal_type,
217 typename CrsMatrixType::node_type> >&
rangeMap = Teuchos::null,
218 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
253template <
class CrsMatrixType>
254Teuchos::RCP<CrsMatrixType>
256 const Export<
typename CrsMatrixType::local_ordinal_type,
257 typename CrsMatrixType::global_ordinal_type,
259 const Export<
typename CrsMatrixType::local_ordinal_type,
260 typename CrsMatrixType::global_ordinal_type,
262 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
263 typename CrsMatrixType::global_ordinal_type,
264 typename CrsMatrixType::node_type> >& domainMap,
265 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
266 typename CrsMatrixType::global_ordinal_type,
267 typename CrsMatrixType::node_type> >&
rangeMap,
268 const Teuchos::RCP<Teuchos::ParameterList>&
params);
273template <
class SC,
class LO,
class GO,
class NO>
398 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>,
456 using mag_type =
typename KokkosKernels::ArithTraits<impl_scalar_type>::mag_type;
472 typename local_graph_device_type::size_type>;
473 using local_matrix_host_type =
474 typename local_matrix_device_type::host_mirror_type;
476 using row_ptrs_device_view_type =
477 typename row_matrix_type::row_ptrs_device_view_type;
478 using row_ptrs_host_view_type =
479 typename row_matrix_type::row_ptrs_host_view_type;
481 using local_inds_device_view_type =
482 typename row_matrix_type::local_inds_device_view_type;
483 using local_inds_host_view_type =
484 typename row_matrix_type::local_inds_host_view_type;
485 using nonconst_local_inds_host_view_type =
486 typename row_matrix_type::nonconst_local_inds_host_view_type;
488 using global_inds_device_view_type =
489 typename row_matrix_type::global_inds_device_view_type;
490 using global_inds_host_view_type =
491 typename row_matrix_type::global_inds_host_view_type;
492 using nonconst_global_inds_host_view_type =
493 typename row_matrix_type::nonconst_global_inds_host_view_type;
495 using values_device_view_type =
496 typename row_matrix_type::values_device_view_type;
497 using values_host_view_type =
498 typename row_matrix_type::values_host_view_type;
499 using nonconst_values_host_view_type =
500 typename row_matrix_type::nonconst_values_host_view_type;
537 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
539 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
553 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
555 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
575 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
576 const Teuchos::RCP<const map_type>& colMap,
578 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
598 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
599 const Teuchos::RCP<const map_type>& colMap,
601 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
632 const Teuchos::RCP<const crs_graph_type>&
graph,
633 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
659 explicit CrsMatrix(
const Teuchos::RCP<const crs_graph_type>&
graph,
660 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
690 explicit CrsMatrix(
const Teuchos::RCP<const crs_graph_type>&
graph,
691 const typename local_matrix_device_type::values_type&
values,
692 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
720 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
721 const Teuchos::RCP<const map_type>& colMap,
722 const typename local_graph_device_type::row_map_type&
rowPointers,
723 const typename local_graph_device_type::entries_type::non_const_type&
columnIndices,
724 const typename local_matrix_device_type::values_type&
values,
725 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
753 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
754 const Teuchos::RCP<const map_type>& colMap,
757 const Teuchos::ArrayRCP<Scalar>&
values,
758 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
781 CrsMatrix(
const Teuchos::RCP<const map_type>& rowMap,
782 const Teuchos::RCP<const map_type>& colMap,
784 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
817 const Teuchos::RCP<const map_type>& rowMap,
818 const Teuchos::RCP<const map_type>& colMap,
819 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
820 const Teuchos::RCP<const map_type>&
rangeMap = Teuchos::null,
821 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
828 const Teuchos::RCP<const map_type>& rowMap,
829 const Teuchos::RCP<const map_type>& colMap,
830 const Teuchos::RCP<const map_type>& domainMap,
831 const Teuchos::RCP<const map_type>&
rangeMap,
832 const Teuchos::RCP<const import_type>&
importer,
833 const Teuchos::RCP<const export_type>&
exporter,
834 const Teuchos::RCP<Teuchos::ParameterList>&
params =
855 template <
class S2,
class LO2,
class GO2,
class N2>
859 template <
class S2,
class LO2,
class GO2,
class N2>
866 template <
class MatrixArray,
class MultiVectorArray>
868 const typename std::remove_pointer<typename MultiVectorArray::value_type>::type&
X,
870 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type
alpha,
871 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type
beta,
872 Teuchos::RCP<Teuchos::ParameterList>
params);
946 const Teuchos::ArrayView<const GlobalOrdinal>&
cols,
947 const Teuchos::ArrayView<const Scalar>&
vals);
1013 const Teuchos::ArrayView<const LocalOrdinal>&
cols,
1014 const Teuchos::ArrayView<const Scalar>&
vals,
1103 const Kokkos::View<const global_ordinal_type*, Kokkos::AnonymousSpace>&
inputInds,
1104 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>&
inputVals);
1110 const Teuchos::ArrayView<const GlobalOrdinal>&
cols,
1111 const Teuchos::ArrayView<const Scalar>&
vals);
1192 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>&
inputInds,
1193 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>&
inputVals);
1200 const Teuchos::ArrayView<const LocalOrdinal>&
cols,
1201 const Teuchos::ArrayView<const Scalar>&
vals);
1231 static const bool useAtomicUpdatesByDefault =
1232#ifdef KOKKOS_ENABLE_SERIAL
1233 !std::is_same<execution_space, Kokkos::Serial>::value;
1269 const bool atomic = useAtomicUpdatesByDefault);
1310 const Teuchos::ArrayView<const GlobalOrdinal>&
cols,
1311 const Teuchos::ArrayView<const Scalar>&
vals,
1312 const bool atomic = useAtomicUpdatesByDefault);
1341 const bool atomic = useAtomicUpdatesByDefault);
1364 const bool atomic = useAtomicUpdatesByDefault);
1406 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>&
inputInds,
1407 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>&
inputVals,
1408 const bool atomic = useAtomicUpdatesByDefault);
1441 const Teuchos::ArrayView<const LocalOrdinal>&
cols,
1442 const Teuchos::ArrayView<const Scalar>&
vals,
1443 const bool atomic = useAtomicUpdatesByDefault);
1471 const bool atomic = useAtomicUpdatesByDefault);
1512 const bool atomic = useAtomicUpdatesByDefault);
1552 const bool atomic = useAtomicUpdatesByDefault);
1586 const bool atomic = useAtomicUpdatesByDefault);
1620 const bool atomic = useAtomicUpdatesByDefault);
1671 const typename UnmanagedView<LocalIndicesViewType>::type&
inputInds,
1672 const typename UnmanagedView<ImplScalarViewType>::type&
inputVals,
1674 const bool atomic = useAtomicUpdatesByDefault) {
1681 static_assert(Kokkos::is_view<LocalIndicesViewType>::value,
1682 "First template parameter LocalIndicesViewType must be "
1684 static_assert(Kokkos::is_view<ImplScalarViewType>::value,
1685 "Second template parameter ImplScalarViewType must be a "
1687 static_assert(
static_cast<int>(LocalIndicesViewType::rank) == 1,
1688 "First template parameter LocalIndicesViewType must "
1690 static_assert(
static_cast<int>(ImplScalarViewType::rank) == 1,
1691 "Second template parameter ImplScalarViewType must have "
1693 static_assert(std::is_same<
1694 typename LocalIndicesViewType::non_const_value_type,
1696 "First template parameter LocalIndicesViewType must "
1697 "contain values of type local_ordinal_type.");
1698 static_assert(std::is_same<
1699 typename ImplScalarViewType::non_const_value_type,
1701 "Second template parameter ImplScalarViewType must "
1702 "contain values of type impl_scalar_type.");
1706 return Teuchos::OrdinalTraits<LO>::invalid();
1708 return this->transformLocalValues(
lclRow,
1757 template <
class BinaryFunction,
class InputMemorySpace>
1767 const bool atomic = useAtomicUpdatesByDefault) {
1771 return Teuchos::OrdinalTraits<LO>::invalid();
1773 return this->transformGlobalValues(
gblRow,
1812 setAllValues(
const typename local_graph_device_type::row_map_type&
ptr,
1813 const typename local_graph_device_type::entries_type::non_const_type&
ind,
1814 const typename local_matrix_device_type::values_type&
val);
1865 const Teuchos::ArrayRCP<LocalOrdinal>&
ind,
1866 const Teuchos::ArrayRCP<Scalar>&
val);
1927 void resumeFill(
const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
1987 fillComplete(
const Teuchos::RCP<const map_type>& domainMap,
1988 const Teuchos::RCP<const map_type>&
rangeMap,
1989 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
2048 const Teuchos::RCP<const map_type>&
rangeMap,
2049 const Teuchos::RCP<const import_type>&
importer = Teuchos::null,
2050 const Teuchos::RCP<const export_type>&
exporter = Teuchos::null,
2051 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null);
2156 const Teuchos::RCP<const map_type>&
newColMap,
2157 const Teuchos::RCP<const import_type>&
newImport = Teuchos::null,
2239 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
2242 Teuchos::RCP<const map_type>
getRowMap()
const override;
2245 Teuchos::RCP<const map_type>
getColMap()
const override;
2248 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2252 Teuchos::RCP<const crs_graph_type>
getCrsGraph()
const;
2268#if __armclang_major__ == 22 && __armclang_minor__ == 1
2273#define TPETRA_DETAILS_ALWAYS_INLINE __attribute__((always_inline))
2275#define TPETRA_DETAILS_ALWAYS_INLINE
2291 local_matrix_host_type getLocalMatrixHost()
const;
2292#undef TPETRA_DETAILS_ALWAYS_INLINE
2522 using values_dualv_type =
2523 Kokkos::DualView<impl_scalar_type*, device_type>;
2524 using values_wdv_type =
2526 values_wdv_type valuesUnpacked_wdv;
2527 mutable values_wdv_type valuesPacked_wdv;
2580 nonconst_global_inds_host_view_type&
Indices,
2581 nonconst_values_host_view_type&
Values,
2600 nonconst_local_inds_host_view_type&
Indices,
2601 nonconst_values_host_view_type&
Values,
2619 global_inds_host_view_type& indices,
2620 values_host_view_type&
values)
const override;
2636 local_inds_host_view_type& indices,
2637 values_host_view_type&
values)
const override;
2725 Kokkos::MemoryUnmanaged>& offsets)
const;
2751 const Teuchos::ArrayView<const size_t>& offsets)
const;
2835 const Teuchos::ETransp
mode = Teuchos::NO_TRANS,
2836 const Scalar&
alpha = Teuchos::ScalarTraits<Scalar>::one(),
2837 const Scalar&
beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
2842 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
2862 Teuchos::ETransp
mode = Teuchos::NO_TRANS,
2863 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
2864 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const override;
2876 Teuchos::RCP<const map_type>
getDomainMap()
const override;
2884 Teuchos::RCP<const map_type>
getRangeMap()
const override;
2900 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
2906 const Teuchos::RCP<Teuchos::ParameterList>&
params)
const override;
2919 const Teuchos::EVerbosityLevel
verbLevel =
2920 Teuchos::Describable::verbLevel_default)
const override;
2939 const bool verbose);
2943 copyAndPermuteStaticGraph(
2945 const size_t numSameIDs,
2948 const size_t numPermutes);
2951 copyAndPermuteNonStaticGraph(
2953 const size_t numSameIDs,
2954 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>&
permuteToLIDs_dv,
2955 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>&
permuteFromLIDs_dv,
2956 const size_t numPermutes);
2965 const size_t numSameIDs,
2966 const Kokkos::DualView<
2969 const Kokkos::DualView<
2976 const Kokkos::DualView<
2979 Kokkos::DualView<char*, buffer_device_type>& exports,
2992 unpackAndCombineImpl(
2995 Kokkos::DualView<char*, buffer_device_type> imports,
2999 const bool verbose);
3004 unpackAndCombineImplNonStatic(
3007 Kokkos::DualView<char*, buffer_device_type> imports,
3024 Kokkos::DualView<char*, buffer_device_type> imports,
3140 packNew(
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>&
exportLIDs,
3141 Kokkos::DualView<char*, buffer_device_type>& exports,
3153 packNonStaticNew(
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>&
exportLIDs,
3154 Kokkos::DualView<char*, buffer_device_type>& exports,
3188 packRow(
char exports[],
3253 const char imports[],
3268 allocatePackSpaceNew(Kokkos::DualView<char*, buffer_device_type>& exports,
3269 size_t& totalNumEntries,
3276 typename local_matrix_host_type::values_type::const_type
3278 return valuesPacked_wdv.getHostView(
s);
3282 typename local_matrix_host_type::values_type
3284 return valuesPacked_wdv.getHostView(
s);
3288 typename local_matrix_host_type::values_type
3290 return valuesPacked_wdv.getHostView(
s);
3294 typename local_matrix_device_type::values_type::const_type
3296 return valuesPacked_wdv.getDeviceView(
s);
3300 typename local_matrix_device_type::values_type
3302 return valuesPacked_wdv.getDeviceView(
s);
3306 typename local_matrix_device_type::values_type
3308 return valuesPacked_wdv.getDeviceView(
s);
3313 template <
class CrsMatrixType>
3314 friend Teuchos::RCP<CrsMatrixType>
3316 const Import<
typename CrsMatrixType::local_ordinal_type,
3317 typename CrsMatrixType::global_ordinal_type,
3318 typename CrsMatrixType::node_type>&
importer,
3319 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3320 typename CrsMatrixType::global_ordinal_type,
3321 typename CrsMatrixType::node_type> >& domainMap,
3322 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3323 typename CrsMatrixType::global_ordinal_type,
3324 typename CrsMatrixType::node_type> >&
rangeMap,
3325 const Teuchos::RCP<Teuchos::ParameterList>&
params);
3328 template <
class CrsMatrixType>
3329 friend Teuchos::RCP<CrsMatrixType>
3331 const Import<
typename CrsMatrixType::local_ordinal_type,
3332 typename CrsMatrixType::global_ordinal_type,
3334 const Import<
typename CrsMatrixType::local_ordinal_type,
3335 typename CrsMatrixType::global_ordinal_type,
3337 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3338 typename CrsMatrixType::global_ordinal_type,
3339 typename CrsMatrixType::node_type> >& domainMap,
3340 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3341 typename CrsMatrixType::global_ordinal_type,
3342 typename CrsMatrixType::node_type> >&
rangeMap,
3343 const Teuchos::RCP<Teuchos::ParameterList>&
params);
3346 template <
class CrsMatrixType>
3347 friend Teuchos::RCP<CrsMatrixType>
3349 const Export<
typename CrsMatrixType::local_ordinal_type,
3350 typename CrsMatrixType::global_ordinal_type,
3351 typename CrsMatrixType::node_type>&
exporter,
3352 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3353 typename CrsMatrixType::global_ordinal_type,
3354 typename CrsMatrixType::node_type> >& domainMap,
3355 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3356 typename CrsMatrixType::global_ordinal_type,
3357 typename CrsMatrixType::node_type> >&
rangeMap,
3358 const Teuchos::RCP<Teuchos::ParameterList>&
params);
3361 template <
class CrsMatrixType>
3362 friend Teuchos::RCP<CrsMatrixType>
3364 const Export<
typename CrsMatrixType::local_ordinal_type,
3365 typename CrsMatrixType::global_ordinal_type,
3367 const Export<
typename CrsMatrixType::local_ordinal_type,
3368 typename CrsMatrixType::global_ordinal_type,
3370 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3371 typename CrsMatrixType::global_ordinal_type,
3372 typename CrsMatrixType::node_type> >& domainMap,
3373 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
3374 typename CrsMatrixType::global_ordinal_type,
3375 typename CrsMatrixType::node_type> >&
rangeMap,
3376 const Teuchos::RCP<Teuchos::ParameterList>&
params);
3397 const Teuchos::RCP<const map_type>& domainMap,
3398 const Teuchos::RCP<const map_type>&
rangeMap,
3399 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null)
const;
3420 const Teuchos::RCP<const map_type>& domainMap,
3421 const Teuchos::RCP<const map_type>&
rangeMap,
3422 const Teuchos::RCP<Teuchos::ParameterList>&
params)
const;
3442 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3443 const Teuchos::RCP<const map_type>&
rangeMap = Teuchos::null,
3444 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null)
const;
3465 const Teuchos::RCP<const map_type>& domainMap,
3466 const Teuchos::RCP<const map_type>&
rangeMap,
3467 const Teuchos::RCP<Teuchos::ParameterList>&
params)
const;
3492 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>&
rowTransfer,
3493 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> >&
domainTransfer,
3494 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3495 const Teuchos::RCP<const map_type>&
rangeMap = Teuchos::null,
3496 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null)
const;
3528 insertGlobalValuesFiltered(
3530 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3531 const Teuchos::ArrayView<const Scalar>&
values,
3537 insertGlobalValuesFilteredChecked(
3539 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3540 const Teuchos::ArrayView<const Scalar>&
values,
3541 const char*
const prefix,
3543 const bool verbose);
3557 combineGlobalValues(
3559 const Teuchos::ArrayView<const GlobalOrdinal>&
columnIndices,
3560 const Teuchos::ArrayView<const Scalar>&
values,
3562 const char*
const prefix,
3564 const bool verbose);
3593 const char*
const prefix,
3595 const bool verbose);
3608 template <
class BinaryFunction>
3611 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3612 const Teuchos::ArrayView<const Scalar>&
values,
3614 const bool atomic = useAtomicUpdatesByDefault) {
3619 const LO
numInputEnt =
static_cast<LO
>(indices.size());
3621 return Teuchos::OrdinalTraits<LO>::invalid();
3624 const GO*
const inputCols = indices.getRawPtr();
3625 const IST*
const inputVals =
3626 reinterpret_cast<const IST*
>(values.getRawPtr());
3627 return this->transformGlobalValues(globalRow, numInputEnt, inputVals,
3628 inputCols, f, atomic);
3638 insertNonownedGlobalValues(
const GlobalOrdinal globalRow,
3639 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3640 const Teuchos::ArrayView<const Scalar>& values);
3687 const typename crs_graph_type::SLocalGlobalViews& newInds,
3688 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
3689 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
3690 const ELocalGlobal lg,
3691 const ELocalGlobal I);
3695 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3696 typedef KokkosKernels::ArithTraits<impl_scalar_type> STS;
3697 typedef KokkosKernels::ArithTraits<mag_type> STM;
3698 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
3699 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
3703 enum GraphAllocationStatus {
3704 GraphAlreadyAllocated,
3705 GraphNotYetAllocated
3728 const bool verbose);
3802 const bool force =
false)
const;
3827 const bool force =
false)
const;
3840 const Teuchos::ETransp
mode,
3848 typename values_dualv_type::t_host::const_type
3853 typename values_dualv_type::t_dev::const_type
3858 typename values_dualv_type::t_host
3863 typename values_dualv_type::t_dev
3871 using local_matrix_int_rowptrs_device_type =
3881 local_matrix_int_rowptrs_device_type,
3882 typename MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::device_view_type>;
3884 std::shared_ptr<ApplyHelper> getApplyHelper()
const {
3887 applyHelper = std::make_shared<ApplyHelper>(A_lcl.nnz(), A_lcl.graph.row_map);
3894 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
3898 template <
typename S,
typename LO,
typename GO,
typename NODE,
typename LOV>
3899 friend struct Tpetra::MMdetails::KernelWrappers;
3900 template <
typename S,
typename LO,
typename GO,
typename NODE,
typename LOV>
3901 friend struct Tpetra::MMdetails::KernelWrappers2;
3904 friend void Tpetra::MMdetails::import_and_extract_views<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
3905 const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
3906 Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node> > targetMap,
3907 CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
3908 Teuchos::RCP<
const Import<LocalOrdinal, GlobalOrdinal, Node> > prototypeImporter,
3909 bool userAssertsThereAreNoRemotes,
3910 const std::string& label,
3911 const Teuchos::RCP<Teuchos::ParameterList>& params);
3916 void swap(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix);
3924 void fillLocalMatrix(
const Teuchos::RCP<Teuchos::ParameterList>& params);
3948 Teuchos::RCP<const Graph> staticGraph_;
3949 Teuchos::RCP<Graph> myGraph_;
3963 Details::STORAGE_1D_UNPACKED;
3995 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
3996 Teuchos::Array<Scalar> > >
4005 mutable std::shared_ptr<ApplyHelper> applyHelper;
4014 struct pack_functor {
4020 typedef typename DestOffsetViewType::non_const_value_type scalar_index_type;
4028 , src_offset_(src_offset)
4033 scalar_index_type
srcPos = src_offset_(row);
4034 const scalar_index_type
dstEnd = dst_offset_(row + 1);
4035 scalar_index_type
dstPos = dst_offset_(row);
4047template <
class Scalar,
4049 class GlobalOrdinal,
4051Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4055 const Teuchos::RCP<Teuchos::ParameterList>&
params = Teuchos::null) {
4062template <
class CrsMatrixType>
4063Teuchos::RCP<CrsMatrixType>
4065 const Import<
typename CrsMatrixType::local_ordinal_type,
4066 typename CrsMatrixType::global_ordinal_type,
4067 typename CrsMatrixType::node_type>&
importer,
4068 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4069 typename CrsMatrixType::global_ordinal_type,
4070 typename CrsMatrixType::node_type> >& domainMap,
4071 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4072 typename CrsMatrixType::global_ordinal_type,
4073 typename CrsMatrixType::node_type> >&
rangeMap,
4074 const Teuchos::RCP<Teuchos::ParameterList>&
params) {
4080template <
class CrsMatrixType>
4081Teuchos::RCP<CrsMatrixType>
4083 const Import<
typename CrsMatrixType::local_ordinal_type,
4084 typename CrsMatrixType::global_ordinal_type,
4086 const Import<
typename CrsMatrixType::local_ordinal_type,
4087 typename CrsMatrixType::global_ordinal_type,
4089 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4090 typename CrsMatrixType::global_ordinal_type,
4091 typename CrsMatrixType::node_type> >& domainMap,
4092 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4093 typename CrsMatrixType::global_ordinal_type,
4094 typename CrsMatrixType::node_type> >&
rangeMap,
4095 const Teuchos::RCP<Teuchos::ParameterList>&
params) {
4101template <
class CrsMatrixType>
4102Teuchos::RCP<CrsMatrixType>
4104 const Export<
typename CrsMatrixType::local_ordinal_type,
4105 typename CrsMatrixType::global_ordinal_type,
4106 typename CrsMatrixType::node_type>&
exporter,
4107 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4108 typename CrsMatrixType::global_ordinal_type,
4109 typename CrsMatrixType::node_type> >& domainMap,
4110 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4111 typename CrsMatrixType::global_ordinal_type,
4112 typename CrsMatrixType::node_type> >&
rangeMap,
4113 const Teuchos::RCP<Teuchos::ParameterList>&
params) {
4119template <
class CrsMatrixType>
4120Teuchos::RCP<CrsMatrixType>
4122 const Export<
typename CrsMatrixType::local_ordinal_type,
4123 typename CrsMatrixType::global_ordinal_type,
4125 const Export<
typename CrsMatrixType::local_ordinal_type,
4126 typename CrsMatrixType::global_ordinal_type,
4128 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4129 typename CrsMatrixType::global_ordinal_type,
4130 typename CrsMatrixType::node_type> >& domainMap,
4131 const Teuchos::RCP<
const Map<
typename CrsMatrixType::local_ordinal_type,
4132 typename CrsMatrixType::global_ordinal_type,
4133 typename CrsMatrixType::node_type> >&
rangeMap,
4134 const Teuchos::RCP<Teuchos::ParameterList>&
params) {
4146template <
class CrsMatrixType>
4148 typename Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitudeType
const&
threshold =
4149 Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitude(Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::zero())) {
Forward declaration of Tpetra::CrsMatrix.
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Forward declaration of some Tpetra Matrix Matrix objects.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
typename local_graph_device_type::host_mirror_type local_graph_host_type
The type of the part of the sparse graph on each MPI process.
KokkosSparse::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
The type of the part of the sparse graph on each MPI process.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
virtual void insertGlobalValuesImpl(crs_graph_type &graph, RowInfo &rowInfo, const GlobalOrdinal gblColInds[], const impl_scalar_type vals[], const size_t numInputEnt)
Common implementation detail of insertGlobalValues and insertGlobalValuesFiltered.
bool isGloballyIndexed() const override
Whether the matrix is globally indexed on the calling process.
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.
std::map< GlobalOrdinal, std::pair< Teuchos::Array< GlobalOrdinal >, Teuchos::Array< Scalar > > > nonlocals_
Nonlocal data added using insertGlobalValues().
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 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, const CombineMode CM) override
Unpack the imported column indices and values, and combine into matrix.
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment.
void replaceRangeMap(const Teuchos::RCP< const map_type > &newRangeMap)
Replace the current range Map with the given objects.
Details::EStorageStatus storageStatus_
Status of the matrix's storage, when not in a fill-complete state.
typename device_type::execution_space execution_space
The Kokkos execution space.
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
Special case of apply() for mode == Teuchos::NO_TRANS.
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.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
The CrsGraph specialization suitable for this CrsMatrix specialization.
Node node_type
This class' Kokkos Node type.
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)
Replace one or more entries' values, using global indices.
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 > &rowImporter, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainImporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, over all processes in the matrix's communicator.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &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,...
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 scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
GlobalOrdinal global_ordinal_type
The type of each global index in the matrix.
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...
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) const
Pack this object's data for an Import or Export.
size_t getLocalNumCols() const override
The number of columns connected to the locally owned rows of this matrix.
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
bool hasColMap() const override
Whether the matrix has a well-defined column Map.
row_ptrs_host_view_type getLocalRowPtrsHost() const
Get a host view of the CRS packed row pointers.
mag_type getNormInf() const
Compute and return the infinity norm of the matrix.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T.
values_dualv_type::t_dev getValuesViewDeviceNonConst(const RowInfo &rowinfo)
Get a non-const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myR...
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.
LocalOrdinal transformLocalValues(const LocalOrdinal lclRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault)
Transform CrsMatrix entries in place, using local indices to select the entries in the row to transfo...
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)
Sum into one or more sparse matrix entries, using local row and column indices.
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.
CrsMatrix(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor.
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.
DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
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.
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< 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...
Teuchos::RCP< MV > exportMV_
Row Map MultiVector used in apply().
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which the matrix is distributed.
bool isFillActive() const
Whether the matrix is not fill complete.
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.
local_matrix_host_type::values_type getLocalValuesHost(Access::ReadWriteStruct s)
Get the Kokkos local values on host, read write.
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.
mag_type getNorm1(bool assumeSymmetric=false) const
Compute and return the 1-norm of the matrix.
virtual ~CrsMatrix()=default
Destructor (virtual for memory safety of derived classes).
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.
mag_type getFrobeniusNorm() const override
Compute and return the Frobenius norm of the matrix.
void insertLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const CombineMode CM=ADD)
Insert one or more entries into the matrix, using local column indices.
global_size_t getGlobalNumCols() const override
The number of global columns in the matrix.
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
Teuchos::RCP< MV > importMV_
Column Map MultiVector used in apply().
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas, const bool verbose)
Allocate values (and optionally indices) using the Node.
size_t getLocalNumEntries() const override
The local number of entries in this matrix.
typename Node::device_type device_type
The Kokkos device type.
typename KokkosKernels::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
bool fillComplete_
Whether the matrix is fill complete.
virtual LocalOrdinal sumIntoGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoGlobalValues.
void replaceDomainMap(const Teuchos::RCP< const map_type > &newDomainMap)
Replace the current domain Map with the given objects.
void removeCrsMatrixZeros(CrsMatrixType &matrix, typename Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitudeType const &threshold=Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitude(Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::zero()))
Remove zero entries from a matrix.
std::string description() const override
A one-line description of this object.
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...
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, device_type, void, typename local_graph_device_type::size_type > local_matrix_device_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
void replaceRangeMapAndExporter(const Teuchos::RCP< const map_type > &newRangeMap, Teuchos::RCP< const export_type > &newExporter)
Replace the current Range Map and Export with the given objects.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
global_size_t getGlobalNumRows() const override
Number of global elements in the row map of this matrix.
local_matrix_host_type::values_type::const_type getLocalValuesHost(Access::ReadOnlyStruct s) const
Get the Kokkos local values on host, read only.
void globalAssemble()
Communicate nonlocal contributions to other processes.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
bool hasTransposeApply() const override
Whether apply() allows applying the transpose or conjugate transpose.
GlobalOrdinal getIndexBase() const override
The index base for global indices for this matrix.
LocalOrdinal local_ordinal_type
The type of each local index in the matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const override
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices,...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local graph and matrix.
row_ptrs_device_view_type getLocalRowPtrsDevice() const
Get a device view of the CRS packed row pointers.
Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization suitable for this CrsMatrix specialization.
local_inds_host_view_type getLocalIndicesHost() const
Get a host view of the CRS packed column indicies.
TPETRA_DETAILS_ALWAYS_INLINE local_matrix_device_type getLocalMatrixDevice() const
The local sparse matrix.
void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant view of a row of this matrix, using local row and column indices.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
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 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...
typename crs_graph_type::local_graph_device_type local_graph_device_type
The part of the sparse matrix's graph on each MPI process.
void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices.
void setAllValues(const typename local_graph_device_type::row_map_type &ptr, const typename local_graph_device_type::entries_type::non_const_type &ind, const typename local_matrix_device_type::values_type &val)
Set the local matrix using three (compressed sparse row) arrays.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const override
This matrix's graph, as a RowGraph.
virtual void copyAndPermute(const SrcDistObject &source, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM) override
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
local_matrix_device_type::values_type getLocalValuesDevice(Access::ReadWriteStruct s)
Get the Kokkos local values on device, read write.
virtual LocalOrdinal sumIntoLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoLocalValues.
void swap(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix)
Swaps the data from *this with the data and maps from crsMatrix.
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
global_size_t getGlobalNumEntries() const override
The global number of entries in this matrix.
virtual LocalOrdinal replaceLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceLocalValues.
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().
size_t getLocalNumRows() const override
The number of matrix rows owned by the calling process.
bool isFillComplete() const override
Whether the matrix is fill complete.
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)
Transform CrsMatrix entries in place, using global indices to select the entries in the row to transf...
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.
typename device_type::memory_space memory_space
The Kokkos memory space.
local_matrix_device_type::values_type getLocalValuesDevice(Access::OverwriteAllStruct s)
Get the Kokkos local values on device, overwrite all.
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)
Replace one or more entries' values, using local row and column indices.
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_host_type::values_type getLocalValuesHost(Access::OverwriteAllStruct s)
Get the Kokkos local values on host, overwrite all.
values_dualv_type::t_host::const_type getValuesViewHost(const RowInfo &rowinfo) const
Get a const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor.
bool isLocallyIndexed() const override
Whether the matrix is locally indexed on the calling process.
typename row_matrix_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
local_matrix_device_type::values_type::const_type getLocalValuesDevice(Access::ReadOnlyStruct s) const
Get the Kokkos local values on device, read only.
virtual LocalOrdinal replaceGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceGlobalValues.
values_dualv_type::t_host getValuesViewHostNonConst(const RowInfo &rowinfo)
Get a non-const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow...
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Fill data into the local matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the right with the given Vector.
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 > &rowExporter, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainExporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
bool isStorageOptimized() const
Returns true if storage has been optimized.
Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization suitable for this CrsMatrix specialization.
void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &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< 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().
values_dualv_type::t_dev::const_type getValuesViewDevice(const RowInfo &rowinfo) const
Get a const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the left with the given Vector.
CrsMatrix & operator=(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move assignment.
virtual bool supportsRowViews() const override
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
local_inds_device_view_type getLocalIndicesDevice() const
Get a device_view of the CRS packed column indicies.
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
virtual LocalOrdinal getBlockSize() const override
The number of degrees of freedom per mesh point.
Struct that holds views of the contents of a CrsMatrix.
Keep track of how much more space a CrsGraph or CrsMatrix needs, when the graph or matrix is the targ...
A class can inherit from this if it wants to use Tpetra managed spaces.
A wrapper around Kokkos::DualView to safely manage data that might be replicated between host and dev...
Base class for distributed Tpetra objects that support data redistribution.
virtual void packAndPrepare(const SrcDistObject &source, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets)
Pack data and metadata for communication (sends).
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode)
Perform any unpacking and combining after communication.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A parallel distribution of indices over processes.
One or more distributed dense vectors.
A read-only, row-oriented interface to a sparse matrix.
typename KokkosKernels::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Abstract base class for objects that can be the source of an Import or Export operation.
Implementation details of Tpetra.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
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.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
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().
size_t global_size_t
Global size_t object.
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().
CombineMode
Rule for combining data in an Import or Export.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.