11 #ifndef TEST_INTERFACE_OBSVECTOR_H_
12 #define TEST_INTERFACE_OBSVECTOR_H_
18 #define ECKIT_TESTING_SELF_REGISTER_CASES 0
20 #include "eckit/testing/Test.h"
24 #include "oops/util/dot_product.h"
33 typedef ObsTestsFixture<OBS> Test_;
36 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
37 std::unique_ptr<ObsVector_> ov(
new ObsVector_(Test_::obspace()[jj]));
48 typedef ObsTestsFixture<OBS> Test_;
51 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
52 std::unique_ptr<ObsVector_> ov(
new ObsVector_(Test_::obspace()[jj]));
56 std::unique_ptr<ObsVector_> other(
new ObsVector_(*ov));
59 const double ov2 = dot_product(*ov, *ov);
60 const double other2 = dot_product(*other, *other);
62 EXPECT(ov2 == other2);
76 const double zero = 0.0;
78 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
79 ObsVector_ ov1(Test_::obspace()[jj]);
82 const double zz = dot_product(ov1, ov1);
88 EXPECT(dot_product(ov2, ov1) == zero);
89 EXPECT(dot_product(ov2, ov2) == zero);
97 const double tolerance = 1.0e-8;
98 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
99 ObsVector_ ov1(Test_::obspace()[jj]);
107 EXPECT(dot_product(ov2, ov2) < tolerance);
113 EXPECT(dot_product(ov2, ov2) < tolerance);
120 EXPECT(dot_product(ov2, ov2) < tolerance);
128 EXPECT(dot_product(ov2, ov2) < tolerance);
134 EXPECT(std::abs(dot_product(ov2, ov2) - ov2.nobs()) < tolerance);
142 const double tolerance = 1.0e-8;
143 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
144 ObsVector_ ov1(Test_::obspace()[jj]);
148 ObsVector_ ov2(Test_::obspace()[jj],
"test");
150 EXPECT(dot_product(ov2, ov2) < tolerance);
157 const double tolerance = 1.0e-8;
158 for (std::size_t jj = 0; jj < Test_::obspace().size(); ++jj) {
159 ObsVector_ ov1(Test_::obspace()[jj]);
161 double rms1 = ov1.rms();
163 Eigen::VectorXd vec = ov1.packEigen();
164 EXPECT(vec.size() == ov1.nobs());
166 double rms2 = sqrt(vec.squaredNorm() / ov1.nobs());
167 EXPECT(std::abs(rms1-rms2) < tolerance);
172 template <
typename OBS>
181 std::string
testid()
const override {
return "test::ObsVector<" + OBS::name() +
">";}
184 std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
186 ts.emplace_back(
CASE(
"interface/ObsVector/testConstructor")
187 { testConstructor<OBS>(); });
188 ts.emplace_back(
CASE(
"interface/ObsVector/testCopyConstructor")
189 { testCopyConstructor<OBS>(); });
190 ts.emplace_back(
CASE(
"interface/ObsVector/testNotZero")
191 { testNotZero<OBS>(); });
192 ts.emplace_back(
CASE(
"interface/ObsVector/testLinearAlgebra")
193 { testLinearAlgebra<OBS>(); });
194 ts.emplace_back(
CASE(
"interface/ObsVector/testReadWrite")
195 { testReadWrite<OBS>(); });
196 ts.emplace_back(
CASE(
"interface/ObsVector/testPackEigen")
197 { testPackEigen<OBS>(); });
209 #endif // TEST_INTERFACE_OBSVECTOR_H_