Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58513 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates/level2
From: rutger_at_[hidden]
Date: 2009-12-23 10:01:59


Author: rutger
Date: 2009-12-23 10:01:57 EST (Wed, 23 Dec 2009)
New Revision: 58513
URL: http://svn.boost.org/trac/boost/changeset/58513

Log:
sync of latest numeric_bindings generators

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 40 +++++++++++++++---
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 84 +++++++++++++++++++++++++++++++--------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpmv.hpp | 2
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpsv.hpp | 2
   4 files changed, 103 insertions(+), 25 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py 2009-12-23 10:01:57 EST (Wed, 23 Dec 2009)
@@ -92,7 +92,7 @@
             if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] != None:
                 typename_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_0_typename' ] ]
 
- if info_map[ subroutine ][ "has_cblas_order_arg" ]:
+ if "has_cblas_order_arg" in info_map[ subroutine ]:
             arg_list.insert( 0, "Order" )
             cblas_arg_list.insert( 0, "cblas_option< Order >::value" )
             typename_list.insert( 0, "typename Order" )
@@ -196,23 +196,45 @@
       if 'matrix' in info_map[ subroutine ][ 'grouped_arguments' ][ 'by_type' ]:
         has_trans = False
         matrix_wo_trans = []
+ 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 ]:
                 has_trans = True
+ matrix_type = info_map[ subroutine ][ 'argument_map' ][ matrix_arg ][ 'code' ][ 'level_1_static_assert' ]
+ matrix_with_trans += [ matrix_type ]
             else:
                 matrix_wo_trans.append( info_map[ subroutine ][ 'argument_map' ][ matrix_arg ][ 'code' ][ 'level_1_static_assert' ] )
 
- if has_trans:
- includes += [ '#include <boost/numeric/bindings/trans_tag.hpp>' ]
-
         #
         # Matrices have trans options in this case. If there is one without,
         # that one will determine the order of the call
         #
- if has_trans and len( matrix_wo_trans )>0:
- typedef_list += [ 'typedef typename data_order< ' + matrix_wo_trans[0] + \
- ' >::type order_type;' ]
+ if has_trans:
+ includes += [ '#include <boost/numeric/bindings/trans_tag.hpp>' ]
+ if len( matrix_wo_trans )>0:
+ typedef_list.insert( 0, 'typedef typename result_of::data_order< ' + matrix_wo_trans[0] + \
+ ' >::type order;' )
             includes += [ '#include <boost/numeric/bindings/data_order.hpp>' ]
+ else:
+ typedef_list.insert( 0, 'typedef typename detail::default_order< ' + matrix_with_trans[0] + \
+ ' >::type order;' )
+ includes += [ '#include <boost/numeric/bindings/blas/detail/default_order.hpp>' ]
+ else:
+ # so, there's no trans option
+ # but, what if there's an order? (e.g., syr) -- then use `
+ if "has_cblas_order_arg" in info_map[ subroutine ]:
+ typedef_list.insert( 0, 'typedef typename result_of::data_order< ' + matrix_wo_trans[0] + \
+ ' >::type order;' )
+ includes += [ '#include <boost/numeric/bindings/data_order.hpp>' ]
+
+
+ #
+ # Add an include in case of the uplo or diag options
+ #
+ if 'UPLO' in info_map[ subroutine ][ 'arguments' ]:
+ includes += [ '#include <boost/numeric/bindings/data_side.hpp>' ]
+ if 'DIAG' in info_map[ subroutine ][ 'arguments' ]:
+ includes += [ '#include <boost/numeric/bindings/diag_tag.hpp>' ]
 
       #
       # Create static assertions, first by value type
@@ -257,12 +279,14 @@
           level1_type_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_1_type' ] ]
         if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_1_assert' ] != None:
           level1_assert_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_1_assert' ] ]
+ if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'typedef' ] != None:
+ typedef_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'typedef' ] ]
         if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_2' ] != None:
           level2_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'level_2' ] ]
 
       # Insert the order_type() if appropriate
       if info_map[ subroutine ][ "has_cblas_order_arg" ]:
- level0_arg_list.insert( 0, "order_type()" )
+ level0_arg_list.insert( 0, "order()" )
 
       # Level 1 replacements
       level1_template = level1_template.replace( "$TYPEDEFS", "\n ".join( typedef_list ) )

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py 2009-12-23 10:01:57 EST (Wed, 23 Dec 2009)
@@ -96,27 +96,28 @@
     'TRANSA': 'TransA',
     'TRANSB': 'TransB',
     'TRANSR': 'TransR',
- 'UPLO' : 'UpLo'
+ 'UPLO' : 'UpLo',
+ 'DIAG' : 'Diag'
 }
 
 def level0_type( name, properties ):
     result = cpp_type( name, properties )
     if 'trait_type' in properties:
