$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64116 - in sandbox/numeric_bindings: boost/numeric/bindings/lapack boost/numeric/bindings/lapack/computational libs/numeric/bindings/tools libs/numeric/bindings/tools/templates
From: thomas.klimpel_at_[hidden]
Date: 2010-07-17 19:44:34
Author: klimpel
Date: 2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
New Revision: 64116
URL: http://svn.boost.org/trac/boost/changeset/64116
Log:
No more hand editing of lapack/computational.hpp!
Moved initialization of variable "subroutine" before first of it.
Replaced occurrences of "fortran_int_t" in the templates by "$LIBRARY_INT_TYPE"
Text files modified: 
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational.hpp        |     4                                         
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/tgexc.hpp  |   745 ++++++++++++++++++++------------------- 
   sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trexc.hpp  |   206 +++++-----                              
   sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py        |     8                                         
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp       |     2                                         
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp |     8                                         
   6 files changed, 493 insertions(+), 480 deletions(-)
Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational.hpp	(original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational.hpp	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -61,7 +61,7 @@
 #include <boost/numeric/bindings/lapack/computational/orghr.hpp>
 #include <boost/numeric/bindings/lapack/computational/ormhr.hpp>
 #include <boost/numeric/bindings/lapack/computational/trevc.hpp>
-//#include <boost/numeric/bindings/lapack/computational/trexc.hpp>
+#include <boost/numeric/bindings/lapack/computational/trexc.hpp>
 #include <boost/numeric/bindings/lapack/computational/trsen.hpp>
 #include <boost/numeric/bindings/lapack/computational/trsna.hpp>
 #include <boost/numeric/bindings/lapack/computational/trsyl.hpp>
@@ -163,7 +163,7 @@
 #include <boost/numeric/bindings/lapack/computational/gghrd.hpp>
 #include <boost/numeric/bindings/lapack/computational/hgeqz.hpp>
 #include <boost/numeric/bindings/lapack/computational/tgevc.hpp>
-//#include <boost/numeric/bindings/lapack/computational/tgexc.hpp>
+#include <boost/numeric/bindings/lapack/computational/tgexc.hpp>
 #include <boost/numeric/bindings/lapack/computational/tgsen.hpp>
 #include <boost/numeric/bindings/lapack/computational/tgsna.hpp>
 #include <boost/numeric/bindings/lapack/computational/tgsyl.hpp>
Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/tgexc.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/tgexc.hpp	(original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/tgexc.hpp	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -136,15 +136,16 @@
     typedef typename remove_imaginary< Value >::type real_type;
 
     //
-    // Static member function, that
+    // Static member function for user-defined workspaces, that
     // * Deduces the required arguments for dispatching to LAPACK, and
     // * Asserts that most arguments make sense.
     //
     template< typename MatrixA, typename MatrixB, typename MatrixQ,
-            typename MatrixZ >
+            typename MatrixZ, typename WORK >
     static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
             MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-            fortran_int_t& ifst, fortran_int_t& ilst ) {
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            detail::workspace1< WORK > work ) {
         namespace bindings = ::boost::numeric::bindings;
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixA >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixB >::value) );
@@ -190,6 +191,63 @@
                 bindings::size(work.select(real_type())) );
     }
 
+    //
+    // Static member function that
+    // * Figures out the minimal workspace requirements, and passes
+    //   the results to the user-defined workspace overload of the 
+    //   invoke static member function
+    // * Enables the unblocked algorithm (BLAS level 2)
+    //
+    template< typename MatrixA, typename MatrixB, typename MatrixQ,
+            typename MatrixZ >
+    static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
+            MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            minimal_workspace ) {
+        namespace bindings = ::boost::numeric::bindings;
+        bindings::detail::array< real_type > tmp_work( min_size_work(
+                bindings::size_column(a) ) );
+        return invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+                workspace( tmp_work ) );
+    }
+
+    //
+    // Static member function that
+    // * Figures out the optimal workspace requirements, and passes
+    //   the results to the user-defined workspace overload of the 
+    //   invoke static member
+    // * Enables the blocked algorithm (BLAS level 3)
+    //
+    template< typename MatrixA, typename MatrixB, typename MatrixQ,
+            typename MatrixZ >
+    static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
+            MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            optimal_workspace ) {
+        namespace bindings = ::boost::numeric::bindings;
+        real_type opt_size_work;
+        detail::tgexc( wantq, wantz, bindings::size_column(a),
+                bindings::begin_value(a), bindings::stride_major(a),
+                bindings::begin_value(b), bindings::stride_major(b),
+                bindings::begin_value(q), bindings::stride_major(q),
+                bindings::begin_value(z), bindings::stride_major(z), ifst,
+                ilst, &opt_size_work, -1 );
+        bindings::detail::array< real_type > tmp_work(
+                traits::detail::to_int( opt_size_work ) );
+        return invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+                workspace( tmp_work ) );
+    }
+
+    //
+    // Static member function that returns the minimum size of
+    // workspace-array work.
+    //
+    static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
+        if (n <= 1)
+            return 1;
+        else
+            return 4*n + 16;
+    }
 };
 
 //
