Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51870 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates templates/driver
From: rutger_at_[hidden]
Date: 2009-03-20 12:43:40


Author: rutger
Date: 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
New Revision: 51870
URL: http://svn.boost.org/trac/boost/changeset/51870

Log:
Added latest generator updates for work on lapack::solve

Added:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesv.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gtsv.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/posv.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ptsv.hpp (contents, props changed)
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp (contents, props changed)
Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py | 25 ++++++++++++++++++-------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 18 +++++++++++-------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp | 4 ++--
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gbsv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hesv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hpsv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/pbsv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ppsv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/spsv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/sysv.hpp | 2 ++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp | 24 ++++++++++++------------
   11 files changed, 57 insertions(+), 28 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 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -62,10 +62,6 @@
       '#include <boost/type_traits/is_same.hpp>',
       '#include <boost/static_assert.hpp>' ]
 
- # add support for the mpl keyword vector
- includes += [ '#include <boost/mpl/vector.hpp>',
- '#include <boost/numeric/bindings/lapack/keywords.hpp>' ]
-
     if template_map.has_key( group_name.lower() + '.includes' ):
       includes += template_map[ group_name.lower() + '.includes' ].splitlines()
 
@@ -109,7 +105,7 @@
     level1_map = {}
     level2_map = {}
     for value_type, case_map in cases.iteritems():
-
+
       level1_template = ''
       level2_template = ''
       if info_map[ subroutine ][ 'grouped_arguments' ][ 'by_io' ].has_key( 'workspace' ):
@@ -118,10 +114,25 @@
       else:
         level1_template = template_map[ 'level1_noworkspace' ]
         level2_template = template_map[ 'level2_noworkspace' ]
-
+
+ # include templates come before anything else; they can hold any
+ # $ID
+ my_include_key = group_name.lower() + '.' + value_type + '.include_templates'
+ if netlib.my_has_key( my_include_key, template_map ):
+ include_template_list = template_map[ netlib.my_has_key( my_include_key, template_map ) ].strip().replace(' ','').split(",")
+ include_templates = ''
+ for template in include_template_list:
+ include_templates += template_map[ 'template_' + template ]
+ level1_template = level1_template.replace( '$INCLUDE_TEMPLATES', bindings.proper_indent(include_templates) )
+ level2_template = level2_template.replace( '$INCLUDE_TEMPLATES', bindings.proper_indent(include_templates) )
+ else:
+ level1_template = level1_template.replace( '\n $INCLUDE_TEMPLATES', '' )
+ level2_template = level2_template.replace( '\n $INCLUDE_TEMPLATES', '' )
+
+ # continue with first replacements
       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

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-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -170,25 +170,29 @@
 
 def keyword_typename( name, properties ):
   result = None
- namespace = 'keywords::tag::'
+ prefix = ''
 
   if 'workspace' not in properties[ 'io' ]:
     if properties[ 'type' ] == 'matrix':
       if name == 'A' or name == 'B':
- result = namespace + name
+ result = prefix + name
       if properties.has_key( 'packed' ):
         if name == 'AP':
- result = namespace + 'A'
+ result = prefix + 'A'
         if name == 'BP':
- result = namespace + 'B'
+ result = prefix + 'B'
       if properties.has_key( 'banded' ):
         if name == 'AB':
- result = namespace + 'A'
+ result = prefix + 'A'
         if name == 'BB':
- result = namespace + 'B'
+ result = prefix + 'B'
     if properties[ 'type' ] == 'vector':
       if name == 'IPIV':
- result = namespace + 'pivot'
+ result = prefix + 'pivot'
+ if properties[ 'type' ] == 'scalar':
+ if name == 'INFO':
+ result = prefix + 'info'
+
   return result
 
 

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -47,7 +47,7 @@
 
     // templated specialization
     template< $TYPES >
