Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58709 - in sandbox/numeric_bindings/boost/numeric/bindings: . detail detail/config std ublas
From: rutger_at_[hidden]
Date: 2010-01-05 11:59:55


Author: rutger
Date: 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
New Revision: 58709
URL: http://svn.boost.org/trac/boost/changeset/58709

Log:
Added ublas matrix_reference, bug fixes, tags for banded matrices, banded adaptor for ublas, reintroduced a fortran_int_t (defined in detail/config/fortran.hpp)

Added:
   sandbox/numeric_bindings/boost/numeric/bindings/detail/config/
   sandbox/numeric_bindings/boost/numeric/bindings/detail/config/fortran.hpp
      - copied, changed from r58691, /sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp (contents, props changed)
Removed:
   sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h
Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/detail/config/fortran.hpp | 10 ++++++++--
   sandbox/numeric_bindings/boost/numeric/bindings/detail/get.hpp | 9 +++++++++
   sandbox/numeric_bindings/boost/numeric/bindings/size.hpp | 4 ++--
   sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp | 3 ++-
   sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp | 3 +++
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/hermitian.hpp | 24 ++++++++++++++++--------
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp | 1 +
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp | 29 +++++++++++++++++++----------
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp | 9 +++++----
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp | 2 ++
   10 files changed, 67 insertions(+), 27 deletions(-)

Copied: sandbox/numeric_bindings/boost/numeric/bindings/detail/config/fortran.hpp (from r58691, /sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h)
==============================================================================
--- /sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/config/fortran.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -6,8 +6,8 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 
-#ifndef BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H
-#define BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H
+#ifndef BOOST_NUMERIC_BINDINGS_DETAIL_CONFIG_FORTRAN_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_CONFIG_FORTRAN_HPP
 
 #if defined(BIND_FORTRAN_LOWERCASE_UNDERSCORE) || defined(BIND_FORTRAN_LOWERCASE)
 // Allow manual override of the defaults, e.g. if you want to use a fortran
@@ -48,4 +48,10 @@
 #define BIND_FORTRAN_F2C_RETURN_CONVENTIONS
 #endif
 
+#ifndef BIND_FORTRAN_INTEGER_8
+ typedef int fortran_int_t;
+#else
+ typedef std::ptrdiff_t fortran_int_t;
+#endif
+
 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H

Deleted: sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/fortran.h 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
+++ (empty file)
@@ -1,51 +0,0 @@
-//
-// Copyright (C) 2002, 2003 Si-Lab b.v.b.a., Toon Knapen and Kresimir Fresl
-//
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#ifndef BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H
-#define BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H
-
-#if defined(BIND_FORTRAN_LOWERCASE_UNDERSCORE) || defined(BIND_FORTRAN_LOWERCASE)
-// Allow manual override of the defaults, e.g. if you want to use a fortran
-// lib compiled with gcc from MSVC
-#else
-
-// First we need to know what the conventions for linking
-// C with Fortran is on this platform/toolset
-#if defined(__GNUC__) || defined(__ICC) || defined(__sgi) || defined(__COMO__) || defined(__KCC)
-#define BIND_FORTRAN_LOWERCASE_UNDERSCORE
-#elif defined(__IBMCPP__) || defined(_MSC_VER)
-#define BIND_FORTRAN_LOWERCASE
-#else
-#error do not know how to link with fortran for the given platform
-#endif
-
-#endif
-
-// Next we define macro's to convert our symbols to
-// the current convention
-#if defined(BIND_FORTRAN_LOWERCASE_UNDERSCORE)
-#define FORTRAN_ID( id ) id##_
-#elif defined(BIND_FORTRAN_LOWERCASE)
-#define FORTRAN_ID( id ) id
-#else
-#error do not know how to bind to fortran calling convention
-#endif
-
-
-// "g77" or clapack or "gfortran -ff2c"
-//#define BIND_FORTRAN_F2C_RETURN_CONVENTIONS
-// "g77 -fno-f2c" or "gfortran"
-//#define BIND_FORTRAN_NO_F2C_RETURN_CONVENTIONS
-
-// As long as f2c return conventions are the common case,
-// we turn them on unless requested otherwise
-#ifndef BIND_FORTRAN_NO_F2C_RETURN_CONVENTIONS
-#define BIND_FORTRAN_F2C_RETURN_CONVENTIONS
-#endif
-
-#endif // BOOST_NUMERIC_BINDINGS_TRAITS_FORTRAN_H

Modified: sandbox/numeric_bindings/boost/numeric/bindings/detail/get.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/get.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/get.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -38,6 +38,15 @@
         return detail::adaptor_access<T>:: \
         BOOST_PP_CAT( stride, which )( t ); \
     } \