- if properties[ 'trait_type' ] in [ 'trans', 'uplo' ]:
+ if properties[ 'trait_type' ] in [ 'trans', 'uplo', 'diag' ]:
             result = level0_types[ name ]
     return result
 
 def level0_typename( name, properties ):
     result = None
     if 'trait_type' in properties:
- if properties[ 'trait_type' ] in [ 'trans', 'uplo' ]:
+ if properties[ 'trait_type' ] in [ 'trans', 'uplo', 'diag' ]:
             result = 'typename ' + level0_types[ name ]
     return result
 
 def call_blas_header( name, properties ):
     result = call_c_type( name, properties )
     if 'trait_type' in properties:
- if properties[ 'trait_type' ] in [ 'trans', 'uplo' ]:
+ if properties[ 'trait_type' ] in [ 'trans', 'uplo', 'diag' ]:
             result = '&blas_option< ' + level0_types[ name ] + ' >::value'
     return result
 
@@ -164,22 +165,28 @@
     #
     # number of columns is only valid if there's no option to transposing
     #
- if properties[ 'trait_type' ] == 'num_columns' and \
- 'ref_trans' not in arg_map[ properties[ 'trait_of' ][ 0 ] ]:
- result = "size_column(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
+ if properties[ 'trait_type' ] == 'num_columns':
+ if 'ref_trans' not in arg_map[ properties[ 'trait_of' ][ 0 ] ]:
+ result = "size_column(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
+ else:
+ result = "size_column_op(" + properties[ 'trait_of' ][ 0 ].lower() + \
+ ", " + arg_map[ properties[ 'trait_of' ][ 0 ] ][ 'ref_trans' ].lower() + "())"
 
     #
     # number of rows is only valid if there's no option to transposing
     #
- if properties[ 'trait_type' ] == 'num_rows' and \
- 'ref_trans' not in arg_map[ properties[ 'trait_of' ][ 0 ] ]:
- result = "size_row(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
+ if properties[ 'trait_type' ] == 'num_rows':
+ if 'ref_trans' not in arg_map[ properties[ 'trait_of' ][ 0 ] ]:
+ result = "size_row(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
+ else:
+ result = "size_row_op(" + properties[ 'trait_of' ][ 0 ].lower() + \
+ ", " + arg_map[ properties[ 'trait_of' ][ 0 ] ][ 'ref_trans' ].lower() + "())"
 
     #
     #
     #
     if properties[ 'trait_type' ] == 'trans_num_columns':
- result = "size_major(" + properties[ 'trait_of' ][1].lower() + ")"
+ result = "size_column(" + properties[ 'trait_of' ][1].lower() + ")"
       #result = "(" + properties[ 'trait_of' ][ 0 ][0].lower() + "=='N' ? " + \
                #"num_columns(" + properties[ 'trait_of' ][ 0 ][1].lower() + ") : " + \
                #"num_rows(" + properties[ 'trait_of' ][ 0 ][1].lower() + "))"
@@ -190,13 +197,14 @@
         my_name = 'work.select(' + workspace_type( properties[ 'trait_of' ][ 0 ].lower(), referring_to_properties ) + \
                   '())'
       result = "size(" + my_name + ")"
- if properties[ 'trait_type' ] == 'uplo':
- result = "traits::matrix_uplo_tag(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
+ #result = "data_side(" + properties[ 'trait_of' ][ 0 ].lower() + ")"
     if properties[ 'trait_type' ] == 'stride':
       result = "stride(" + properties[ 'trait_of' ][ 0 ][0].lower() + ")"
 
- if properties[ 'trait_type' ] == 'trans':
- result = "trans_tag( " + properties[ 'trait_of' ][ 0 ].lower() + ", order_type() )"
+ if properties[ 'trait_type' ] in [ 'trans', 'uplo', 'diag' ]:
+ result = name.lower() + "()"
+
+ #result = "trans_tag( " + properties[ 'trait_of' ][ 0 ].lower() + ", order_type() )"
 
   else:
     result = name.lower()
@@ -380,7 +388,8 @@
 def level1_assert( name, properties, arg_map ):
   result = None
   
- if properties.has_key( 'assert_char' ) and name not in [ 'TRANS', 'TRANSA', 'TRANSB', 'TRANSR' ]:
+ if properties.has_key( 'assert_char' ) and \
+ name not in [ 'TRANS', 'TRANSA', 'TRANSB', 'TRANSR', 'UPLO', 'DIAG' ]:
     result = "BOOST_ASSERT( "
     result_array = []
     for char in properties[ 'assert_char' ]:
@@ -421,6 +430,29 @@
   return result
 
 
