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 Total, S.A
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_TRANSPOSEMATRIXOPERATOR_HPP_
21 #define GEOS_LINEARALGEBRA_TRANSPOSEMATRIXOPERATOR_HPP_
22 
24 
25 namespace geos
26 {
27 
32 template< typename LAI >
33 class TransposeOperator : public LinearOperator< typename LAI::ParallelVector >
34 {
35 public:
36 
39 
41  using Vector = typename Base::Vector;
42 
44  using Matrix = typename LAI::ParallelMatrix;
45 
50  explicit TransposeOperator( Matrix const & mat )
51  : Base(),
52  m_matrix( mat )
53  { }
54 
58  virtual ~TransposeOperator() override = default;
59 
67  virtual void apply( Vector const & src, Vector & dst ) const override
68  {
69  m_matrix.applyTranspose( src, dst );
70  }
71 
76  virtual globalIndex numGlobalRows() const override
77  {
78  return m_matrix.numGlobalCols();
79  }
80 
85  virtual globalIndex numGlobalCols() const override
86  {
87  return m_matrix.numGlobalRows();
88  }
89 
94  virtual localIndex numLocalRows() const override
95  {
96  return m_matrix.numLocalCols();
97  }
98 
103  virtual localIndex numLocalCols() const override
104  {
105  return m_matrix.numLocalRows();
106  }
107 
112  virtual MPI_Comm comm() const override
113  {
114  return m_matrix.comm();
115  }
116 
117 private:
118 
119  Matrix const & m_matrix;
120 };
121 
122 }
123 
124 #endif //GEOS_LINEARALGEBRA_TRANSPOSEMATRIXOPERATOR_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 void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
virtual globalIndex numGlobalCols() const override
Get the number of global columns.
virtual localIndex numLocalCols() const override
Get the number of local columns.
virtual localIndex numLocalRows() const override
Get the number of local rows.
virtual ~TransposeOperator() override=default
Destructor.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
virtual globalIndex numGlobalRows() const override
Get the number of global rows.
virtual MPI_Comm comm() const override
Get the MPI communicator the matrix was created with.
TransposeOperator(Matrix const &mat)
Constructor.
typename Base::Vector Vector
Alias for vector type.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
LAInterface::ParallelMatrix ParallelMatrix
Alias for ParallelMatrix.