FV3 Bundle
DiagonalMatrix.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_BASE_DIAGONALMATRIX_H_
12 #define OOPS_BASE_DIAGONALMATRIX_H_
13 
14 #include <boost/noncopyable.hpp>
15 
16 namespace oops {
17 
18 // -----------------------------------------------------------------------------
19 /// Diagonal matrix.
20 template <typename VECTOR> class DiagonalMatrix : private boost::noncopyable {
21  public:
22  explicit DiagonalMatrix(const VECTOR & diag): diag_(diag) {}
24 
25  void multiply(const VECTOR & v1, VECTOR & v2) const {
26  v2 = v1;
27  v2 *= diag_;
28  }
29 
30  void inverseMultiply(const VECTOR & v1, VECTOR & v2) const {
31  v2 = v1;
32  v2 /= diag_;
33  }
34 
35  private:
36  const VECTOR diag_;
37 };
38 // -----------------------------------------------------------------------------
39 
40 } // namespace oops
41 
42 #endif // OOPS_BASE_DIAGONALMATRIX_H_
DiagonalMatrix(const VECTOR &diag)
Diagonal matrix.
void inverseMultiply(const VECTOR &v1, VECTOR &v2) const
The namespace for the main oops code.
void multiply(const VECTOR &v1, VECTOR &v2) const