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 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 
19 #ifndef GEOS_LINEARALGEBRA_NORMALOPERATOR_HPP_
20 #define GEOS_LINEARALGEBRA_NORMALOPERATOR_HPP_
21 
23 
24 namespace geos
25 {
26 
31 template< typename LAI >
32 class NormalOperator : public LinearOperator< typename LAI::ParallelVector >
33 {
34 public:
35 
38 
40  using Vector = typename Base::Vector;
41 
43  using Matrix = typename LAI::ParallelMatrix;
44 
49  explicit NormalOperator( Matrix const & mat )
50  : m_matrix( mat )
51  {}
52 
56  virtual ~NormalOperator() override = default;
57 
65  void apply( Vector const & src, Vector & dst ) const override
66  {
67  m_matrix.gemv( 1.0, src, 0.0, dst, false );
68  m_matrix.gemv( 1.0, dst, 0.0, dst, true );
69  }
70 
74  globalIndex numGlobalRows() const override
75  {
76  return m_matrix.numGlobalCols();
77  }
78 
82  globalIndex numGlobalCols() const override
83  {
84  return m_matrix.numGlobalCols();
85  }
86 
90  localIndex numLocalRows() const override
91  {
92  return m_matrix.numLocalCols();
93  }
94 
98  localIndex numLocalCols() const override
99  {
100  return m_matrix.numLocalCols();
101  }
102 
106  MPI_Comm comm() const override
107  {
108  return m_matrix.comm();
109  }
110 
111 private:
112 
114  Matrix const & m_matrix;
115 };
116 
117 } // namespace geos
118 
119 #endif //GEOS_LINEARALGEBRA_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.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
typename Base::Vector Vector
Alias for vector type.
virtual ~NormalOperator() override=default
Destructor.
NormalOperator(Matrix const &mat)
Constructor.
void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
localIndex numLocalCols() const override
MPI_Comm comm() const override
localIndex numLocalRows() const override
globalIndex numGlobalCols() const override
globalIndex numGlobalRows() const override
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.