+def typedef_type( name, properties, arg_map ):
+ result = None
+ if 'trait_type' in properties:
+ if properties[ 'trait_type' ] == 'trans':
+ matrix_type = level1_typename( properties[ 'trait_of' ][ 0 ],
+ arg_map[ properties[ 'trait_of' ][ 0 ] ] ).replace( "typename ", "" )
+ result = 'typedef typename result_of::trans_tag< ' + \
+ matrix_type + ', order >::type ' + name.lower() + ';'
+ if properties[ 'trait_type' ] == 'uplo':
+ matrix_type = level1_typename( properties[ 'trait_of' ][ 0 ],
+ arg_map[ properties[ 'trait_of' ][ 0 ] ] ).replace( "typename ", "" )
+ result = 'typedef typename result_of::data_side< ' + \
+ matrix_type + ' >::type ' + name.lower() + ';'
+ if properties[ 'trait_type' ] == 'diag':
+ matrix_type = level1_typename( properties[ 'trait_of' ][ 0 ],
+ arg_map[ properties[ 'trait_of' ][ 0 ] ] ).replace( "typename ", "" )
+ result = 'typedef typename result_of::diag_tag< ' + \
+ matrix_type + ' >::type ' + name.lower() + ';'
+
+
+ return result
+
+
 def workspace_type( name, properties ):
   result = None
   if 'workspace' in properties[ 'io' ]:
@@ -1225,6 +1257,17 @@
         # this doesn't look that correct
         argument_properties[ 'trait_of' ] = [ 'A' ]
 
+ # Diag character detection
+ if argument_name[0:4] == 'DIAG':
+ argument_properties[ 'trait_type' ] = 'diag'
+ match_diag = re.compile( ' ([A-Z]+)(\s|is|)+unit\s+triangular', re.M ).findall( comment_block )
+ if len( match_diag ) > 0:
+ ref_arg = match_diag[ 0 ][ 0 ]
+ if ref_arg in argument_map:
+ argument_properties[ 'trait_of' ] = [ ref_arg ]
+ if ref_arg + 'P' in argument_map:
+ argument_properties[ 'trait_of' ] = [ ref_arg + 'P' ]
+
       # check for existance of trait_of definition in template file(s)
       traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + argument_name + '.trait_of'
       if my_has_key( traits_key, template_map ):
@@ -1274,7 +1317,7 @@
           print "Using user-defined assert_size_args: ", tmp_result
 
       #
- # Try to detect packed strorage stuff. Typically these are vectors in Fortran, but
+ # Try to detect packed storage stuff. Typically these are vectors in Fortran, but
       # matrices in our bindings. E.g. as used in spsv.
       #
       packed_keywords = re.compile( '(/s|packed|matrix)+', re.M ).findall( comment_block )
@@ -1285,6 +1328,12 @@
         argument_properties[ 'type' ] = 'matrix'
         argument_properties[ 'packed' ] = True
 
+ # Update the grouped arguments stuff
+ grouped_arguments[ 'by_type' ][ 'vector' ].remove( argument_name )
+ if 'matrix' not in grouped_arguments[ 'by_type' ]:
+ grouped_arguments[ 'by_type' ][ 'matrix' ] = []
+ grouped_arguments[ 'by_type' ][ 'matrix' ].append( argument_name )
+
     #
     # Matrix related detection code
     #
@@ -1357,6 +1406,7 @@
     argument_properties[ 'code' ][ 'min_workspace_args' ] = min_workspace_arg_type( argument_name, argument_properties, argument_map )
     argument_properties[ 'code' ][ 'min_workspace_call' ] = min_workspace_call_type( argument_name, argument_properties, argument_map )
     argument_properties[ 'code' ][ 'user_defined_init' ] = user_defined_type( argument_name, argument_properties, argument_map )
+ argument_properties[ 'code' ][ 'typedef' ] = typedef_type( argument_name, argument_properties, argument_map )
 
   print "Argument map: "
   pp.pprint( argument_map )

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpmv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpmv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpmv.hpp 2009-12-23 10:01:57 EST (Wed, 23 Dec 2009)
@@ -2,6 +2,8 @@
 AP
 $TEMPLATE[tpmv.all.UPLO.trait_of]
 AP
+$TEMPLATE[tpmv.all.TRANS.trait_of]
+AP
 $TEMPLATE[tpmv.all.cblas_alias]
 TRANS,TRANSA
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level2/tpsv.hpp 2009-12-23 10:01:57 EST (Wed, 23 Dec 2009)
@@ -2,6 +2,8 @@
 AP
 $TEMPLATE[tpsv.all.UPLO.trait_of]
 AP
+$TEMPLATE[tpsv.all.TRANS.trait_of]
+AP
 $TEMPLATE[tpsv.all.cblas_alias]
 TRANS,TRANSA
 $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