Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59141 - sandbox/numeric_bindings/boost/numeric/bindings/ublas
From: rutger_at_[hidden]
Date: 2010-01-19 13:04:46


Author: rutger
Date: 2010-01-19 13:04:45 EST (Tue, 19 Jan 2010)
New Revision: 59141
URL: http://svn.boost.org/trac/boost/changeset/59141

Log:
corrected ublas' c_matrix and c_vector to have dynamic sizes

Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp | 15 ++++++++++++---
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp | 8 ++++++--
   2 files changed, 18 insertions(+), 5 deletions(-)

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-19 13:04:45 EST (Tue, 19 Jan 2010)
@@ -13,6 +13,7 @@
 #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/detail/offset.hpp>
 #include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
 #include <boost/numeric/bindings/ublas/storage.hpp>
 #include <boost/numeric/bindings/ublas/matrix_expression.hpp>
@@ -74,8 +75,8 @@
     typedef mpl::map<
         mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::matrix >,
- mpl::pair< tag::size_type<1>, mpl::int_<N> >,
- mpl::pair< tag::size_type<2>, mpl::int_<M> >,
+ mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
+ mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
         mpl::pair< tag::matrix_type, tag::general >,
         mpl::pair< tag::data_structure, tag::linear_array >,
         mpl::pair< tag::data_order, tag::row_major >,
@@ -83,12 +84,20 @@
         mpl::pair< tag::stride_type<2>, tag::contiguous >
> 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 id.data();
     }
 
     static value_type* end_value( Id& id ) {
- return id.data() + N*M;
+ return id.data() + offset( id, id.size1(), id.size2() );
     }
 
 };

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-19 13:04:45 EST (Tue, 19 Jan 2010)
@@ -54,17 +54,21 @@
     typedef mpl::map<
         mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::vector >,
- mpl::pair< tag::size_type<1>, mpl::int_<N> >,
+ mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
         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& id ) {
+ return id.size();
+ }
+
     static value_type* begin_value( Id& id ) {
         return id.data();
     }
 
     static value_type* end_value( Id& id ) {
- return id.data() + N;
+ return id.data() + id.size();
     }
 
 };


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