11 #ifndef OOPS_BASE_DEPARTURES_H_
12 #define OOPS_BASE_DEPARTURES_H_
14 #include <Eigen/Dense>
24 #include "oops/util/dot_product.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/Printable.h"
42 template <
typename OBS>
52 const std::string & name =
"",
const bool failIfNameNotFound =
true);
83 void save(
const std::string &)
const;
86 void print(std::ostream &)
const;
89 std::vector<ObsVector_>
dep_;
94 template<
typename OBS>
96 const std::string & name,
const bool fail): dep_()
99 for (
size_t jj = 0; jj < obsdb.
size(); ++jj) {
100 dep_.emplace_back(obsdb[jj], name, fail);
102 Log::trace() <<
"Departures created" << std::endl;
105 template<
typename OBS>
109 for (
size_t jj = 0; jj < other.
dep_.size(); ++jj) {
110 dep_.emplace_back(obsdb[jj], other[jj]);
112 Log::trace() <<
"Local Departures created" << std::endl;
115 template<
typename OBS>
117 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
123 template<
typename OBS>
125 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
131 template<
typename OBS>
133 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
139 template<
typename OBS>
141 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
147 template<
typename OBS>
149 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
155 template<
typename OBS>
157 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
162 template<
typename OBS>
164 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
169 template<
typename OBS>
171 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
176 template<
typename OBS>
178 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
179 dep_[jj].axpy(zz, rhs[jj]);
183 template<
typename OBS>
186 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
187 zz += dot_product(dep_[jj], other[jj]);
192 template<
typename OBS>
194 return sqrt(dot_product_with(*
this) / this->nobs());
197 template<
typename OBS>
200 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
201 nobs += dep_[jj].nobs();
206 template<
typename OBS>
208 for (
size_t ii = 0; ii < dep_.size(); ++ii) {
209 dep_[ii].mask(*qc.
qcFlags(ii));
213 template <
typename OBS>
215 Eigen::VectorXd vec(nobs());
217 for (
size_t idep = 0; idep < dep_.size(); ++idep) {
218 vec.segment(ii, dep_[idep].nobs()) = dep_[idep].packEigen();
219 ii += dep_[idep].nobs();
221 ASSERT(ii == nobs());
225 template <
typename OBS>
227 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
232 template <
typename OBS>
234 for (
size_t jj = 0; jj < dep_.size(); ++jj) {
235 os << dep_[jj] << std::endl;
241 #endif // OOPS_BASE_DEPARTURES_H_