+};\
+\
+template<> \
+struct get_dispatch< tag::bandwidth_type<which> > { \
+ template< typename T > \
+ static std::ptrdiff_t invoke( const T& t ) { \
+ return detail::adaptor_access<T>:: \
+ BOOST_PP_CAT( bandwidth, which )( t ); \
+ } \
 };
 
 BOOST_PP_REPEAT_FROM_TO(1,3,GENERATE_GET,~)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/size.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/size.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/size.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -141,13 +141,13 @@
 template< typename T, typename Tag >
 inline typename result_of::size_row_op< const T, Tag >::type
 size_row_op( const T& t, Tag ) {
- return size( t, typename index_trans< tag::index<1>, Tag >::type() );
+ return bindings::size( t, typename index_trans< tag::index<1>, Tag >::type() );
 }
 
 template< typename T, typename Tag >
 inline typename result_of::size_row_op< const T, Tag >::type
 size_column_op( const T& t, Tag ) {
- return size( t, typename index_trans< tag::index<2>, Tag >::type() );
+ return bindings::size( t, typename index_trans< tag::index<2>, Tag >::type() );
 }
 
 } // namespace bindings

Modified: sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -25,7 +25,8 @@
         mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::vector >,
         mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::data_structure, tag::linear_array >
+ mpl::pair< tag::data_structure, tag::linear_array >,
+ mpl::pair< tag::stride_type<1>, tag::contiguous >
> property_map;
 
     static std::ptrdiff_t size1( const Id& t ) {

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -64,11 +64,13 @@
 ADD_INT_TEMPLATE_TAG( tensor )
 ADD_INT_TEMPLATE_TAG( size_type )
 ADD_INT_TEMPLATE_TAG( stride_type )
+ADD_INT_TEMPLATE_TAG( bandwidth_type )
 ADD_INT_TEMPLATE_TAG( index )
 
 // Supported data structures
 ADD_TAG( linear_array )
 ADD_TAG( triangular_array )
+ADD_TAG( banded_array )
 ADD_TAG( yale_sparse )
 
 ADD_TAG( structure )
@@ -77,6 +79,7 @@
 ADD_TAG( unit_triangular )
 ADD_TAG( symmetric )
 ADD_TAG( hermitian )
+ADD_TAG( banded )
 
 ADD_TAG( num_strides )
 

Added: sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -0,0 +1,117 @@
+//
+// Copyright (c) 2009 Rutger ter Borg
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_BANDED_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_BANDED_HPP
+
+#include <boost/numeric/bindings/begin.hpp>
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/end.hpp>
+#include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
+#include <boost/numeric/bindings/value.hpp>
+#include <boost/numeric/ublas/banded.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename F, typename A, typename Id, typename Enable >
+struct adaptor< ublas::banded_matrix< T, F, A >, Id, Enable > {
+
+ typedef typename copy_const< Id, T >::type value_type;
+ typedef mpl::map<
+ mpl::pair< tag::value_type, value_type >,
+ mpl::pair< tag::entity, tag::matrix >,
+ mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
+ mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
+ mpl::pair< tag::matrix_type, tag::banded >,
+ mpl::pair< tag::data_structure, tag::banded_array >,
+ mpl::pair< tag::data_order, typename convert_to< tag::data_order, F >::type >,
+ mpl::pair< tag::bandwidth_type<1>, std::ptrdiff_t >,
+ mpl::pair< tag::bandwidth_type<2>, std::ptrdiff_t >
+ > property_map;
+
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.size1();
+ }
+
+ static std::ptrdiff_t size2( const Id& id ) {
+ return id.size2();
+ }
+
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.data() );
+ }
+
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.data() );
+ }
+
+ static std::ptrdiff_t bandwidth1( const Id& id ) {
+ return id.upper();
+ }
+
+ static std::ptrdiff_t bandwidth2( const Id& id ) {
+ return id.lower();
+ }
+
+};
+
+
+template< typename T, typename Id, typename Enable >
+struct adaptor< ublas::banded_adaptor< T >, Id, Enable > {
+
+ typedef typename copy_const< Id, typename value< T >::type >::type value_type;
+ typedef typename property_insert< T,
+ mpl::pair< tag::value_type, value_type >,
+ mpl::pair< tag::matrix_type, tag::banded >,
+ mpl::pair< tag::bandwidth_type<1>, std::ptrdiff_t >,
+ mpl::pair< tag::bandwidth_type<2>, std::ptrdiff_t >
+ >::type property_map;
+
+ static std::ptrdiff_t size1( const Id& id ) {
+ return bindings::size1( id.data() );
+ }
+
+ static std::ptrdiff_t size2( const Id& id ) {
+ return bindings::size2( id.data() );
+ }
+
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.data() );
+ }
+
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.data() );
+ }
+
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return bindings::stride1( id.data() );
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return bindings::stride2( id.data() );
+ }
+
+ static std::ptrdiff_t bandwidth1( const Id& id ) {
+ return id.upper();
+ }
+
+ static std::ptrdiff_t bandwidth2( const Id& id ) {
+ return id.lower();
+ }
+
+};
+
+} // detail
+} // bindings
+} // numeric
+} // boost
+
+#endif

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/hermitian.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/hermitian.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/hermitian.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -63,20 +63,28 @@
         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F >::type >
