GEOS
NormalOperator.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 
19 #ifndef GEOS_LINEARALGEBRA_UTILITIES_NORMALOPERATOR_HPP_
20 #define GEOS_LINEARALGEBRA_UTILITIES_NORMALOPERATOR_HPP_
21 
23 
24 namespace geos
25 {
26 
31 template< typename MATRIX >
32 class NormalOperator : public LinearOperator< typename MATRIX::Vector >
33 {
34 public:
35 
38 
40  using Vector = typename Base::Vector;
41 
43  using Matrix = MATRIX;
44 
49  explicit NormalOperator( Matrix const & mat )
50  : m_matrix( mat )
51  {}
52 
60  void apply( Vector const & src, Vector & dst ) const override
61  {
62  m_matrix.gemv( 1.0, src, 0.0, dst, false );
63  m_matrix.gemv( 1.0, dst, 0.0, dst, true );
64  }
65 
69  globalIndex numGlobalRows() const override
70  {
71  return m_matrix.numGlobalCols();
72  }
73 
77  globalIndex numGlobalCols() const override
78  {
79  return m_matrix.numGlobalCols();
80  }
81 
85  localIndex numLocalRows() const override
86  {
87  return m_matrix.numLocalCols();
88  }
89 
93  localIndex numLocalCols() const override
94  {
95  return m_matrix.numLocalCols();
96  }
97 
101  MPI_Comm comm() const override
102  {
103  return m_matrix.comm();
104  }
105 
106 private:
107 
109  Matrix const & m_matrix;
110 };
111 
112 } // namespace geos
113 
114 #endif //GEOS_LINEARALGEBRA_UTILITIES_NORMALOPERATOR_HPP_
Abstract base class for linear operators.
VECTOR Vector
Alias for template parameter.
Wraps a matrix A and represents A^T * A as a linear operator.
NormalOperator(Matrix const &mat)
Constructor.
MATRIX Matrix
Alias for matrix type.
typename Base::Vector Vector
Alias for vector type.
void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
globalIndex numGlobalRows() const override
localIndex numLocalCols() const override
localIndex numLocalRows() const override
globalIndex numGlobalCols() const override
MPI_Comm comm() const override
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