Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-04-16 18:07:14


Hi,

I think this is really useful. I'd suggest the name "element_abs"
(similar to element_prod). This may avoid confusion with the
vector/matrix norms.

Am Freitag, 13. April 2007 19:33 schrieb Neal Becker:
> A useful addition:
>
> namespace boost { namespace numeric { namespace ublas {
> template<class T>
> struct scalar_abs:
> public scalar_real_unary_functor<T> {
> typedef typename scalar_real_unary_functor<T>::value_type
> value_type; typedef typename
> scalar_real_unary_functor<T>::argument_type argument_type; typedef
> typename scalar_real_unary_functor<T>::result_type result_type;
>
> static BOOST_UBLAS_INLINE
> result_type apply (argument_type t) {
> return std::abs (t);

Why not scalar_traits<argument_type>::type_abs(t); ?

> }
> };
>
> template<typename E>
> inline typename vector_unary_traits<E, scalar_abs<typename
> E::value_type> >::result_type abs (vector_expression<E> const& e) {
> typedef typename vector_unary_traits<E, scalar_abs<typename
> E::value_type> >::expression_type expression_type; return
> expression_type (e ());
> }
>
> }}}

@Neal: Can you collect the snippets into functional.hpp and prepare a
patch?

mfg
Gunter