@@ -202,16 +260,15 @@
     typedef typename remove_imaginary< Value >::type real_type;
 
     //
-    // Static member function for user-defined workspaces, that
+    // Static member function, that
     // * Deduces the required arguments for dispatching to LAPACK, and
     // * Asserts that most arguments make sense.
     //
     template< typename MatrixA, typename MatrixB, typename MatrixQ,
-            typename MatrixZ, $WORKSPACE_TYPENAMES >
+            typename MatrixZ >
     static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
             MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-            const fortran_int_t ifst, fortran_int_t& ilst,
-            detail::workspace$WORKSPACE_SIZE< $WORKSPACE_TYPES > work ) {
+            const fortran_int_t ifst, fortran_int_t& ilst ) {
         namespace bindings = ::boost::numeric::bindings;
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixA >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixB >::value) );
@@ -254,43 +311,6 @@
                 ilst );
     }
 
-    //
-    // Static member function that
-    // * Figures out the minimal workspace requirements, and passes
-    //   the results to the user-defined workspace overload of the 
-    //   invoke static member function
-    // * Enables the unblocked algorithm (BLAS level 2)
-    //
-    template< typename MatrixA, typename MatrixB, typename MatrixQ,
-            typename MatrixZ >
-    static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
-            MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-            const fortran_int_t ifst, fortran_int_t& ilst,
-            minimal_workspace ) {
-        namespace bindings = ::boost::numeric::bindings;
-$SETUP_MIN_WORKARRAYS_POST
-        return invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-                workspace( $TMP_WORKARRAYS ) );
-    }
-
-    //
-    // Static member function that
-    // * Figures out the optimal workspace requirements, and passes
-    //   the results to the user-defined workspace overload of the 
-    //   invoke static member
-    // * Enables the blocked algorithm (BLAS level 3)
-    //
-    template< typename MatrixA, typename MatrixB, typename MatrixQ,
-            typename MatrixZ >
-    static std::ptrdiff_t invoke( const logical_t wantq, const logical_t wantz,
-            MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-            const fortran_int_t ifst, fortran_int_t& ilst,
-            optimal_workspace ) {
-        namespace bindings = ::boost::numeric::bindings;
-$OPT_WORKSPACE_FUNC
-    }
-
-$MIN_SIZE_FUNCS
 };
 
 
@@ -309,238 +329,298 @@
 // * MatrixB&
 // * MatrixQ&
 // * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
+// * MatrixA&
 // * MatrixB&
 // * MatrixQ&
 // * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
-// * const MatrixB&
+// * const MatrixA&
+// * MatrixB&
 // * MatrixQ&
 // * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
-// * const MatrixB&
+// * MatrixB&
 // * MatrixQ&
 // * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
-// * MatrixB&
-// * const MatrixQ&
+// * const MatrixB&
+// * MatrixQ&
 // * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        const MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
-// * MatrixB&
-// * const MatrixQ&
+// * MatrixA&
+// * const MatrixB&
+// * MatrixQ&
 // * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        const MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
+// * const MatrixA&
 // * const MatrixB&
-// * const MatrixQ&
+// * MatrixQ&
 // * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        const MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
 // * const MatrixB&
-// * const MatrixQ&
+// * MatrixQ&
 // * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        const MatrixB& b, MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
 // * MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
+// * const MatrixQ&
+// * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        MatrixB& b, const MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
+// * MatrixA&
 // * MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
