Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MatrixUtils_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef PACKAGES_XPETRA_SUP_MATRIX_UTILS_DECL_HPP_
11 #define PACKAGES_XPETRA_SUP_MATRIX_UTILS_DECL_HPP_
12 
13 #include "Xpetra_ConfigDefs.hpp"
14 
15 #include "Xpetra_Map.hpp"
16 #include "Xpetra_MapUtils.hpp"
17 #include "Xpetra_StridedMap.hpp"
18 #include "Xpetra_MapFactory.hpp"
19 #include "Xpetra_MapExtractor.hpp"
21 #include "Xpetra_Matrix.hpp"
22 #include "Xpetra_MatrixFactory.hpp"
23 #include "Xpetra_BlockedCrsMatrix.hpp"
24 #include "Xpetra_MatrixMatrix.hpp"
25 #include "Xpetra_Helpers.hpp"
26 
27 #ifdef HAVE_XPETRA_TPETRA
28 #include "Xpetra_TpetraMultiVector.hpp"
29 #include <Tpetra_RowMatrixTransposer.hpp>
30 #include <Tpetra_Details_extractBlockDiagonal.hpp>
31 #include <Tpetra_Details_scaleBlockDiagonal.hpp>
32 #endif
33 
34 namespace Xpetra {
35 
45 template <class Scalar,
46  class LocalOrdinal,
47  class GlobalOrdinal,
48  class Node>
49 class MatrixUtils {
50 #undef XPETRA_MATRIXUTILS_SHORT
51 #include "Xpetra_UseShortNames.hpp"
52 
53  public:
54  static Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpetraGidNumbering2ThyraGidNumbering(
56 
57  static Teuchos::RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> findColumnSubMap(
60 
71  static Teuchos::RCP<Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> SplitMatrix(
73  Teuchos::RCP<const Xpetra::MapExtractor<Scalar, LocalOrdinal, GlobalOrdinal, Node>> rangeMapExtractor,
74  Teuchos::RCP<const Xpetra::MapExtractor<Scalar, LocalOrdinal, GlobalOrdinal, Node>> domainMapExtractor,
75  Teuchos::RCP<const Xpetra::MapExtractor<Scalar, LocalOrdinal, GlobalOrdinal, Node>> columnMapExtractor = Teuchos::null,
76  bool bThyraMode = false);
77 
81  bool const& repairZeroDiagonals, Teuchos::FancyOStream& fos,
82  const typename Teuchos::ScalarTraits<Scalar>::magnitudeType threshold = Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>::zero(),
83  const Scalar replacementValue = Teuchos::ScalarTraits<Scalar>::one());
84 
92  const Teuchos::ArrayView<const double>& relativeThreshold, Teuchos::FancyOStream& fos);
93 
94  // Extracting the block diagonal of a matrix
97 
98  // Inverse scaling by a block-diagonal matrix
100  bool doTranspose,
102 
104 
112  static void convertMatrixToStridedMaps(
114  std::vector<size_t>& rangeStridingInfo, std::vector<size_t>& domainStridingInfo);
115 };
116 
117 } // end namespace Xpetra
118 
119 #define XPETRA_MATRIXUTILS_SHORT
120 
121 #endif // PACKAGES_XPETRA_SUP_MATRIX_UTILS_DECL_HPP_
static void CheckRepairMainDiagonal(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &Ac, bool const &repairZeroDiagonals, Teuchos::FancyOStream &fos, const typename Teuchos::ScalarTraits< Scalar >::magnitudeType threshold=Teuchos::ScalarTraits< typename Teuchos::ScalarTraits< Scalar >::magnitudeType >::zero(), const Scalar replacementValue=Teuchos::ScalarTraits< Scalar >::one())
static Teuchos::RCP< Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > SplitMatrix(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &input, Teuchos::RCP< const Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node >> rangeMapExtractor, Teuchos::RCP< const Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node >> domainMapExtractor, Teuchos::RCP< const Xpetra::MapExtractor< Scalar, LocalOrdinal, GlobalOrdinal, Node >> columnMapExtractor=Teuchos::null, bool bThyraMode=false)
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > findColumnSubMap(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &domainMap)
static void RelativeDiagonalBoost(RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &A, const Teuchos::ArrayView< const double > &relativeThreshold, Teuchos::FancyOStream &fos)
static Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > xpetraGidNumbering2ThyraGidNumbering(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &input)
static void convertMatrixToStridedMaps(Teuchos::RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >> matrix, std::vector< size_t > &rangeStridingInfo, std::vector< size_t > &domainStridingInfo)
static void extractBlockDiagonal(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diagonal)
Xpetra-specific matrix class.
static void checkLocalRowMapMatchesColMap(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
static void inverseScaleBlockDiagonal(Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &blockDiagonal, bool doTranspose, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &toBeScaled)