| 1 | /*
|
|---|
| 2 | * $Rev: 5266 $
|
|---|
| 3 | * Author: Jesse Perla (c) 2010
|
|---|
| 4 | * Use, modification and distribution are subject to the
|
|---|
| 5 | * Boost Software License, Version 1.0. (See accompanying file
|
|---|
| 6 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | #define BOOST_TEST_MODULE test_boost_ublas_SFINAE_patches
|
|---|
| 10 | #include <boost/test/unit_test.hpp>
|
|---|
| 11 | #include <boost/numeric/ublas/vector.hpp>
|
|---|
| 12 | #include <boost/numeric/ublas/matrix.hpp>
|
|---|
| 13 | #include <boost/numeric/ublas/io.hpp>
|
|---|
| 14 |
|
|---|
| 15 | using namespace boost::numeric::ublas;
|
|---|
| 16 |
|
|---|
| 17 | BOOST_AUTO_TEST_CASE( test_matrix_SFINAE )
|
|---|
| 18 | {
|
|---|
| 19 | matrix<double> m, m2;
|
|---|
| 20 | m2 = 2 * m;
|
|---|
| 21 | m2 = m * 2;
|
|---|
| 22 |
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | BOOST_AUTO_TEST_CASE( test_vector_SFINAE )
|
|---|
| 26 | {
|
|---|
| 27 | vector<double> v, v2;
|
|---|
| 28 | v2 = 2 * v;
|
|---|
| 29 | v2 = v * 2;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | BOOST_AUTO_TEST_CASE (test_overloaded_multiply){
|
|---|
| 33 | matrix<double> A = identity_matrix<double>(2);
|
|---|
| 34 |
|
|---|
| 35 | vector<double> y(2);
|
|---|
| 36 | std::fill(y.begin(), y.end(), 1.0);
|
|---|
| 37 |
|
|---|
| 38 | std::cout << prod(A, y) << std::endl;
|
|---|
| 39 | std::cout << 2.0 * y << std::endl;
|
|---|
| 40 | std::cout << y * 2 << std::endl;
|
|---|
| 41 | std::cout << A * 2 << std::endl;
|
|---|
| 42 | std::cout << 2 * A << std::endl;
|
|---|
| 43 | std::cout << A * y << std::endl;
|
|---|
| 44 | std::cout << y * A << std::endl;
|
|---|
| 45 | std::cout << A * A << std::endl;
|
|---|
| 46 | }
|
|---|