+// * const MatrixQ&
+// * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        MatrixB& b, const MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
-// * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
+// * const MatrixA&
+// * MatrixB&
+// * const MatrixQ&
+// * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, const MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        MatrixB& b, const MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
-// * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
-//
-template< typename MatrixA, typename MatrixB, typename MatrixQ,
+// * MatrixB&
+// * const MatrixQ&
+// * MatrixZ&
+// * Default workspace-type (optimal)
+//
+template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, const MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        MatrixB& b, const MatrixQ& q, MatrixZ& z, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
-// * MatrixB&
+// * const MatrixB&
 // * const MatrixQ&
-// * const MatrixZ&
+// * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
-// * MatrixB&
+// * MatrixA&
+// * const MatrixB&
 // * const MatrixQ&
-// * const MatrixZ&
+// * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
+        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
         fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
+// * const MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * const MatrixZ&
+// * MatrixZ&
+// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        MatrixA& a, const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
+        typename MatrixZ, typename Workspace >
+inline typename boost::enable_if< detail::is_workspace< Workspace >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            work );
 }
 
 //
@@ -548,22 +628,27 @@
 // * const MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * const MatrixZ&
+// * MatrixZ&
+// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
-        const MatrixA& a, const MatrixB& b, const MatrixQ& q,
-        const MatrixZ& z, fortran_int_t& ifst, fortran_int_t& ilst ) {
+inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
+        std::ptrdiff_t >::type
+tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
+        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
+            optimal_workspace() );
 }
+
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -571,7 +656,7 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, MatrixQ& q, MatrixZ& z, const fortran_int_t ifst,
+        MatrixB& b, MatrixQ& q, const MatrixZ& z, fortran_int_t& ifst,
         fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
@@ -583,7 +668,7 @@
 // * MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -591,7 +676,7 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, MatrixQ& q, MatrixZ& z, const fortran_int_t ifst,
+        MatrixB& b, MatrixQ& q, const MatrixZ& z, fortran_int_t& ifst,
         fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
@@ -603,7 +688,7 @@
 // * const MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -611,7 +696,7 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, MatrixQ& q, MatrixZ& z, const fortran_int_t ifst,
+        MatrixB& b, MatrixQ& q, const MatrixZ& z, fortran_int_t& ifst,
         fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
@@ -623,7 +708,7 @@
 // * const MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -631,7 +716,7 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, MatrixQ& q, MatrixZ& z, const fortran_int_t ifst,
+        MatrixB& b, MatrixQ& q, const MatrixZ& z, fortran_int_t& ifst,
         fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
@@ -643,7 +728,7 @@
 // * MatrixA&
 // * const MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -651,9 +736,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -664,7 +748,7 @@
 // * MatrixA&
 // * const MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -672,8 +756,8 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
@@ -684,7 +768,7 @@
 // * const MatrixA&
 // * const MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -692,9 +776,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -705,7 +788,7 @@
 // * const MatrixA&
 // * const MatrixB&
 // * MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -713,8 +796,8 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
@@ -725,7 +808,7 @@
 // * MatrixA&
 // * MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -733,9 +816,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -746,7 +828,7 @@
 // * MatrixA&
 // * MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -754,8 +836,8 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
@@ -766,7 +848,7 @@
 // * const MatrixA&
 // * MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -774,9 +856,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -787,7 +868,7 @@
 // * const MatrixA&
 // * MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -795,8 +876,8 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
@@ -807,7 +888,7 @@
 // * MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -815,9 +896,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -828,7 +908,7 @@
 // * MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -836,8 +916,8 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
@@ -848,7 +928,7 @@
 // * const MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -856,9 +936,8 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             work );
@@ -869,7 +948,7 @@
 // * const MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
-// * MatrixZ&
+// * const MatrixZ&
 // * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
@@ -877,319 +956,250 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
         std::ptrdiff_t >::type
 tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
             MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
             optimal_workspace() );
 }
-
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * const MatrixZ&
-// * User-defined workspace
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
+// * const MatrixA&
 // * MatrixB&
 // * MatrixQ&
-// * const MatrixZ&
-// * Default workspace-type (optimal)
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, MatrixB& b, MatrixQ& q, MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
-// * MatrixB&
+// * MatrixA&
+// * const MatrixB&
 // * MatrixQ&
-// * const MatrixZ&
-// * User-defined workspace
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, const MatrixB& b, MatrixQ& q, MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
-// * MatrixB&
+// * const MatrixB&
 // * MatrixQ&