- static return_type compute( $LEVEL1 ) {
+ static return_type invoke( $LEVEL1 ) {
         $STATIC_ASSERTS
         $RETURN_STATEMENTdetail::$groupname( $CALL_LEVEL0 );
     }
@@ -58,6 +58,6 @@
 inline typename $groupname_impl< typename traits::$TYPEOF_FIRST_TYPENAME_traits< $FIRST_TYPENAME >::value_type >::return_type
 $groupname( $LEVEL2 ) {
     typedef typename traits::$TYPEOF_FIRST_TYPENAME_traits< $FIRST_TYPENAME >::value_type value_type;
- $RETURN_STATEMENT$groupname_impl< value_type >::compute( $CALL_LEVEL1 );
+ $RETURN_STATEMENT$groupname_impl< value_type >::invoke( $CALL_LEVEL1 );
 }
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gbsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gbsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gbsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -1,3 +1,5 @@
 $TEMPLATE[gbsv.all.N.trait_of]
 AB
+$TEMPLATE[gbsv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesv.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gesv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -0,0 +1,3 @@
+$TEMPLATE[gesv.all.include_templates]
+lapack_solve
+$TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gtsv.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/gtsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -0,0 +1,3 @@
+$TEMPLATE[gtsv.all.include_templates]
+lapack_solve
+$TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hesv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hesv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hesv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -1,4 +1,6 @@
 $TEMPLATE[hesv.complex.min_size_work.args]
 $TEMPLATE[hesv.complex.min_size_work]
 return 1;
+$TEMPLATE[hesv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hpsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hpsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/hpsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -2,4 +2,6 @@
 AP
 $TEMPLATE[hpsv.all.UPLO.trait_of]
 AP
+$TEMPLATE[hpsv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/pbsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/pbsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/pbsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -2,4 +2,6 @@
 AB
 $TEMPLATE[pbsv.all.UPLO.trait_of]
 AB
+$TEMPLATE[pbsv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/posv.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/posv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -0,0 +1,3 @@
+$TEMPLATE[posv.all.include_templates]
+lapack_solve
+$TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ppsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ppsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ppsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -2,4 +2,6 @@
 AP
 $TEMPLATE[ppsv.all.UPLO.trait_of]
 AP
+$TEMPLATE[ppsv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ptsv.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/ptsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -0,0 +1,3 @@
+$TEMPLATE[ptsv.all.include_templates]
+lapack_solve
+$TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/spsv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/spsv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/spsv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -2,4 +2,6 @@
 AP
 $TEMPLATE[spsv.all.UPLO.trait_of]
 AP
+$TEMPLATE[spsv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/sysv.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/sysv.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/driver/sysv.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -1,4 +1,6 @@
 $TEMPLATE[sysv.all.min_size_work.args]
 $TEMPLATE[sysv.all.min_size_work]
 return 1;
+$TEMPLATE[sysv.all.include_templates]
+lapack_solve
 $TEMPLATE[end]

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 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -55,11 +55,11 @@
 $TEMPLATE[level1_workspace]
     typedef ValueType value_type;
     typedef typename traits::type_traits<ValueType>::real_type real_type;
- typedef typename mpl::vector< $KEYWORDS > valid_keywords;
 
+$INCLUDE_TEMPLATES
     // user-defined workspace specialization
     template< $TYPES, $WORKSPACE_TYPENAMES >
- static void compute( $LEVEL1, detail::workspace$WORKSPACE_SIZE< $WORKSPACE_TYPES > work ) {
+ static void invoke( $LEVEL1, detail::workspace$WORKSPACE_SIZE< $WORKSPACE_TYPES > work ) {
         $STATIC_ASSERTS
         $INIT_USER_DEFINED_VARIABLES
         $ASSERTS
@@ -68,15 +68,15 @@
 
     // minimal workspace specialization
     template< $TYPES >
- static void compute( $LEVEL1, minimal_workspace work ) {
+ static void invoke( $LEVEL1, minimal_workspace work ) {
         $INIT_USER_DEFINED_VARIABLES
 $SETUP_MIN_WORKARRAYS_POST
- compute( $CALL_LEVEL1, workspace( $TMP_WORKARRAYS ) );
+ invoke( $CALL_LEVEL1, workspace( $TMP_WORKARRAYS ) );
     }
 
     // optimal workspace specialization
     template< $TYPES >
- static void compute( $LEVEL1, optimal_workspace work ) {
+ static void invoke( $LEVEL1, optimal_workspace work ) {
 $OPT_WORKSPACE_FUNC
     }
 
@@ -88,16 +88,16 @@
         $SETUP_OPT_WORKARRAYS_PRE
         detail::$groupname( $WORKSPACE_QUERY );
         $SETUP_OPT_WORKARRAYS_POST
- compute( $CALL_LEVEL1, workspace( $TMP_WORKARRAYS ) );
+ invoke( $CALL_LEVEL1, workspace( $TMP_WORKARRAYS ) );
 $TEMPLATE[level1_opt_workspace_is_min]
- compute( $CALL_LEVEL1, minimal_workspace() );
+ invoke( $CALL_LEVEL1, minimal_workspace() );
 $TEMPLATE[level2_workspace]
 // template function to call $groupname
 template< $TYPES, typename Workspace >
 inline integer_t $groupname( $LEVEL2, Workspace work ) {
     typedef typename traits::$TYPEOF_FIRST_TYPENAME_traits< $FIRST_TYPENAME >::value_type value_type;
     integer_t info(0);
- $groupname_impl< value_type >::compute( $CALL_LEVEL1, work );
+ $groupname_impl< value_type >::invoke( $CALL_LEVEL1, work );
     return info;
 }
 
@@ -106,7 +106,7 @@
 inline integer_t $groupname( $LEVEL2 ) {
     typedef typename traits::$TYPEOF_FIRST_TYPENAME_traits< $FIRST_TYPENAME >::value_type value_type;
     integer_t info(0);
- $groupname_impl< value_type >::compute( $CALL_LEVEL1, optimal_workspace() );
+ $groupname_impl< value_type >::invoke( $CALL_LEVEL1, optimal_workspace() );
     return info;
 }
 $TEMPLATE[setup_min_workspace]
@@ -121,11 +121,11 @@
 $TEMPLATE[level1_noworkspace]
     typedef ValueType value_type;
     typedef typename traits::type_traits<ValueType>::real_type real_type;
- typedef typename mpl::vector< $KEYWORDS > valid_keywords;
 
+$INCLUDE_TEMPLATES
     // templated specialization
     template< $TYPES >
- static void compute( $LEVEL1 ) {
+ static void invoke( $LEVEL1 ) {
         $STATIC_ASSERTS
         $ASSERTS
         detail::$groupname( $CALL_LEVEL0 );
@@ -138,7 +138,7 @@
 inline integer_t $groupname( $LEVEL2 ) {
     typedef typename traits::$TYPEOF_FIRST_TYPENAME_traits< $FIRST_TYPENAME >::value_type value_type;
     integer_t info(0);
- $groupname_impl< value_type >::compute( $CALL_LEVEL1 );
+ $groupname_impl< value_type >::invoke( $CALL_LEVEL1 );
     return info;
 }
 $TEMPLATE[end]

Added: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack_solve.hpp 2009-03-20 12:43:37 EDT (Fri, 20 Mar 2009)
@@ -0,0 +1,7 @@
+$TEMPLATE[template_lapack_solve]
+ // uniform high-level dispatching-function
+ template< typename MatrixA, typename MatrixB, typename VectorP >
+ static void solve( MatrixA& A, MatrixB& B, VectorP& pivot, integer_t& info ) {
+ invoke( $KEYWORDS );
+ }
+$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