Modify

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#6511 closed Bugs (fixed)

Division by scalar should use enable_if<>

Reported by: Sean Reilly <campreilly@…> Owned by: guwi17
Milestone: Boost 1.52.0 Component: uBLAS
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

file: vector_expression.hpp lines 1409 through 1417 function: operator/( vector, scalar)

Should be using the enable_if<> macros just like the operator*() in lines 1397 through 1407 (just above it). Doing so allows further overloading of operator/() for other types. Suggested change is...

Before:

    // (v / t) [i] = v [i] / t
    template<class E1, class T2>
    BOOST_UBLAS_INLINE
    typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::result_type
    operator / (const vector_expression<E1> &e1,
                const T2 &e2) {
        typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::expression_type expression_type;
        return expression_type (e1 (), e2);
    }

After:

    // (v / t) [i] = v [i] / t
    template<class E1, class T2>
    BOOST_UBLAS_INLINE
    typename enable_if< is_convertible<T2, typename E1::value_type >,    
        typename vector_binary_scalar2_traits<E1, const T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
    >::type
    typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::result_type
    operator / (const vector_expression<E1> &e1,
                const T2 &e2) {
        typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::expression_type expression_type;
        return expression_type (e1 (), e2);
    }

Attachments (0)

Change History (6)

comment:1 Changed 5 years ago by guwi17

(In [80270]) boost/numeric/ublas/vector_expression.hpp - use enable_if for operator/(vector, scalar), see #6511

comment:2 Changed 5 years ago by guwi17

  • Status changed from new to assigned
  • Version changed from Boost 1.48.0 to Boost 1.52.0

comment:3 Changed 5 years ago by guwi17

  • Milestone changed from To Be Determined to Boost 1.52.0
  • Version changed from Boost 1.52.0 to Boost 1.48.0

updated wrong field

comment:4 Changed 5 years ago by guwi17

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:5 follow-up: Changed 4 years ago by Sean Reilly <campreilly@…>

Sorry to do this to you after the ticket has already closed...

But, did you happen to make the corresponding change to matrix_expression.hpp?

comment:6 in reply to: ↑ 5 Changed 4 years ago by guwi17

Replying to Sean Reilly <campreilly@…>:

But, did you happen to make the corresponding change to matrix_expression.hpp?

No, only vector_expression has been patched for this ticket.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain guwi17.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.