11 #ifndef OOPS_ASSIMILATION_SADDLEPOINTLMPMATRIX_H_ 12 #define OOPS_ASSIMILATION_SADDLEPOINTLMPMATRIX_H_ 14 #include <Eigen/Dense> 18 #include <boost/noncopyable.hpp> 19 #include <boost/scoped_ptr.hpp> 55 template<
typename MODEL>
67 void setup(
const std::vector<SPVector_> &,
const std::vector<SPVector_> &);
80 void Fmultiply(Eigen::VectorXd &, Eigen::VectorXd &)
const;
96 template<
typename MODEL>
104 template<
typename MODEL>
106 const std::vector<SPVector_> & pqVEC) {
111 for (
unsigned ii = 0; ii < xyVEC.size(); ++ii) {
112 xyVEC_.push_back(xyVEC[ii]);
113 pqVEC_.push_back(pqVEC[ii]);
116 nvec_ = xyVEC_.size();
119 spvecinit_.reset(
new SPVector_(xyVEC_[0]));
120 (*spvecinit_).zero();
126 for (
unsigned jv = 0; jv < nvec_; ++jv) {
127 this->Pinitmultiply(xyVEC_[jv], ww);
130 RpVEC_.push_back(yy.
lambda());
131 RqVEC_.push_back(yy.
dx());
135 ZMat_.resize(nvec_, nvec_);
137 for (
unsigned jj = 0; jj < nvec_; ++jj) {
138 for (
unsigned ii = 0; ii < nvec_; ++ii) {
139 ZMat_(ii, jj) = calpha * dot_product(RpVEC_[ii], xyVEC_[jj].
lambda());
146 Ik = Eigen::MatrixXd::Identity(2*nvec_, 2*nvec_);
149 FMat_.resize(2*nvec_, 2*nvec_);
150 Eigen::VectorXd
output(2*nvec_);
151 Eigen::VectorXd input(2*nvec_);
152 for (
int ii = 0; ii < 2*nvec_; ii++) {
161 template<
typename MODEL>
187 j_.jb().multiplyB(x.
lambda().
dx(), diag.
dx());
188 for (
unsigned jj = 0; jj < j_.nterms(); ++jj) {
213 template<
typename MODEL>
224 Eigen::VectorXd rhs(2*nvec_);
225 Eigen::VectorXd finvx(2*nvec_);
226 this->Gmultiply(z, rhs);
227 finvx = FMat_.colPivHouseholderQr().solve(rhs);
228 this->Rmultiply(finvx, svw);
235 template<
typename MODEL>
237 Eigen::VectorXd & z)
const {
238 Eigen::VectorXd v1(nvec_);
239 Eigen::VectorXd v2(nvec_);
240 Eigen::VectorXd
ax(nvec_);
241 Eigen::VectorXd axt(nvec_);
242 Eigen::MatrixXd ZMatt(nvec_, nvec_);
243 ZMatt = ZMat_.transpose();
246 for (
unsigned jj = 0; jj < nvec_; ++jj) {
247 v1(jj) = dot_product(RpVEC_[jj], x.
lambda());
248 v2(jj) = dot_product(RqVEC_[jj], x.
dx());
251 ax = ZMat_.colPivHouseholderQr().solve(v1);
252 axt = ZMatt.colPivHouseholderQr().solve(v2);
257 template<
typename MODEL>
264 for (
unsigned ii = 0; ii < nvec_; ++ii) {
265 ww.axpy(x(ii + nvec_), RpVEC_[ii]);
266 zz.axpy(x(ii), RqVEC_[ii]);
273 template<
typename MODEL>
275 Eigen::VectorXd & fx)
const {
279 Eigen::VectorXd ww(2*nvec_);
282 this->Rmultiply(x,
tmp);
284 this->Gmultiply(tmp2, ww);
291 #endif // OOPS_ASSIMILATION_SADDLEPOINTLMPMATRIX_H_
ControlIncrement< MODEL > CtrlInc_
std::vector< CtrlInc_ > RqVEC_
std::vector< SPVector_ > xyVEC_
DualVector< MODEL > LagVector_
Container of dual space vectors for all terms of the cost function.
The preconditioner for the saddle-point minimizer.
void Fmultiply(Eigen::VectorXd &, Eigen::VectorXd &) const
std::vector< SPVector_ > pqVEC_
void setup(const std::vector< SPVector_ > &, const std::vector< SPVector_ > &)
CostFctWeak< MODEL > CostFctWeak_
void Gmultiply(const SPVector_ &, Eigen::VectorXd &) const
void Rmultiply(Eigen::VectorXd &, SPVector_ &) const
integer(long), parameter false
l_size ! loop over number of fields ke do j
The namespace for the main oops code.
boost::scoped_ptr< SPVector_ > spvecinit_
void Pinitmultiply(const SPVector_ &, SPVector_ &) const
Weak Constraint 4D-Var Cost Function.
The preconditioner for the saddle-point minimizer.
void multiply(const SPVector_ &, SPVector_ &) const
SaddlePointVector< MODEL > SPVector_
SaddlePointLMPMatrix(const CostFct_ &j)
Increment< MODEL > Increment_
Increment Class: Difference between two states.
const Multipliers_ & lambda() const
Accessor method to get the lambda_ component.
void multiply(const SPVector_ &, SPVector_ &) const
std::vector< LagVector_ > RpVEC_
void append(GeneralizedDepartures *)
Control vector for the saddle point formulation.
const CtrlInc_ & dx() const
Accessor method to get the dx_ component.
void zero()
Linear algebra operators.
boost::shared_ptr< const GeneralizedDepartures > getv(const unsigned) const
CostFunction< MODEL > CostFct_