>::type property_map;
 
- static std::ptrdiff_t size1( const Id& t ) {
- return t.size1();
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.size1();
     }
 
- static std::ptrdiff_t size2( const Id& t ) {
- return t.size2();
+ static std::ptrdiff_t size2( const Id& id ) {
+ return id.size2();
     }
 
- static value_type* begin_value( Id& t ) {
- return bindings::begin_value( t.data() );
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.data() );
     }
 
- static value_type* end_value( Id& t ) {
- return bindings::end_value( t.data() );
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.data() );
+ }
+
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return bindings::stride1( id.data() );
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return bindings::stride2( id.data() );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -10,6 +10,7 @@
 #define BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_HPP
 
 #include <boost/numeric/bindings/begin.hpp>
+#include <boost/numeric/bindings/end.hpp>
 #include <boost/numeric/bindings/detail/adaptor.hpp>
 #include <boost/numeric/bindings/detail/if_row_major.hpp>
 #include <boost/numeric/bindings/ublas/detail/convert_to.hpp>

Added: sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -0,0 +1,64 @@
+//
+// Copyright (c) 2009 Rutger ter Borg
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_EXPRESSION_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_EXPRESSION_HPP
+
+#include <boost/numeric/bindings/begin.hpp>
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/detail/property_map.hpp>
+#include <boost/numeric/bindings/end.hpp>
+#include <boost/numeric/bindings/size.hpp>
+#include <boost/numeric/ublas/matrix_expression.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename Id, typename Enable >
+struct adaptor< boost::numeric::ublas::matrix_reference< T >, Id, Enable > {
+
+ typedef typename copy_const< Id, typename value<T>::type >::type value_type;
+ typedef typename property_insert<
+ T,
+ mpl::pair< tag::value_type, value_type >
+ >::type property_map;
+
+ static std::ptrdiff_t size1( const Id& id ) {
+ return bindings::size1( id.expression() );
+ }
+
+ static std::ptrdiff_t size2( const Id& id ) {
+ return bindings::size2( id.expression() );
+ }
+
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.expression() );
+ }
+
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.expression() );
+ }
+
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return bindings::stride1( id.expression() );
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return bindings::stride2( id.expression() );
+ }
+
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -57,26 +57,35 @@
 template< typename T, typename F, typename Id, typename Enable >
 struct adaptor< ublas::symmetric_adaptor< T, F >, Id, Enable > {
 
- typedef typename value< T >::type value_type;
- typedef typename property_insert< T,
+ typedef typename copy_const< Id, typename value< T >::type >::type value_type;
+ typedef typename property_insert< T,
+ mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::matrix_type, tag::symmetric >,
         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F >::type >
>::type property_map;
 
- static std::ptrdiff_t size1( const Id& t ) {
- return t.size1();
+ static std::ptrdiff_t size1( const Id& id ) {
+ return bindings::size1( id.data() );
     }
 
- static std::ptrdiff_t size2( const Id& t ) {
- return t.size2();
+ static std::ptrdiff_t size2( const Id& id ) {
+ return bindings::size2( id.data() );
     }
 
- static value_type* begin_value( Id& t ) {
- return bindings::begin_value( t.data() );
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.data() );
     }
 
- static value_type* end_value( Id& t ) {
- return bindings::end_value( t.data() );
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.data() );
+ }
+
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return bindings::stride1( id.data() );
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return bindings::stride2( id.data() );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -26,7 +26,7 @@
 
     typedef typename copy_const< Id, T >::type value_type;
     typedef mpl::map<
- mpl::pair< tag::value_type, T >,
+ mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::matrix >,
         mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
         mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
@@ -58,9 +58,10 @@
 template< typename T, typename F, typename Id, typename Enable >
 struct adaptor< ublas::triangular_adaptor< T, F >, Id, Enable > {
 
- typedef typename value< T >::type value_type;
- typedef typename property_insert< T,
- mpl::pair< tag::matrix_type, tag::triangular >,
+ typedef typename copy_const< Id, typename value< T >::type >::type value_type;
+ typedef typename property_insert< T,
+ mpl::pair< tag::value_type, value_type >,
+ mpl::pair< tag::matrix_type, typename convert_to< tag::matrix_type, F >::type >,
         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F >::type >
>::type property_map;
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp 2010-01-05 11:59:53 EST (Tue, 05 Jan 2010)
@@ -10,6 +10,8 @@
 #define BOOST_NUMERIC_BINDINGS_UBLAS_VECTOR_HPP
 
 #include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/begin.hpp>
+#include <boost/numeric/bindings/end.hpp>
 #include <boost/numeric/ublas/vector.hpp>
 
 namespace boost {


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