Squashed 'third_party/boostorg/odeint/' content from commit 6ff2719
Change-Id: If4892e29c1a5e6cf3a7aa51486a2725c251b0c7d
git-subtree-dir: third_party/boostorg/odeint
git-subtree-split: 6ff2719b6907b86596c3d43e88c1bcfdf29df560
diff --git a/test_external/mpi/norm_test.cpp b/test_external/mpi/norm_test.cpp
new file mode 100644
index 0000000..69f1d40
--- /dev/null
+++ b/test_external/mpi/norm_test.cpp
@@ -0,0 +1,62 @@
+/*
+ Copyright 2013 Karsten Ahnert
+ Copyright 2013 Mario Mulansky
+ Copyright 2013 Pascal Germroth
+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or
+ copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+
+#define BOOST_TEST_MODULE odeint_mpi
+#include <boost/test/unit_test.hpp>
+
+#include <boost/numeric/odeint/external/mpi/mpi.hpp>
+
+using namespace boost::numeric::odeint;
+
+boost::mpi::environment env;
+
+BOOST_AUTO_TEST_SUITE( norm_test_suite )
+
+BOOST_AUTO_TEST_CASE( norm_test )
+{
+ boost::mpi::communicator world;
+
+ int ref_value = 0;
+ std::vector<int> in_data;
+ mpi_state< std::vector<int> > state(world);
+
+ // generate data and reference value on master
+ if(world.rank() == 0) {
+ for(size_t i = 0 ; i < 400 ; i++)
+ in_data.push_back( rand() % 10000 );
+ ref_value = *std::max_element(in_data.begin(), in_data.end());
+ }
+ boost::mpi::broadcast(world, ref_value, 0);
+
+ // copy to nodes
+ split( in_data, state );
+
+ int value = mpi_nested_algebra< range_algebra >::norm_inf( state );
+
+ {
+ std::ostringstream ss;
+ ss << "state[" << world.rank() << "]"
+ << " local:" << range_algebra::norm_inf( state() )
+ << " global:" << value
+ << " ref:" << ref_value << "\n";
+ std::clog << ss.str() << std::flush;
+ }
+
+ BOOST_REQUIRE_EQUAL( value, ref_value );
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
+
+