-// * const MatrixZ&
-// * Default workspace-type (optimal)
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, const MatrixB& b, MatrixQ& q, MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
-// * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
-// * User-defined workspace
+// * MatrixB&
+// * const MatrixQ&
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, MatrixB& b, const MatrixQ& q, MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
-// * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
-// * Default workspace-type (optimal)
+// * const MatrixA&
+// * MatrixB&
+// * const MatrixQ&
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, MatrixB& b, const MatrixQ& q, MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
+// * MatrixA&
 // * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
-// * User-defined workspace
+// * const MatrixQ&
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, const MatrixB& b, const MatrixQ& q, MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
 // * const MatrixB&
-// * MatrixQ&
-// * const MatrixZ&
-// * Default workspace-type (optimal)
+// * const MatrixQ&
+// * MatrixZ&
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, const MatrixB& b, const MatrixQ& q, MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
 // * MatrixB&
-// * const MatrixQ&
+// * MatrixQ&
 // * const MatrixZ&
-// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
+// * const MatrixA&
 // * MatrixB&
-// * const MatrixQ&
+// * MatrixQ&
 // * const MatrixZ&
-// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, MatrixB& b, MatrixQ& q, const MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
-// * MatrixB&
-// * const MatrixQ&
+// * MatrixA&
+// * const MatrixB&
+// * MatrixQ&
 // * const MatrixZ&
-// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, const MatrixB& b, MatrixQ& q, const MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * const MatrixA&
-// * MatrixB&
-// * const MatrixQ&
+// * const MatrixB&
+// * MatrixQ&
 // * const MatrixZ&
-// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, const MatrixB& b, MatrixQ& q, const MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
 // * MatrixA&
-// * const MatrixB&
+// * MatrixB&
 // * const MatrixQ&
 // * const MatrixZ&
-// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * MatrixA&
-// * const MatrixB&
+// * const MatrixA&
+// * MatrixB&
 // * const MatrixQ&
 // * const MatrixZ&
-// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, MatrixB& b, const MatrixQ& q, const MatrixZ& z,
         const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
 // Overloaded function for tgexc. Its overload differs for
-// * const MatrixA&
+// * MatrixA&
 // * const MatrixB&
 // * const MatrixQ&
 // * const MatrixZ&
-// * User-defined workspace
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
-        typename MatrixZ, typename Workspace >
-inline typename boost::enable_if< detail::is_workspace< Workspace >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst,
-        Workspace work ) {
+        typename MatrixZ >
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        MatrixA& a, const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
+        const fortran_int_t ifst, fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            work );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 //
@@ -1198,18 +1208,15 @@
 // * const MatrixB&
 // * const MatrixQ&
 // * const MatrixZ&
-// * Default workspace-type (optimal)
 //
 template< typename MatrixA, typename MatrixB, typename MatrixQ,
         typename MatrixZ >
-inline typename boost::disable_if< detail::is_workspace< MatrixZ >,
-        std::ptrdiff_t >::type
-tgexc( const logical_t wantq, const logical_t wantz, const MatrixA& a,
-        const MatrixB& b, const MatrixQ& q, const MatrixZ& z,
-        const fortran_int_t ifst, fortran_int_t& ilst ) {
+inline std::ptrdiff_t tgexc( const logical_t wantq, const logical_t wantz,
+        const MatrixA& a, const MatrixB& b, const MatrixQ& q,
+        const MatrixZ& z, const fortran_int_t ifst,
+        fortran_int_t& ilst ) {
     return tgexc_impl< typename bindings::value_type<
-            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst,
-            optimal_workspace() );
+            MatrixA >::type >::invoke( wantq, wantz, a, b, q, z, ifst, ilst );
 }
 
 } // namespace lapack
Modified: sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trexc.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trexc.hpp	(original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/lapack/computational/trexc.hpp	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -122,13 +122,14 @@
     typedef typename remove_imaginary< Value >::type real_type;
 
     //
-    // Static member function, that
+    // Static member function for user-defined workspaces, that
     // * Deduces the required arguments for dispatching to LAPACK, and
     // * Asserts that most arguments make sense.
     //
-    template< typename MatrixT, typename MatrixQ >
+    template< typename MatrixT, typename MatrixQ, typename WORK >
     static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
-            fortran_int_t& ifst, fortran_int_t& ilst ) {
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            detail::workspace1< WORK > work ) {
         namespace bindings = ::boost::numeric::bindings;
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixT >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixQ >::value) );
@@ -156,6 +157,45 @@
                 ilst, bindings::begin_value(work.select(real_type())) );
     }
 
