GEOS
TransposeOperator.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_UTILITIES_TRANSPOSEOPERATOR_HPP_
21 #define GEOS_LINEARALGEBRA_UTILITIES_TRANSPOSEOPERATOR_HPP_
22 
24 
25 namespace geos
26 {
27 
32 template< typename MATRIX >
33 class TransposeOperator : public LinearOperator< typename MATRIX::Vector >
34 {
35 public:
36 
39 
41  using Vector = typename Base::Vector;
42 
44  using Matrix = MATRIX;
45 
50  explicit TransposeOperator( Matrix const & mat )
51  : Base(),
52  m_matrix( mat )
53  { }
54 
62  virtual void apply( Vector const & src, Vector & dst ) const override
63  {
64  m_matrix.applyTranspose( src, dst );
65  }
66 
70  virtual globalIndex numGlobalRows() const override
71  {
72  return m_matrix.numGlobalCols();
73  }
74 
78  virtual globalIndex numGlobalCols() const override
79  {
80  return m_matrix.numGlobalRows();
81  }
82 
86  virtual localIndex numLocalRows() const override
87  {
88  return m_matrix.numLocalCols();
89  }
90 
94  virtual localIndex numLocalCols() const override
95  {
96  return m_matrix.numLocalRows();
97  }
98 
103  virtual MPI_Comm comm() const override
104  {
105  return m_matrix.comm();
106  }
107 
108 private:
109 
110  Matrix const & m_matrix;
111 };
112 
113 }
114 
115 #endif //GEOS_LINEARALGEBRA_UTILITIES_TRANSPOSEOPERATOR_HPP_
Abstract base class for linear operators.
VECTOR Vector
Alias for template parameter.
Simple class that wraps a matrix and represents its transpose as a linear operator.
virtual MPI_Comm comm() const override
Get the MPI communicator the matrix was created with.
MATRIX Matrix
Alias for matrix type.
virtual localIndex numLocalRows() const override
virtual globalIndex numGlobalCols() const override
virtual globalIndex numGlobalRows() const override
virtual localIndex numLocalCols() const override
TransposeOperator(Matrix const &mat)
Constructor.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
typename Base::Vector Vector
Alias for vector type.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84