Opened 12 years ago
Closed 12 years ago
#4399 closed Patches (fixed)
Make the free function 'size' support the uBLAS traits system and better work with expression types
Reported by: | Owned by: | David Bellot | |
---|---|---|---|
Milestone: | Boost 1.45.0 | Component: | uBLAS |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
Actually the implementation of the size free function has two weak points:
- It does not make use of the new uBLAS traits system introduced by Gunter.
E.g.: typename ExprT::size_type should become typename matrix_traits<ExprT>::size_type
- It does not fully support expression types. The current support is error prone and not user-friendly.
E.g.: if ExprT is an expression type and e is a variable of type ExprT, then one has to call size(e()) instead of simply size(e).
I suggest to change the size operation in order to fix the above issues.
Attachments (2)
Change History (7)
by , 12 years ago
Attachment: | size-allow_expr_and_break_back_comp.patch added |
---|
comment:1 by , 12 years ago
I've tried to change the 'size' operation without affecting its syntax but I've failed.
More specifically, the problem is given by one of the polymorphic version of size:
template <typename TagT, typename ExprT> typename ExprT::size_type size(ExprT const& e);
which I've initially transformed into
template <typename TagT, typename MatrixExprT> typename matrix_traits<MatrixExprT>::size_type size(matrix_expression<ExprT> const& me);
See the thread http://lists.boost.org/MailArchives/ublas/2010/06/4362.php for more details.
So, my solution is to break back compatibility by removing that version of size and introducing a new free function (e.g., size_by_tag) with the same semantic.
I attach a patch for the size operation and the related test suite.
by , 12 years ago
Attachment: | size-allow_expr.patch added |
---|
Patch for size.hpp which is back compatible.
comment:2 by , 12 years ago
At the end I was able to create a patch for size.hpp which does not break back compatibility. So ignore the initially submitted patch (size-allow_expr_and_break_back_comp.patch).
I admit the real credits go to Daniel & Stefan, two guys that suggested to me the way to go. For more info see: http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/bd5080b28865f826
Summary of changes:
- Use of ublas type-traits system (e.g. typename matrix_traits<M>::size_type).
- Explicit use of matrix_/vector_expression in function arguments (e.g. size(matrix_expression<M> const& m).
- Call to size<1>(v), with v a vector expression, is legal and returns the length of the vector-
Do you like it?
comment:4 by , 12 years ago
Milestone: | Boost 1.44.0 → Boost-1.45.0 |
---|---|
Owner: | changed from | to
Version: | Boost 1.44.0 → Boost Development Trunk |
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Adds the use of uBLAS type traits, simplifies the interaction with expression types, replaces the 'size<tag>' function with the 'size_by_tag<tag>' function.