+    //
+    // Static member function that
+    // * Figures out the minimal workspace requirements, and passes
+    //   the results to the user-defined workspace overload of the 
+    //   invoke static member function
+    // * Enables the unblocked algorithm (BLAS level 2)
+    //
+    template< typename MatrixT, typename MatrixQ >
+    static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            minimal_workspace ) {
+        namespace bindings = ::boost::numeric::bindings;
+        bindings::detail::array< real_type > tmp_work( min_size_work(
+                bindings::size_column(t) ) );
+        return invoke( compq, t, q, ifst, ilst, workspace( tmp_work ) );
+    }
+
+    //
+    // Static member function that
+    // * Figures out the optimal workspace requirements, and passes
+    //   the results to the user-defined workspace overload of the 
+    //   invoke static member
+    // * Enables the blocked algorithm (BLAS level 3)
+    //
+    template< typename MatrixT, typename MatrixQ >
+    static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
+            fortran_int_t& ifst, fortran_int_t& ilst,
+            optimal_workspace ) {
+        namespace bindings = ::boost::numeric::bindings;
+        return invoke( compq, t, q, ifst, ilst, minimal_workspace() );
+    }
+
+    //
+    // Static member function that returns the minimum size of
+    // workspace-array work.
+    //
+    static std::ptrdiff_t min_size_work( const std::ptrdiff_t n ) {
+        return n;
+    }
 };
 
 //
@@ -168,14 +208,13 @@
     typedef typename remove_imaginary< Value >::type real_type;
 
     //
-    // Static member function for user-defined workspaces, that
+    // Static member function, that
     // * Deduces the required arguments for dispatching to LAPACK, and
     // * Asserts that most arguments make sense.
     //
-    template< typename MatrixT, typename MatrixQ, $WORKSPACE_TYPENAMES >
+    template< typename MatrixT, typename MatrixQ >
     static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
-            const fortran_int_t ifst, const fortran_int_t ilst,
-            detail::workspace$WORKSPACE_SIZE< $WORKSPACE_TYPES > work ) {
+            const fortran_int_t ifst, const fortran_int_t ilst ) {
         namespace bindings = ::boost::numeric::bindings;
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixT >::value) );
         BOOST_STATIC_ASSERT( (bindings::is_column_major< MatrixQ >::value) );
@@ -201,38 +240,6 @@
                 ilst );
     }
 
-    //
-    // Static member function that
-    // * Figures out the minimal workspace requirements, and passes
-    //   the results to the user-defined workspace overload of the 
-    //   invoke static member function
-    // * Enables the unblocked algorithm (BLAS level 2)
-    //
-    template< typename MatrixT, typename MatrixQ >
-    static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
-            const fortran_int_t ifst, const fortran_int_t ilst,
-            minimal_workspace ) {
-        namespace bindings = ::boost::numeric::bindings;
-$SETUP_MIN_WORKARRAYS_POST
-        return invoke( compq, t, q, ifst, ilst, workspace( $TMP_WORKARRAYS ) );
-    }
-
-    //
-    // Static member function that
-    // * Figures out the optimal workspace requirements, and passes
-    //   the results to the user-defined workspace overload of the 
-    //   invoke static member
-    // * Enables the blocked algorithm (BLAS level 3)
-    //
-    template< typename MatrixT, typename MatrixQ >
-    static std::ptrdiff_t invoke( const char compq, MatrixT& t, MatrixQ& q,
-            const fortran_int_t ifst, const fortran_int_t ilst,
-            optimal_workspace ) {
-        namespace bindings = ::boost::numeric::bindings;
-$OPT_WORKSPACE_FUNC
-    }
-
-$MIN_SIZE_FUNCS
 };
 
 
@@ -249,61 +256,13 @@
 // Overloaded function for trexc. Its overload differs for
 // * MatrixT&
 // * MatrixQ&
