Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58468 - in sandbox/numeric_bindings: boost/numeric/bindings/lapack/computational libs/numeric/bindings/lapack/test libs/numeric/bindings/tools/templates/computational
From: thomas.klimpel_at_[hidden]
Date: 2009-12-20 09:31:25


Author: klimpel
Date: 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
New Revision: 58468
URL: http://svn.boost.org/trac/boost/changeset/58468

Log:
Continue of regression tests update
(OK, that one was really bad. Both hseqr and trevc lead to ambiguous overloads between the real and the complex version.
- For trevc, the complex version is missing a const before the matrix T, because LAPACK declared T as a input/output parameter in the complex case. The reason for this is that the diagonal of T is internally overwritten, but restored before the routine exists. The assert on "m" for trevc is in the wrong place, because "m" is not an input parameter -> it should be possible to fix this problem in the generator.
- For hseqr, the real version takes two vectors for the real and imaginary parts of the eigenvectors. This conflicts with the user-defined workspace version of the complex hseqr. Only way out seems to be two different names.)
Added:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hseqr.hpp (contents, props changed)
Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp | 20 ++++++++++----------
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trevc.hpp | 6 ++++--
   sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/hseqr.cpp | 28 +++++++++++++++++++---------
   sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/ublas_geqrf.cpp | 2 +-
   4 files changed, 34 insertions(+), 22 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/hseqr.hpp 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
@@ -104,7 +104,7 @@
         BOOST_ASSERT( traits::vector_size(wr) >=
                 traits::matrix_num_columns(h) );
         BOOST_ASSERT( traits::vector_size(work.select(real_type())) >=
- min_size_work( $CALL_MIN_SIZE ));
+ min_size_work( traits::matrix_num_columns(h) ));
         detail::hseqr( job, compz, traits::matrix_num_columns(h), ilo, ihi,
                 traits::matrix_storage(h), traits::leading_dimension(h),
                 traits::vector_storage(wr), traits::vector_storage(wi),
@@ -120,7 +120,7 @@
             const integer_t ihi, MatrixH& h, VectorWR& wr, VectorWI& wi,
             MatrixZ& z, integer_t& info, minimal_workspace work ) {
         traits::detail::array< real_type > tmp_work( min_size_work(
- $CALL_MIN_SIZE ) );
+ traits::matrix_num_columns(h) ) );
         invoke( job, compz, ilo, ihi, h, wr, wi, z, info,
                 workspace( tmp_work ) );
     }
@@ -135,8 +135,8 @@
                 minimal_workspace() );
     }
 
- static integer_t min_size_work( $ARGUMENTS ) {
- $MIN_SIZE
+ static integer_t min_size_work( const integer_t n ) {
+ return std::max< std::ptrdiff_t >( 1, n );
     }
 };
 
@@ -162,7 +162,7 @@
         BOOST_ASSERT( job == 'E' || job == 'S' );
         BOOST_ASSERT( compz == 'N' || compz == 'I' || compz == 'V' );
         BOOST_ASSERT( traits::vector_size(work.select(value_type())) >=
- min_size_work( $CALL_MIN_SIZE ));
+ min_size_work( traits::matrix_num_columns(h) ));
         detail::hseqr( job, compz, traits::matrix_num_columns(h), ilo, ihi,
                 traits::matrix_storage(h), traits::leading_dimension(h),
                 traits::vector_storage(w), traits::matrix_storage(z),
@@ -177,7 +177,7 @@
             const integer_t ihi, MatrixH& h, VectorW& w, MatrixZ& z,
             integer_t& info, minimal_workspace work ) {
         traits::detail::array< value_type > tmp_work( min_size_work(
- $CALL_MIN_SIZE ) );
+ traits::matrix_num_columns(h) ) );
         invoke( job, compz, ilo, ihi, h, w, z, info, workspace( tmp_work ) );
     }
 
@@ -189,8 +189,8 @@
         invoke( job, compz, ilo, ihi, h, w, z, info, minimal_workspace() );
     }
 
- static integer_t min_size_work( $ARGUMENTS ) {
- $MIN_SIZE
+ static integer_t min_size_work( const integer_t n ) {
+ return std::max< std::ptrdiff_t >( 1, n );
     }
 };
 
@@ -198,7 +198,7 @@
 // template function to call hseqr
 template< typename MatrixH, typename VectorWR, typename VectorWI,
         typename MatrixZ, typename Workspace >
