1 // Distributed under the Boost Software License, Version 1.0. (See
2 // accompanying file LICENSE_1_0.txt or copy at
3 // http://www.boost.org/LICENSE_1_0.txt)
5 #include <boost/numeric/ublas/vector.hpp>
6 #include <boost/numeric/ublas/io.hpp>
10 using namespace boost::numeric::ublas
;
12 static const double TOL(1.0e-5); ///< Used for comparing two real numbers.
14 BOOST_UBLAS_TEST_DEF ( test_double_scaled_norm_2
) {
16 v
[0] = 0; v
[1] = 1.0e155
;
18 const double expected
= 1.0e155
;
20 BOOST_UBLAS_DEBUG_TRACE( "norm is " << norm_2(v
) );
21 BOOST_UBLAS_TEST_CHECK(std::abs(norm_2(v
) - expected
) < TOL
);
24 BOOST_UBLAS_TEST_DEF ( test_float_scaled_norm_2
) {
26 v
[0] = 0; v
[1] = 1.0e20
;
28 const float expected
= 1.0e20
;
30 BOOST_UBLAS_DEBUG_TRACE( "norm is " << norm_2(v
) );
31 BOOST_UBLAS_TEST_CHECK(std::abs(norm_2(v
) - expected
) < TOL
);
35 BOOST_UBLAS_TEST_BEGIN();
37 BOOST_UBLAS_TEST_DO( test_double_scaled_norm_2
);
38 BOOST_UBLAS_TEST_DO( test_float_scaled_norm_2
);
40 BOOST_UBLAS_TEST_END();