-//
-template< typename MatrixT, typename MatrixQ >
-inline std::ptrdiff_t trexc( const char compq, MatrixT& t, MatrixQ& q,
-        fortran_int_t& ifst, fortran_int_t& ilst ) {
-    return trexc_impl< typename bindings::value_type<
-            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
-}
-
-//
-// Overloaded function for trexc. Its overload differs for
-// * const MatrixT&
-// * MatrixQ&
-//
-template< typename MatrixT, typename MatrixQ >
-inline std::ptrdiff_t trexc( const char compq, const MatrixT& t,
-        MatrixQ& q, fortran_int_t& ifst, fortran_int_t& ilst ) {
-    return trexc_impl< typename bindings::value_type<
-            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
-}
-
-//
-// Overloaded function for trexc. Its overload differs for
-// * MatrixT&
-// * const MatrixQ&
-//
-template< typename MatrixT, typename MatrixQ >
-inline std::ptrdiff_t trexc( const char compq, MatrixT& t,
-        const MatrixQ& q, fortran_int_t& ifst, fortran_int_t& ilst ) {
-    return trexc_impl< typename bindings::value_type<
-            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
-}
-
-//
-// Overloaded function for trexc. Its overload differs for
-// * const MatrixT&
-// * const MatrixQ&
-//
-template< typename MatrixT, typename MatrixQ >
-inline std::ptrdiff_t trexc( const char compq, const MatrixT& t,
-        const MatrixQ& q, fortran_int_t& ifst, fortran_int_t& ilst ) {
-    return trexc_impl< typename bindings::value_type<
-            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
-}
-//
-// Overloaded function for trexc. Its overload differs for
-// * MatrixT&
-// * MatrixQ&
 // * User-defined workspace
 //
 template< typename MatrixT, typename MatrixQ, typename Workspace >
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
-trexc( const char compq, MatrixT& t, MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst,
-        Workspace work ) {
+trexc( const char compq, MatrixT& t, MatrixQ& q, fortran_int_t& ifst,
+        fortran_int_t& ilst, Workspace work ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst, work );
 }
@@ -317,8 +276,8 @@
 template< typename MatrixT, typename MatrixQ >
 inline typename boost::disable_if< detail::is_workspace< MatrixQ >,
         std::ptrdiff_t >::type
-trexc( const char compq, MatrixT& t, MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst ) {
+trexc( const char compq, MatrixT& t, MatrixQ& q, fortran_int_t& ifst,
+        fortran_int_t& ilst ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst,
             optimal_workspace() );
@@ -334,8 +293,7 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 trexc( const char compq, const MatrixT& t, MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst,
-        Workspace work ) {
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst, work );
 }
@@ -350,7 +308,7 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixQ >,
         std::ptrdiff_t >::type
 trexc( const char compq, const MatrixT& t, MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst ) {
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst,
             optimal_workspace() );
@@ -366,8 +324,7 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 trexc( const char compq, MatrixT& t, const MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst,
-        Workspace work ) {
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst, work );
 }
@@ -382,7 +339,7 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixQ >,
         std::ptrdiff_t >::type
 trexc( const char compq, MatrixT& t, const MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst ) {
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst,
             optimal_workspace() );
@@ -398,8 +355,7 @@
 inline typename boost::enable_if< detail::is_workspace< Workspace >,
         std::ptrdiff_t >::type
 trexc( const char compq, const MatrixT& t, const MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst,
-        Workspace work ) {
+        fortran_int_t& ifst, fortran_int_t& ilst, Workspace work ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst, work );
 }
@@ -414,11 +370,61 @@
 inline typename boost::disable_if< detail::is_workspace< MatrixQ >,
         std::ptrdiff_t >::type
 trexc( const char compq, const MatrixT& t, const MatrixQ& q,
-        const fortran_int_t ifst, const fortran_int_t ilst ) {
+        fortran_int_t& ifst, fortran_int_t& ilst ) {
     return trexc_impl< typename bindings::value_type<
             MatrixT >::type >::invoke( compq, t, q, ifst, ilst,
             optimal_workspace() );
 }
