11 #ifndef TEST_INTERFACE_ERRORCOVARIANCE_H_ 12 #define TEST_INTERFACE_ERRORCOVARIANCE_H_ 18 #define BOOST_TEST_NO_MAIN 19 #define BOOST_TEST_ALTERNATIVE_INIT_API 20 #define BOOST_TEST_DYN_LINK 22 #include <boost/noncopyable.hpp> 23 #include <boost/scoped_ptr.hpp> 24 #include <boost/test/unit_test.hpp> 26 #include "eckit/config/Configuration.h" 34 #include "oops/util/DateTime.h" 35 #include "oops/util/dot_product.h" 36 #include "oops/util/Logger.h" 57 return theErrorCovarianceFixture;
61 oops::instantiateCovarFactory<MODEL>();
83 boost::scoped_ptr<const eckit::LocalConfiguration>
test_;
84 boost::scoped_ptr<const Geometry_>
resol_;
85 boost::scoped_ptr<const oops::Variables>
ctlvars_;
86 boost::scoped_ptr<const util::DateTime>
time_;
87 boost::scoped_ptr<Covariance_>
B_;
96 Increment_ dx1(Test_::resol(), Test_::ctlvars(),
Test_::time());
97 Increment_ dx2(Test_::resol(), Test_::ctlvars(),
Test_::time());
99 Test_::covariance().randomize(dx2);
102 BOOST_CHECK_EQUAL(dx1.norm(), 0.0);
103 BOOST_CHECK(dx2.norm() > 0.0);
104 Test_::covariance().multiply(dx1, dx2);
105 BOOST_CHECK_EQUAL(dx2.norm(), 0.0);
107 const bool testinverse =
Test_::test().getBool(
"testinverse",
true);
112 Test_::covariance().randomize(dx2);
113 BOOST_CHECK_EQUAL(dx1.norm(), 0.0);
114 BOOST_CHECK(dx2.norm() > 0.0);
115 Test_::covariance().inverseMultiply(dx1, dx2);
116 BOOST_CHECK_EQUAL(dx2.norm(), 0.0);
128 const bool testinverse =
Test_::test().getBool(
"testinverse",
true);
131 Increment_ dx1(Test_::resol(), Test_::ctlvars(),
Test_::time());
132 Increment_ dx2(Test_::resol(), Test_::ctlvars(),
Test_::time());
133 Increment_ dx3(Test_::resol(), Test_::ctlvars(),
Test_::time());
134 Test_::covariance().randomize(dx1);
135 BOOST_CHECK(dx1.norm() > 0.0);
137 Test_::covariance().multiply(dx1, dx2);
138 Test_::covariance().inverseMultiply(dx2, dx3);
140 BOOST_CHECK(dx2.norm() > 0.0);
141 BOOST_CHECK(dx3.norm() > 0.0);
144 BOOST_CHECK_SMALL(dx3.norm(),
tol);
156 Increment_ dx(Test_::resol(), Test_::ctlvars(),
Test_::time());
157 Increment_ Bdx(Test_::resol(), Test_::ctlvars(),
Test_::time());
158 Increment_ dy(Test_::resol(), Test_::ctlvars(),
Test_::time());
159 Increment_ Bdy(Test_::resol(), Test_::ctlvars(),
Test_::time());
164 Test_::covariance().multiply(dx, Bdx);
165 Test_::covariance().multiply(dy, Bdy);
166 const double zz1 = dot_product(dx, Bdy);
167 const double zz2 = dot_product(Bdx, dy);
169 << (zz1-zz2)/zz1 << std::endl;
171 << (zz1-zz2)/zz2 << std::endl;
173 BOOST_CHECK_CLOSE(zz1, zz2,
tol);
186 boost::unit_test::test_suite * ts = BOOST_TEST_SUITE(
"interface/ErrorCovariance");
188 ts->add(BOOST_TEST_CASE(&testErrorCovarianceZero<MODEL>));
189 ts->add(BOOST_TEST_CASE(&testErrorCovarianceInverse<MODEL>));
190 ts->add(BOOST_TEST_CASE(&testErrorCovarianceSym<MODEL>));
192 boost::unit_test::framework::master_test_suite().add(ts);
200 #endif // TEST_INTERFACE_ERRORCOVARIANCE_H_
void testErrorCovarianceInverse()
static const Geometry_ & resol()
boost::scoped_ptr< Covariance_ > B_
static const util::DateTime & time()
boost::scoped_ptr< const util::DateTime > time_
Encapsulates the model state.
static const eckit::Configuration & config()
virtual ~ErrorCovariance()
boost::scoped_ptr< const Geometry_ > resol_
static const oops::Variables & ctlvars()
static const Covariance_ & covariance()
subroutine, public info(self)
oops::Geometry< MODEL > Geometry_
Abstract base class for model space error covariances.
void testErrorCovarianceSym()
Increment Class: Difference between two states.
static ErrorCovarianceFixture< MODEL > & getInstance()
boost::scoped_ptr< const eckit::LocalConfiguration > test_
boost::scoped_ptr< const oops::Variables > ctlvars_
oops::ModelSpaceCovarianceBase< MODEL > Covariance_
void testErrorCovarianceZero()
static const eckit::Configuration & test()
void register_tests() const
std::string testid() const
const util::DateTime validTime() const
Time.