11 #ifndef OOPS_ASSIMILATION_DUALVECTOR_H_ 12 #define OOPS_ASSIMILATION_DUALVECTOR_H_ 15 #include <boost/scoped_ptr.hpp> 16 #include <boost/shared_ptr.hpp> 22 #include "oops/util/dot_product.h" 51 boost::shared_ptr<const GeneralizedDepartures>
getv(
const unsigned)
const;
68 boost::scoped_ptr<CtrlInc_>
dxjb_;
69 std::vector<boost::shared_ptr<Departures_> >
dxjo_;
70 std::vector<boost::shared_ptr<Increment_> >
dxjc_;
71 std::vector<unsigned>
ijo_;
72 std::vector<unsigned>
ijc_;
78 template<
typename MODEL>
80 : dxjb_(), dxjo_(), dxjc_(),
81 ijo_(other.ijo_), ijc_(other.ijc_), size_(other.size_)
83 if (other.
dxjb_ != 0) {
86 for (
unsigned jj = 0; jj < other.
dxjo_.size(); ++jj) {
90 for (
unsigned jj = 0; jj < other.
dxjc_.size(); ++jj) {
96 template<
typename MODEL>
106 template<
typename MODEL>
111 boost::shared_ptr<Increment_> si(
pi);
113 ijc_.push_back(size_);
117 boost::shared_ptr<Departures_> sd(pd);
119 ijo_.push_back(size_);
121 ASSERT(
pi != 0 || pd != 0);
125 template<
typename MODEL>
126 boost::shared_ptr<const GeneralizedDepartures>
129 boost::shared_ptr<const GeneralizedDepartures>
pv;
130 for (
unsigned jj = 0; jj < ijo_.size(); ++jj) {
131 if (ijo_[jj] == ii)
pv = dxjo_[jj];
133 for (
unsigned jj = 0; jj < ijc_.size(); ++jj) {
134 if (ijc_[jj] == ii)
pv = dxjc_[jj];
140 template<
typename MODEL>
142 ASSERT(this->compatible(rhs));
146 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
147 *dxjo_[jj] = *rhs.
dxjo_[jj];
149 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
150 *dxjc_[jj] = *rhs.
dxjc_[jj];
155 template<
typename MODEL>
157 ASSERT(this->compatible(rhs));
159 *dxjb_ += *rhs.
dxjb_;
161 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
162 *dxjo_[jj] += *rhs.
dxjo_[jj];
164 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
165 *dxjc_[jj] += *rhs.
dxjc_[jj];
170 template<
typename MODEL>
172 ASSERT(this->compatible(rhs));
174 *dxjb_ -= *rhs.
dxjb_;
176 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
177 *dxjo_[jj] -= *rhs.
dxjo_[jj];
179 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
180 *dxjc_[jj] -= *rhs.
dxjc_[jj];
185 template<
typename MODEL>
190 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
193 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
199 template<
typename MODEL>
204 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
207 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
212 template<
typename MODEL>
214 ASSERT(this->compatible(rhs));
216 dxjb_->axpy(zz, *rhs.
dxjb_);
218 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
219 dxjo_[jj]->axpy(zz, *rhs.
dxjo_[jj]);
221 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
222 dxjc_[jj]->axpy(zz, *rhs.
dxjc_[jj]);
226 template<
typename MODEL>
228 ASSERT(this->compatible(x2));
231 zz += dot_product(*dxjb_, *x2.
dxjb_);
233 for (
unsigned jj = 0; jj < dxjo_.size(); ++jj) {
234 zz += dot_product(*dxjo_[jj], *x2.
dxjo_[jj]);
236 for (
unsigned jj = 0; jj < dxjc_.size(); ++jj) {
237 zz += dot_product(*dxjc_[jj], *x2.
dxjc_[jj]);
242 template<
typename MODEL>
244 bool lcheck = (dxjb_ == 0) == (other.
dxjb_ == 0)
245 && (dxjo_.size() == other.
dxjo_.size())
246 && (dxjc_.size() == other.
dxjc_.size());
252 #endif // OOPS_ASSIMILATION_DUALVECTOR_H_
std::vector< unsigned > ijc_
Container of dual space vectors for all terms of the cost function.
std::vector< boost::shared_ptr< Increment_ > > dxjc_
const CtrlInc_ & dx() const
Difference between two observation vectors.
double dot_product_with(const DualVector &) const
DualVector & operator-=(const DualVector &)
ControlIncrement< MODEL > CtrlInc_
std::vector< unsigned > ijo_
The namespace for the main oops code.
DualVector & operator=(const DualVector &)
Departures< MODEL > Departures_
boost::scoped_ptr< CtrlInc_ > dxjb_
Increment< MODEL > Increment_
bool compatible(const DualVector &other) const
Increment Class: Difference between two states.
DualVector & operator*=(const double)
std::vector< boost::shared_ptr< Departures_ > > dxjo_
Abstract base class for quantities.
void append(GeneralizedDepartures *)
DualVector & operator+=(const DualVector &)
boost::shared_ptr< const GeneralizedDepartures > getv(const unsigned) const
void axpy(const double, const DualVector &)