-inline integer_t hseqr( const char job, const char compz,
+inline integer_t hseqr_2( const char job, const char compz,
         const integer_t ilo, const integer_t ihi, MatrixH& h, VectorWR& wr,
         VectorWI& wi, MatrixZ& z, Workspace work ) {
     typedef typename traits::matrix_traits< MatrixH >::value_type value_type;
@@ -211,7 +211,7 @@
 // template function to call hseqr, default workspace type
 template< typename MatrixH, typename VectorWR, typename VectorWI,
         typename MatrixZ >
-inline integer_t hseqr( const char job, const char compz,
+inline integer_t hseqr_2( const char job, const char compz,
         const integer_t ilo, const integer_t ihi, MatrixH& h, VectorWR& wr,
         VectorWI& wi, MatrixZ& z ) {
     typedef typename traits::matrix_traits< MatrixH >::value_type value_type;

Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trevc.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trevc.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trevc.hpp 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
@@ -102,7 +102,6 @@
         BOOST_ASSERT( traits::matrix_num_columns(t) >= 0 );
         BOOST_ASSERT( traits::leading_dimension(t) >= std::max<
                 std::ptrdiff_t >(1,traits::matrix_num_columns(t)) );
- BOOST_ASSERT( mm >= m );
         BOOST_ASSERT( traits::vector_size(work.select(real_type())) >=
                 min_size_work( traits::matrix_num_columns(t) ));
         detail::trevc( side, howmny, traits::vector_storage(select),
@@ -111,6 +110,7 @@
                 traits::leading_dimension(vl), traits::matrix_storage(vr),
                 traits::leading_dimension(vr), mm, m,
                 traits::vector_storage(work.select(real_type())), info );
+ BOOST_ASSERT( mm >= m );
     }
 
     // minimal workspace specialization
@@ -167,7 +167,6 @@
         BOOST_ASSERT( traits::matrix_num_columns(t) >= 0 );
         BOOST_ASSERT( traits::leading_dimension(t) >= std::max<
                 std::ptrdiff_t >(1,traits::matrix_num_columns(t)) );
- BOOST_ASSERT( mm >= m );
         BOOST_ASSERT( traits::vector_size(work.select(value_type())) >=
                 min_size_work( traits::matrix_num_columns(t) ));
         BOOST_ASSERT( traits::vector_size(work.select(real_type())) >=
@@ -179,6 +178,7 @@
                 traits::leading_dimension(vr), mm, m,
                 traits::vector_storage(work.select(value_type())),
                 traits::vector_storage(work.select(real_type())), info );
+ BOOST_ASSERT( mm >= m );
     }
 
     // minimal workspace specialization
@@ -217,6 +217,7 @@
 };
 
 
+/*
 // template function to call trevc
 template< typename VectorSELECT, typename MatrixT, typename MatrixVL,
         typename MatrixVR, typename Workspace >
@@ -242,6 +243,7 @@
             mm, m, info, optimal_workspace() );
     return info;
 }
+*/
 // template function to call trevc
 template< typename VectorSELECT, typename MatrixT, typename MatrixVL,
         typename MatrixVR, typename Workspace >

Modified: sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/hseqr.cpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/hseqr.cpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/hseqr.cpp 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
@@ -8,9 +8,9 @@
 #include <boost/numeric/ublas/io.hpp>
 #include <boost/numeric/bindings/traits/ublas_matrix.hpp>
 #include <boost/numeric/bindings/traits/ublas_vector.hpp>
-#include <boost/numeric/bindings/lapack/geev.hpp>
-#include <boost/numeric/bindings/lapack/hseqr.hpp>
-#include <boost/numeric/bindings/lapack/trevc.hpp>
+#include <boost/numeric/bindings/traits/detail/utils.hpp>
+#include <boost/numeric/bindings/lapack/computational/hseqr.hpp>
+#include <boost/numeric/bindings/lapack/computational/trevc.hpp>
 
 using std::cout;
 using std::endl;
@@ -19,6 +19,7 @@
 
 namespace ublas = boost::numeric::ublas;
 namespace lapack = boost::numeric::bindings::lapack;
+namespace traits = boost::numeric::bindings::traits;
 
 void hseqr(int);
 template <typename T>
@@ -41,17 +42,22 @@
     cout << "\nUpper Hessenberg matrix H:\n" << H << endl;
 
     ublas::vector<complex<double> > values(n);
+ ublas::vector<double> values_r(n);
+ ublas::vector<double> values_i(n);
     ublas::matrix<double, ublas::column_major> Z(n,n);
 
     cout << "\nHSEQR for only eigenvalues." << endl;
- lapack::hseqr('E', H, values);
+ ublas::matrix<double, ublas::column_major> Z_dummy(1,1);
+ lapack::hseqr_2('E', 'N', 1, n, H, values_r, values_i, Z_dummy);
+ traits::detail::interlace(values_r.begin(), values_r.end(), values_i.begin(), values.begin());
     cout << "\nH:\n" << H << endl;
     cout << "\nvalues: " << values << endl;
 
     cout << "\nHSEQR for eigenvalues and Schur vectors." << endl;
     Hessenberg(H);
     cout << "H:\n" << H << endl;
- lapack::hseqr('S', 'I', H, values, Z);
+ lapack::hseqr_2('S', 'I', 1, n, H, values_r, values_i, Z);
+ traits::detail::interlace(values_r.begin(), values_r.end(), values_i.begin(), values.begin());
     cout << "\nH: " << H << endl;
     cout << "\nvalues: " << values << endl;
     cout << "\nZ: " << Z << endl;
@@ -69,7 +75,8 @@
     ublas::matrix<complex<double>, ublas::column_major> G(n,n);
     Hessenberg(G);
     cout << "\nG:\n" << G << endl;
- lapack::hseqr('E', G, values);
+ ublas::matrix<complex<double>, ublas::column_major> cZ_dummy(1,1);
+ lapack::hseqr('E', 'N', 1, n, G, values, cZ_dummy);
     cout << "\nG:\n" << G << endl;
     cout << "\nvalues: " << values << endl;
 
@@ -77,7 +84,7 @@
     Hessenberg(G);
     cout << "G:\n" << G << endl;
     ublas::matrix<complex<double>, ublas::column_major> cZ(n,n);
- lapack::hseqr('S', 'I', G, values, cZ);
+ lapack::hseqr('S', 'I', 1, n, G, values, cZ);
     cout << "\nG:\n " << G << endl;
     cout << "\nvalues: " << values << endl;
     cout << "\nZ:\n " << Z << endl;
@@ -92,8 +99,11 @@
 
     ublas::matrix<complex<double>, ublas::column_major> cVL(cZ);
     ublas::matrix<complex<double>, ublas::column_major> cVR(cZ);
- boost::numeric::bindings::traits::detail::array<complex<double> > work(3*n);
- lapack::trevc('B','B',G,cVL,cVR,work);
+ boost::numeric::bindings::traits::detail::array<complex<double> > work_c(2*n);
+ boost::numeric::bindings::traits::detail::array<double> work_r(n);
+ ublas::vector<bool> select_dummy(n);
+ integer_t m_info(0);
+ lapack::trevc('B','B',select_dummy,G,cVL,cVR,n,m_info,lapack::workspace(work_c,work_r));
 
     cout << "\n==================================" << endl;
     cout << "Testing left & right eigenvectors..." << endl;

Modified: sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/ublas_geqrf.cpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/ublas_geqrf.cpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/lapack/test/ublas_geqrf.cpp 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
@@ -146,7 +146,7 @@
    if (do_memory_type<T,lapack::minimal_workspace>( n, lapack::minimal_workspace() ) ) return 255 ;
 
    ublas::vector<T> work( n );
- do_memory_type<T, lapack::detail::workspace1<ublas::vector<T> > >( n, lapack::workspace(work) );
+ if (do_memory_type<T, lapack::detail::workspace1<ublas::vector<T> > >( n, lapack::workspace(work) ) ) return 255 ;
    return 0;
 } // do_value_type()
 

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hseqr.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hseqr.hpp 2009-12-20 09:31:24 EST (Sun, 20 Dec 2009)
@@ -0,0 +1,7 @@
+$TEMPLATE[hseqr.all.min_size_work.args]
+N
+$TEMPLATE[hseqr.real.min_size_work]
+return std::max< $INTEGER_TYPE >( 1, n );
+$TEMPLATE[hseqr.complex.min_size_work]
+return std::max< $INTEGER_TYPE >( 1, n );
+$TEMPLATE[end]


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