Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58962 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates/computational
From: rutger_at_[hidden]
Date: 2010-01-13 05:05:47


Author: rutger
Date: 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
New Revision: 58962
URL: http://svn.boost.org/trac/boost/changeset/58962

Log:
Improved trait_of detection and assignments (update of generator and a number of templates)

Added:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/gbtrs.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetri.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetrs.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytri.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytrs.hpp (contents, props changed)
Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 93 ++++++++++++++++++++-------------------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/org.hpp | 6 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/orm.hpp | 2
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/un.hpp | 8 +++
   4 files changed, 64 insertions(+), 45 deletions(-)

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 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -1165,7 +1165,8 @@
       #
       # First: perhaps there's something in the templating system
       #
- traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + argument_name + '.trait'
+ traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + \
+ argument_name + '.trait'
       if my_has_key( traits_key, template_map ):
         data = template_map[ my_has_key( traits_key, template_map ) ].split(",")
         argument_properties[ 'trait_type' ] = data[0].strip()
@@ -1185,58 +1186,60 @@
             '([A-Z]+\s+and\s+[A-Z]+|[A-Z]+)', re.M | re.S ).findall( comment_block )
         match_banded_uplo = re.compile( '(number|of|sub|super|\s)+diagonals(if|\s)+UPLO', re.M | re.S ).findall( comment_block )
         if len( match_matrix_traits ) == 1:
- print "Matched trait:", match_matrix_traits
- if match_matrix_traits[0][0] == 'order':
- #
- # see if the traits are overruled through the template system
- # logically, these come first
- traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + '.' + argument_name + '.trait_of'
- if my_has_key( traits_key, template_map ):
- argument_properties[ 'trait_type' ] = 'num_columns'
- argument_properties[ 'trait_of' ] = [ template_map[ my_has_key( traits_key, template_map ) ].strip() ]
+ print "Matched trait:", match_matrix_traits
+
             # PANIC: return none
             # e.g., in tridiagonal case, there is no matrix, but a number of
             # vectors (the diagonals)
- elif not grouped_arguments[ 'by_type' ].has_key( 'matrix' ):
- print "PANIC: returning none"
- # TODO
- # TODO
- return subroutine_name, None
- # TODO
- # TODO
- else:
- #
- # Try to look for different matrices, e.g., if the code
- # refers to Matrix A, then look for argument A, AB, and AP.
- # Allocate the trait to the first matrix found (usually this is A).
- #
- references = match_matrix_traits[0][3].split( 'and' )
- for matrix_name in references:
+ if not grouped_arguments[ 'by_type' ].has_key( 'matrix' ):
+ print "PANIC: returning none"
+ # TODO
+ # TODO
+ return subroutine_name, None
+ # TODO
+ # TODO
+
+ #
+ # Apparently there are matrices found, let's try to allocate this
+ # trait to one of these matrices
+ #
+ # trait_name can be num_columns, num_rows, num_super, num_sub,
+ # num_super_uplo, num_sub_uplo
+ trait_name = 'num_' + match_matrix_traits[0][0]
+ if match_matrix_traits[0][0] == 'order':
+ trait_name = 'num_columns'
+ if len( match_banded_uplo ) > 0:
+ trait_name += '_uplo'
+
+ #
+ # Try to look for different matrices, e.g., if the code
+ # refers to Matrix A, then look for argument A, AB, and AP.
+ # Allocate the trait to the first matrix found (usually this is A).
+ #
+ references = match_matrix_traits[0][3].split( 'and' )
+ for matrix_name in references:
                 try_names = [ matrix_name.strip(),
                               matrix_name.strip() + 'B',
                               matrix_name.strip() + 'P' ]
                 for try_name in try_names:
