FV3 Bundle
UpTriSolve.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_ASSIMILATION_UPTRISOLVE_H_
12 #define OOPS_ASSIMILATION_UPTRISOLVE_H_
13 
14 #include <vector>
15 
16 namespace oops {
17 
18 /*! \file UpTriSolve.h
19  * \brief Solves the upper triangular system sol = H \ rhs
20 */
21 
22 void UpTriSolve(const std::vector <std::vector<double> > & H,
23  const std::vector <double> & rhs, std::vector <double> & sol,
24  const int & dim) {
25  // Backward solve
26  for (int iiter = dim - 1; iiter >= 0; iiter--) {
27  sol[iiter] = rhs[iiter];
28  for (int jiter = iiter + 1; jiter < dim; jiter++) {
29  sol[iiter] -= H[jiter][iiter] * sol[jiter];
30  }
31  sol[iiter] *= 1/H[iiter][iiter];
32  }
33 }
34 } // namespace oops
35 
36 #endif // OOPS_ASSIMILATION_UPTRISOLVE_H_
The namespace for the main oops code.
void UpTriSolve(const std::vector< std::vector< double > > &H, const std::vector< double > &rhs, std::vector< double > &sol, const int &dim)
Definition: UpTriSolve.h:22