+//
+// Overloaded function for trexc. Its overload differs for
+// * MatrixT&
+// * MatrixQ&
+//
+template< typename MatrixT, typename MatrixQ >
+inline std::ptrdiff_t trexc( const char compq, MatrixT& t, MatrixQ& q,
+        const fortran_int_t ifst, const fortran_int_t ilst ) {
+    return trexc_impl< typename bindings::value_type<
+            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
+}
+
+//
+// Overloaded function for trexc. Its overload differs for
+// * const MatrixT&
+// * MatrixQ&
+//
+template< typename MatrixT, typename MatrixQ >
+inline std::ptrdiff_t trexc( const char compq, const MatrixT& t,
+        MatrixQ& q, const fortran_int_t ifst,
+        const fortran_int_t ilst ) {
+    return trexc_impl< typename bindings::value_type<
+            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
+}
+
+//
+// Overloaded function for trexc. Its overload differs for
+// * MatrixT&
+// * const MatrixQ&
+//
+template< typename MatrixT, typename MatrixQ >
+inline std::ptrdiff_t trexc( const char compq, MatrixT& t,
+        const MatrixQ& q, const fortran_int_t ifst,
+        const fortran_int_t ilst ) {
+    return trexc_impl< typename bindings::value_type<
+            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
+}
+
+//
+// Overloaded function for trexc. Its overload differs for
+// * const MatrixT&
+// * const MatrixQ&
+//
+template< typename MatrixT, typename MatrixQ >
+inline std::ptrdiff_t trexc( const char compq, const MatrixT& t,
+        const MatrixQ& q, const fortran_int_t ifst,
+        const fortran_int_t ilst ) {
+    return trexc_impl< typename bindings::value_type<
+            MatrixT >::type >::invoke( compq, t, q, ifst, ilst );
+}
 
 } // namespace lapack
 } // namespace bindings
Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py	(original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -195,6 +195,10 @@
     level2_map = {}
     for value_type, case_map in cases.iteritems():
 
+      # take this subroutine for arguments etc.
+      subroutine = case_map[ 'subroutines' ][ 0 ]
+      print "taking",subroutine
+
       level1_template = ''
       level2_template = ''
       if info_map[ subroutine ][ 'grouped_arguments' ][ 'by_io' ].has_key( 'workspace' ):
@@ -222,10 +226,6 @@
       level1_template = level1_template.replace( '$groupname', group_name.lower() )
       level1_template = level1_template.replace( "$SPECIALIZATION", value_type )
 
-      # take this subroutine for arguments etc.
-      subroutine = case_map[ 'subroutines' ][ 0 ]
-      print "taking",subroutine
-      
       level0_arg_list = []
       level1_arg_list = []
       level2_arg_list = []
Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp	(original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -88,7 +88,7 @@
 template< $TYPES >
 inline $INTEGER_TYPE $groupname( $LEVEL0 ) {
     $STATIC_ASSERTS
-    fortran_int_t info(0);
+    $LIBRARY_INT_TYPE info(0);
     LAPACK_$SUBROUTINE( $CALL_LAPACK_HEADER );
     return info;
 }
Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp	(original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp	2010-07-17 19:44:32 EDT (Sat, 17 Jul 2010)
@@ -3,7 +3,7 @@
     typedef boost::mpl::bool_<false> has_pivot;
 
     template< typename MatrixA, typename MatrixB, typename VectorP >
-    static void solve( MatrixA& A, MatrixB& B, VectorP const&, fortran_int_t& info ) {
+    static void solve( MatrixA& A, MatrixB& B, VectorP const&, $LIBRARY_INT_TYPE& info ) {
         invoke( $KEYWORDS );
     }
 $TEMPLATE[template_lapack_solve_pivot1]
@@ -11,13 +11,13 @@
     typedef boost::mpl::bool_<true> has_pivot;
 
     template< typename MatrixA, typename MatrixB, typename VectorP >
-    static void solve( MatrixA& A, MatrixB& B, VectorP& pivot, fortran_int_t& info ) {
+    static void solve( MatrixA& A, MatrixB& B, VectorP& pivot, $LIBRARY_INT_TYPE& info ) {
         invoke( $KEYWORDS );
     }
 
     template< typename MatrixA, typename MatrixB, typename VectorP >
-    static void solve( MatrixA& A, MatrixB& B, VectorP const&, fortran_int_t& info ) {
-        traits::detail::array< fortran_int_t > pivot( size_column(A) );
+    static void solve( MatrixA& A, MatrixB& B, VectorP const&, $LIBRARY_INT_TYPE& info ) {
+        traits::detail::array< $LIBRARY_INT_TYPE > pivot( size_column(A) );
         invoke( $KEYWORDS );
     }
 $TEMPLATE[end]