11 #ifndef OOPS_ASSIMILATION_RPLANCZOSMINIMIZER_H_ 12 #define OOPS_ASSIMILATION_RPLANCZOSMINIMIZER_H_ 24 #include "oops/util/dot_product.h" 25 #include "oops/util/formats.h" 26 #include "oops/util/Logger.h" 75 const std::string
classname()
const override {
return "RPLanczosMinimizer";}
81 const int &,
const double &,
Dual_ &,
const double &)
override;
86 template<
typename MODEL>
89 const int & maxiter,
const double &
tolerance,
107 std::vector<Dual_> vVEC;
108 std::vector<Dual_> tVEC;
109 std::vector<Dual_> zVEC;
110 std::vector<double> vpVEC;
111 std::vector<double> tpVEC;
112 std::vector<double> zpVEC;
113 std::vector<double> alphas;
114 std::vector<double> betas;
115 std::vector<double> y;
116 std::vector<double>
d;
125 ttp = dot_product(dy, zz) +
sigma*zzp;
127 double normReduction = 1.0;
128 double beta0 = sqrt(dot_product(rr, tt) + rrp*
ttp);
155 zpVEC.push_back(zzp);
156 tpVEC.push_back(
ttp);
160 for (jiter = 0; jiter < maxiter; ++jiter) {
161 Log::info() <<
"RPLanczos Starting Iteration " << jiter+1 << std::endl;
170 double alpha = dot_product(tt, ww) +
ttp*wwp;
176 for (
int iiter = 0; iiter < jiter; ++iiter) {
177 double proj = dot_product(ww, tVEC[iiter]) + wwp * tpVEC[iiter];
178 ww.
axpy(-proj, vVEC[iiter]);
179 wwp -= proj * vpVEC[iiter];
189 ttp = dot_product(dy, zz) +
sigma*zzp;
191 beta = sqrt(dot_product(tt, ww) +
ttp*wwp);
208 zpVEC.push_back(zzp);
209 tpVEC.push_back(
ttp);
211 alphas.push_back(
alpha);
215 y.push_back(beta0/
alpha);
219 for (
int iiter = 0; iiter <= jiter; ++iiter) {
220 d.push_back(beta0*(dot_product(tVEC[0], vVEC[iiter]) + tpVEC[0]*vpVEC[iiter]));
226 double rznorm =
beta*std::abs(y[jiter]);
228 normReduction = rznorm/beta0;
230 betas.push_back(
beta);
232 Log::info() <<
"RPLanczos end of iteration " << jiter+1 <<
". Norm reduction= " 233 << util::full_precision(normReduction) << std::endl << std::endl;
236 Log::info() <<
"RPLanczos: Achieved required reduction in residual norm." << std::endl;
242 for (
int iiter = 0; iiter < jiter; ++iiter) {
243 vv.
axpy(y[iiter], zVEC[iiter]);
244 vvp += y[iiter]*zpVEC[iiter];
247 Log::info() <<
"RPLanczos: end" << std::endl;
249 return normReduction;
256 #endif // OOPS_ASSIMILATION_RPLANCZOSMINIMIZER_H_
void multiply(const Dual_ &dx, Dual_ &dy) const
RinvMatrix< MODEL > Rinv_
Container of dual space vectors for all terms of the cost function.
const std::string classname() const override
integer, parameter sigma
Flags to indicate where climatology pressure levels are pressure or sigma levels. ...
CostFunction< MODEL > CostFct_
void TriDiagSolve(const std::vector< double > &diag, const std::vector< double > &sub, const std::vector< double > &rhs, std::vector< double > &sol)
RPLanczosMinimizer(const eckit::Configuration &, const CostFct_ &J)
The namespace for the main oops code.
subroutine, public info(self)
real(fp), parameter, public tolerance
DualVector< MODEL > Dual_
double solve(Dual_ &, double &, Dual_ &, const HBHt_ &, const Rinv_ &, const int &, const double &, Dual_ &, const double &) override
void multiply(const VECTOR &a, VECTOR &b) const
void multiply(const Dual_ &dy, Dual_ &dz) const
HBHtMatrix< MODEL > HBHt_
void axpy(const double, const DualVector &)