Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81043 - trunk/libs/numeric/ublas/test
From: guwi17_at_[hidden]
Date: 2012-10-21 16:45:16


Author: guwi17
Date: 2012-10-21 16:45:15 EDT (Sun, 21 Oct 2012)
New Revision: 81043
URL: http://svn.boost.org/trac/boost/changeset/81043

Log:
* libs/numeric/ublas/test/test_banded_storage_layout.cpp - new failing test, see #7549

* libs/numeric/ublas/test/Jamfile.v2 - add test to test suite

Added:
   trunk/libs/numeric/ublas/test/test_banded_storage_layout.cpp (contents, props changed)
Text files modified:
   trunk/libs/numeric/ublas/test/Jamfile.v2 | 7 +++++++
   1 files changed, 7 insertions(+), 0 deletions(-)

Modified: trunk/libs/numeric/ublas/test/Jamfile.v2
==============================================================================
--- trunk/libs/numeric/ublas/test/Jamfile.v2 (original)
+++ trunk/libs/numeric/ublas/test/Jamfile.v2 2012-10-21 16:45:15 EDT (Sun, 21 Oct 2012)
@@ -205,4 +205,11 @@
       ]
       [ run test_coordinate_matrix_inplace_merge.cpp
       ]
+ [ run test_banded_storage_layout.cpp
+ :
+ :
+ :
+ :
+ :
+ ]
     ;

Added: trunk/libs/numeric/ublas/test/test_banded_storage_layout.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/numeric/ublas/test/test_banded_storage_layout.cpp 2012-10-21 16:45:15 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,114 @@
+
+#include <iostream>
+#include <boost/numeric/ublas/banded.hpp>
+#include <boost/numeric/ublas/io.hpp>
+#include <boost/numeric/ublas/operation.hpp>
+#include <iomanip>
+
+#include "utils.hpp"
+
+using namespace boost::numeric::ublas;
+
+
+int expected_index( int index, column_major tag ) {
+ // this is the data shown on http://www.netlib.org/lapack/lug/node124.html
+ // read column-by-column, aka column_major
+ int mapping[] = { 0, 11, 21, 31, 12, 22, 32, 42, 23, 33, 43, 53, 34, 44, 54, 0, 45, 55, 0, 0 };
+ return mapping[ index ];
+}
+
+int expected_index( int index, row_major tag ) {
+ // this is the data shown on http://www.netlib.org/lapack/lug/node124.html
+ // read row-by-row, aka row_major
+ int mapping[] = { 0, 0, 11, 12, 0, 21, 22, 23, 31, 32, 33, 34, 42, 43, 44, 45, 53, 54, 55, 0 };
+ return mapping[ index ];
+}
+
+template< typename Orientation >
+bool test_band_storage() {
+
+ int m = 5;
+ int n = 5;
+ int kl = 2;
+ int ku = 1;
+ int band_storage_size = n * (1+kl+ku);
+
+ banded_matrix< int, Orientation > test_matrix( m, n, kl, ku );
+ test_matrix.clear();
+
+ test_matrix( 0, 0 ) = 11;
+ test_matrix( 0, 1 ) = 12;
+ test_matrix( 1, 0 ) = 21;
+ test_matrix( 1, 1 ) = 22;
+ test_matrix( 1, 2 ) = 23;
+ test_matrix( 2, 0 ) = 31;
+ test_matrix( 2, 1 ) = 32;
+ test_matrix( 2, 2 ) = 33;
+ test_matrix( 2, 3 ) = 34;
+ test_matrix( 3, 1 ) = 42;
+ test_matrix( 3, 2 ) = 43;
+ test_matrix( 3, 3 ) = 44;
+ test_matrix( 3, 4 ) = 45;
+ test_matrix( 4, 2 ) = 53;
+ test_matrix( 4, 3 ) = 54;
+ test_matrix( 4, 4 ) = 55;
+
+ BOOST_UBLAS_TEST_TRACE( "Full matrix" );
+ BOOST_UBLAS_TEST_TRACE( std::setw( 3 ) << test_matrix );
+
+ BOOST_UBLAS_TEST_TRACE( "data() of matrix" );
+ for ( int i = 0; i < band_storage_size; ++i ) {
+ std::cerr << test_matrix.data()[ i ] << " ";
+ }
+ std::cerr << std::endl;
+
+ BOOST_UBLAS_TEST_TRACE( "Expected data() of matrix" );
+ for ( int i = 0; i < band_storage_size; ++i ) {
+ std::cerr << expected_index( i, Orientation() ) << " ";
+ }
+ std::cerr << std::endl;
+
+ size_t mismatch = 0;
+
+ for ( int i = 0; i < band_storage_size; ++i ) {
+ if ( test_matrix.data()[ i ] != expected_index( i, Orientation() ) ) {
+ ++mismatch;
+ }
+ }
+
+ return 0 == mismatch;
+}
+
+BOOST_UBLAS_TEST_DEF( banded_matrix_column_major )
+{
+ BOOST_UBLAS_TEST_TRACE( "Test case: storage layout banded_matrix < column_major >" );
+
+ BOOST_UBLAS_TEST_CHECK( test_band_storage< column_major >() );
+}
+
+BOOST_UBLAS_TEST_DEF( banded_matrix_row_major )
+{
+ BOOST_UBLAS_TEST_TRACE( "Test case: storage layout banded_matrix < row_major >" );
+
+ BOOST_UBLAS_TEST_CHECK( test_band_storage< row_major >() );
+}
+
+int main()
+{
+
+ BOOST_UBLAS_TEST_SUITE( "Test storage layout of banded matrix type" );
+
+ BOOST_UBLAS_TEST_TRACE( "Example data taken from http://www.netlib.org/lapack/lug/node124.html" );
+
+ BOOST_UBLAS_TEST_BEGIN();
+
+ BOOST_UBLAS_TEST_DO( banded_matrix_column_major );
+
+ BOOST_UBLAS_TEST_DO( banded_matrix_row_major );
+
+ BOOST_UBLAS_TEST_END();
+
+ return EXIT_SUCCESS;
+}
+
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk