FV3 Bundle
TriDiagSpectrum.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_TRIDIAGSPECTRUM_H_
12 #define OOPS_ASSIMILATION_TRIDIAGSPECTRUM_H_
13 
14 #include <vector>
15 
16 #include "oops/util/Logger.h"
17 
18 extern "C" {
19  void FtnTriDiagSpectrum(const int &, const double *, const double *,
20  double *, double *);
21 }
22 
23 namespace oops {
24 
25 void TriDiagSpectrum(const std::vector<double> & diag, const std::vector<double> & sub,
26  std::vector<double> & evals,
27  std::vector< std::vector<double> > & evecs) {
28  const unsigned nn = diag.size();
29  ASSERT(sub.size() == nn);
30  evals.resize(nn);
31  evecs.resize(nn);
32 
33  if (nn > 0) {
34  std::vector<double> ftnev(nn*nn);
35 
36  FtnTriDiagSpectrum(nn, &diag[0], &sub[0], &evals[0], &ftnev[0]);
37 
38  unsigned ii = 0;
39  for (unsigned jv = 0; jv < nn; ++jv) {
40  evecs[jv].resize(nn);
41  for (unsigned jj = 0; jj < nn; ++jj) {
42  evecs[jv][jj] = ftnev[ii];
43  ++ii;
44  }
45  }
46  }
47 }
48 
49 } // namespace oops
50 
51 #endif // OOPS_ASSIMILATION_TRIDIAGSPECTRUM_H_
void FtnTriDiagSpectrum(const int &, const double *, const double *, double *, double *)
The namespace for the main oops code.
void TriDiagSpectrum(const std::vector< double > &diag, const std::vector< double > &sub, std::vector< double > &evals, std::vector< std::vector< double > > &evecs)