|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51818 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates
From: rutger_at_[hidden]
Date: 2009-03-17 12:47:35
Author: rutger
Date: 2009-03-17 12:47:34 EDT (Tue, 17 Mar 2009)
New Revision: 51818
URL: http://svn.boost.org/trac/boost/changeset/51818
Log:
Added initial support for keyword detection in lapack bindings
Text files modified:
sandbox/numeric_bindings/libs/numeric/bindings/tools/lapack_generator.py | 16 +++++++++++++---
sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 21 ++++++++++++++++++++-
sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/blas.hpp | 1 +
sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp | 6 ++++--
sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_lapack.hpp | 10 +++++-----
5 files changed, 43 insertions(+), 11 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-17 12:47:34 EDT (Tue, 17 Mar 2009)
@@ -58,10 +58,14 @@
includes = [ '#include <boost/assert.hpp>',
'#include <boost/numeric/bindings/traits/traits.hpp>',
'#include <boost/numeric/bindings/traits/type_traits.hpp>',
- '#include <boost/numeric/bindings/lapack/lapack.h>',
+ '#include <boost/numeric/bindings/lapack/detail/lapack.h>',
'#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()
@@ -132,6 +136,7 @@
workspace_query_arg_list = []
user_defined_arg_list = []
user_defined_opt_arg_list = []
+ keyword_type_list = []
#
# Create static assertions, first by value type
@@ -168,6 +173,8 @@
call_level1_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'call_level_1' ] ]
if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'opt_workspace_query' ] != None:
workspace_query_arg_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'opt_workspace_query' ] ]
+ if info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'keyword_type' ] != None:
+ keyword_type_list += [ info_map[ subroutine ][ 'argument_map' ][ arg ][ 'code' ][ 'keyword_type' ] ]
if info_map[ subroutine ][ 'user_defined_variables' ] != None:
for arg in info_map[ subroutine ][ 'user_defined_variables' ]:
@@ -187,6 +194,7 @@
level1_template = level1_template.replace( "$LEVEL1", ", ".join( level1_arg_list ) )
level1_template = level1_template.replace( "$TYPES", ", ".join( level1_type_arg_list ) )
level1_template = level1_template.replace( "$ASSERTS", "\n ".join( level1_assert_list ) )
+ level1_template = level1_template.replace( "$KEYWORDS", ", ".join( keyword_type_list ) )
if len( level1_static_assert_list ) > 0:
level1_template = level1_template.replace( "$STATIC_ASSERTS", "\n ".join( level1_static_assert_list ) )
@@ -360,6 +368,8 @@
result = result.replace( '$LEVEL2', level2 )
result = result.replace( '$GROUPNAME', group_name )
result = result.replace( '$groupname', group_name.lower() )
+ result = result.replace( '$DIRNAME', base_dir.split("/")[-1].upper() )
+ result = result.replace( '$dirname', base_dir.split("/")[-1].lower() )
# replace the global variables as last (this is convenient)
#result = result.replace( '$INDENT', ' ' )
@@ -514,8 +524,8 @@
print routines
-bindings.write_names_header( function_info_map, routines, templates, bindings_target_path + 'lapack_names.h' )
-bindings.write_header( function_info_map, routines, templates, bindings_target_path + 'lapack.h' )
+bindings.write_names_header( function_info_map, routines, templates, bindings_target_path + 'detail/lapack_names.h' )
+bindings.write_header( function_info_map, routines, templates, bindings_target_path + 'detail/lapack.h' )
for level, level_properties in routines.iteritems():
target_path = bindings_target_path + level
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-17 12:47:34 EDT (Tue, 17 Mar 2009)
@@ -168,6 +168,23 @@
result = "typename Vector" + name
return result
+def keyword_typename( name, properties ):
+ result = None
+ namespace = 'keywords::tag::'
+
+ if 'workspace' not in properties[ 'io' ]:
+ if properties[ 'type' ] == 'matrix':
+ if name == 'A' or name == 'B':
+ result = namespace + name
+ if properties.has_key( 'packed' ):
+ if name == 'AP':
+ result = namespace + 'A'
+ if properties[ 'type' ] == 'vector':
+ if name == 'IPIV':
+ result = namespace + 'pivot'
+
+ return result
+
def level1_static_assert( name, properties ):
result = None
@@ -1094,6 +1111,7 @@
# Overrule my type :-)
#
argument_properties[ 'type' ] = 'matrix'
+ argument_properties[ 'packed' ] = True
#
# Add user-defined arguments to the argument_map
@@ -1132,7 +1150,8 @@
argument_properties[ 'code' ][ 'call_level_1' ] = call_level1_type( argument_name, argument_properties )
argument_properties[ 'code' ][ 'level_2' ] = level2_type( argument_name, argument_properties )
argument_properties[ 'code' ][ 'workspace_type' ] = workspace_type( argument_name, argument_properties )
-
+ argument_properties[ 'code' ][ 'keyword_type' ] = keyword_typename( argument_name, argument_properties )
+
# Pass 2
# A second pass is needed, because the asserts may cross-reference other
# variables which have been assigned their code in pass 1.
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-17 12:47:34 EDT (Tue, 17 Mar 2009)
@@ -42,6 +42,7 @@
struct $groupname_impl {
typedef ValueType value_type;
+ typedef typename traits::type_traits<ValueType>::real_type real_type;
typedef $RETURN_TYPE return_type;
// templated specialization
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-17 12:47:34 EDT (Tue, 17 Mar 2009)
@@ -12,8 +12,8 @@
// PLEASE DO NOT EDIT!
//
-#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_$GROUPNAME_HPP
-#define BOOST_NUMERIC_BINDINGS_LAPACK_$GROUPNAME_HPP
+#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_$DIRNAME_$GROUPNAME_HPP
+#define BOOST_NUMERIC_BINDINGS_LAPACK_$DIRNAME_$GROUPNAME_HPP
$INCLUDES
@@ -55,6 +55,7 @@
$TEMPLATE[level1_workspace]
typedef ValueType value_type;
typedef typename traits::type_traits<ValueType>::real_type real_type;
+ typedef typename mpl::vector< $KEYWORDS > valid_keywords;
// user-defined workspace specialization
template< $TYPES, $WORKSPACE_TYPENAMES >
@@ -111,6 +112,7 @@
$TEMPLATE[level1_noworkspace]
typedef ValueType value_type;
typedef typename traits::type_traits<ValueType>::real_type real_type;
+ typedef typename mpl::vector< $KEYWORDS > valid_keywords;
// templated specialization
template< $TYPES >
Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_lapack.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_lapack.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/singleton_lapack.hpp 2009-03-17 12:47:34 EDT (Tue, 17 Mar 2009)
@@ -12,11 +12,11 @@
// PLEASE DO NOT EDIT!
//
-#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_LAPACK_H
-#define BOOST_NUMERIC_BINDINGS_LAPACK_LAPACK_H
+#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_DETAIL_LAPACK_H
+#define BOOST_NUMERIC_BINDINGS_LAPACK_DETAIL_LAPACK_H
#include <boost/numeric/bindings/traits/type.h>
-#include <boost/numeric/bindings/lapack/lapack_names.h>
+#include <boost/numeric/bindings/lapack/detail/lapack_names.h>
#ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
# define BOOST_NUMERIC_BINDINGS_FORTRAN
@@ -51,8 +51,8 @@
// PLEASE DO NOT EDIT!
//
-#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_LAPACK_NAMES_H
-#define BOOST_NUMERIC_BINDINGS_LAPACK_LAPACK_NAMES_H
+#ifndef BOOST_NUMERIC_BINDINGS_LAPACK_DETAIL_LAPACK_NAMES_H
+#define BOOST_NUMERIC_BINDINGS_LAPACK_DETAIL_LAPACK_NAMES_H
#ifndef BOOST_NUMERIC_BINDINGS_USE_CLAPACK
# include <boost/numeric/bindings/traits/fortran.h>
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