- if try_name in grouped_arguments[ 'by_type' ][ 'matrix' ] and \
- 'trait_of' not in argument_properties:
- argument_properties[ 'trait_type' ] = 'num_columns'
- argument_properties[ 'trait_of' ] = [ try_name.strip() ]
+ print "Looking for matrix named", try_name
+ if try_name in grouped_arguments[ 'by_type' ][ 'matrix' ] and \
+ 'trait_of' not in argument_properties:
+ print "Assigning trait to matrix", try_name.strip()
+ argument_properties[ 'trait_type' ] = trait_name
+ argument_properties[ 'trait_of' ] = [ try_name.strip() ]
+
+ #
+ # see if the traits are overruled through the template system
+ # these overwrite whatever has been found
+ #
+ traits_key = subroutine_group_name.lower() + '.' + subroutine_value_type + \
+ '.' + argument_name + '.trait_of'
+ if my_has_key( traits_key, template_map ):
+ argument_properties[ 'trait_type' ] = trait_name
+ argument_properties[ 'trait_of' ] = [ template_map[ my_has_key( traits_key, template_map ) ].strip() ]
+
 
- # if we're not dealing with order
- else:
- references = match_matrix_traits[0][3].split( 'and' )
- for matrix_name in references:
- try_names = [ matrix_name.strip(),
- matrix_name.strip() + 'B',
- matrix_name.strip() + 'P' ]
- for try_name in try_names:
- if try_name in grouped_arguments[ 'by_type' ][ 'matrix' ] and \
- 'trait_of' not in argument_properties:
- if len( match_banded_uplo ) == 0:
- argument_properties[ 'trait_type' ] = 'num_' + match_matrix_traits[0][0]
- else:
- argument_properties[ 'trait_type' ] = 'num_' + match_matrix_traits[0][0] + '_uplo'
- # only store the first matrix found (usually A)
- argument_properties[ 'trait_of' ] = [ try_name.strip() ]
 
         #
         # Matrix traits detection, continued

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/gbtrs.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/gbtrs.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,3 @@
+$TEMPLATE[gbtrs.all.TRANS.trait_of]
+AB
+$TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetri.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetri.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,3 @@
+$TEMPLATE[hetri.all.UPLO.trait_of]
+A
+$TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetrs.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/hetrs.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,3 @@
+$TEMPLATE[hetrs.all.UPLO.trait_of]
+A
+$TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/org.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/org.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/org.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -14,6 +14,12 @@
 N
 $TEMPLATE[orgql.all.min_size_work]
 return std::max< $INTEGER_TYPE >( 1, n );
+$TEMPLATE[orgqr.all.M.trait_of]
+A
+$TEMPLATE[orgqr.all.N.trait_of]
+A
+$TEMPLATE[orgqr.all.K.trait]
+size,TAU
 $TEMPLATE[orgqr.all.min_size_work.args]
 N
 $TEMPLATE[orgqr.all.min_size_work]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/orm.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/orm.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/orm.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -12,6 +12,8 @@
     return std::max< $INTEGER_TYPE >( 1, n );
 else
     return std::max< $INTEGER_TYPE >( 1, m );
+$TEMPLATE[ormqr.all.K.trait]
+size,TAU
 $TEMPLATE[ormqr.all.min_size_work.args]
 SIDE,M,N
 $TEMPLATE[ormqr.all.min_size_work]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytri.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytri.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,3 @@
+$TEMPLATE[sytri.all.UPLO.trait_of]
+A
+$TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytrs.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/sytrs.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,3 @@
+$TEMPLATE[sytrs.all.UPLO.trait_of]
+A
+$TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/un.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/un.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/computational/un.hpp 2010-01-13 05:05:46 EST (Wed, 13 Jan 2010)
@@ -6,6 +6,12 @@
 N
 $TEMPLATE[ungql.all.min_size_work]
 return std::max< $INTEGER_TYPE >( 1, n );
+$TEMPLATE[ungqr.all.M.trait_of]
+A
+$TEMPLATE[ungqr.all.N.trait_of]
+A
+$TEMPLATE[ungqr.all.K.trait]
+size,TAU
 $TEMPLATE[ungqr.all.min_size_work.args]
 N
 $TEMPLATE[ungqr.all.min_size_work]
@@ -46,6 +52,8 @@
     return std::max< $INTEGER_TYPE >( 1, n );
 else
     return std::max< $INTEGER_TYPE >( 1, m );
+$TEMPLATE[unmqr.all.K.trait]
+size,TAU
 $TEMPLATE[unmqr.all.min_size_work.args]
 SIDE,M,N
 $TEMPLATE[unmqr.all.min_size_work]


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