$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r59187 - sandbox/numeric_bindings/libs/numeric/bindings/tools
From: rutger_at_[hidden]
Date: 2010-01-21 03:15:57
Author: rutger
Date: 2010-01-21 03:15:56 EST (Thu, 21 Jan 2010)
New Revision: 59187
URL: http://svn.boost.org/trac/boost/changeset/59187
Log:
added column_major static assertions to LAPACK code generator
Text files modified: 
   sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py |    33 +++++++++++++++++++++++++++++++++       
   1 files changed, 33 insertions(+), 0 deletions(-)
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-01-21 03:15:56 EST (Thu, 21 Jan 2010)
@@ -240,6 +240,7 @@
       if 'matrix' in info_map[ subroutine ][ 'grouped_arguments' ][ 'by_type' ]:
         has_trans = False
         matrix_wo_trans = []
+        matrix_wo_trans_arg = []
         matrix_with_trans = []
         for matrix_arg in info_map[ subroutine ][ 'grouped_arguments' ][ 'by_type' ][ 'matrix' ]:
             if 'ref_trans' in info_map[ subroutine ][ 'argument_map' ][ matrix_arg ]:
@@ -248,6 +249,7 @@
                 matrix_with_trans += [ matrix_type ]
             else:
                 matrix_wo_trans.append( info_map[ subroutine ][ 'argument_map' ][ matrix_arg ][ 'code' ][ 'level_1_static_assert' ] )
+                matrix_wo_trans_arg.append( matrix_arg )
 
         #
         # Matrices have trans options in this case. If there is one without,
@@ -256,9 +258,14 @@
         if has_trans:
           includes += [ '#include <boost/numeric/bindings/trans_tag.hpp>' ]
           if len( matrix_wo_trans )>0:
+            # Take the first from the matrix_wo_trans list for the order argument
+            # remove this item from that list, so we have a correct list for static asserting
+            # on column major data order later on
             typedef_list.insert( 0, 'typedef typename result_of::data_order< ' + matrix_wo_trans[0] + \
                 ' >::type order;' )
             includes += [ '#include <boost/numeric/bindings/data_order.hpp>' ]
+            del matrix_wo_trans[0]
+            del matrix_wo_trans_arg[0]
           else:
             typedef_list.insert( 0, 'typedef typename detail::default_order< ' + matrix_with_trans[0] + \
                 ' >::type order;' )
@@ -270,6 +277,32 @@
               typedef_list.insert( 0, 'typedef typename result_of::data_order< ' + matrix_wo_trans[0] + \
                 ' >::type order;' )
               includes += [ '#include <boost/numeric/bindings/data_order.hpp>' ]
+              del matrix_wo_trans[0]
+              del matrix_wo_trans_arg[0]
+
+        # in LAPACK, every matrix that is not
+        # * transposeable
+        # * used for order determination (CLAPACK). In this case, the wrong order will
+        #   be caught in the detail/overload function (static assert on column_major order)
+        # and a matrix that has
+        # * a leading dimension trait
+        # should be column major, even in case of a row_major order used by CLAPACK
+        # See http://math-atlas.sourceforge.net/faq.html#RowSolve
+        # This effectively says every RHS matrix should be column major
+        if len( matrix_wo_trans_arg ) > 0:
+            for matrix_arg in matrix_wo_trans_arg:
+                # In some cases, level1 assert stuff isn't set due to a workspace array
+                # being passed as a matrix. Test for None in this case. Make sure the matrix has
+                # a leading dimension trait. 
+                # TODO reconsider if the leading dimension trait is needed
+                if 'ref_lda' in info_map[ subroutine ][ 'argument_map' ][ matrix_arg ] and \
+                        info_map[ subroutine ][ 'argument_map' ][ matrix_arg ][ 'code' ][ 'level_1_static_assert' ] != None:
+                    assert_line = 'BOOST_STATIC_ASSERT( (bindings::is_column_major< ' + \
+                        info_map[ subroutine ][ 'argument_map' ][ matrix_arg ][ 'code' ][ 'level_1_static_assert' ] + ' >::value) );'
+                    level1_static_assert_list += [ assert_line ]
+                    # this looks like we're adding lots of includes, but it will be cleaned up later,
+                    # and this makes sure we're only adding an include if the function is really used.
+                    includes += [ '#include <boost/numeric/bindings/is_column_major.hpp>' ]
 
       #
       # Add an include in case of the uplo or diag options