Boost logo

Ublas :

From: Nuno Sucena Almeida (slug_at_[hidden])
Date: 2007-04-15 13:58:41


And some more to get the argument (complex value type):

namespace boost { namespace numeric { namespace ublas {

  template<class T>
  struct scalar_arg:
    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::arg (t);
    }

  };

  template<typename E>
  BOOST_UBLAS_INLINE
  typename vector_unary_traits<E, scalar_arg<typename E::value_type> >::result_type
  arg (vector_expression<E> const& e) {
    typedef typename vector_unary_traits<E, scalar_arg<typename E::value_type> >::expression_type
      expression_type;
    return expression_type (e ());
  }

  template<typename E>
  BOOST_UBLAS_INLINE
  typename matrix_unary1_traits<E, scalar_arg<typename E::value_type> >::result_type
  arg (matrix_expression<E> const& e) {
    typedef typename matrix_unary1_traits<E, scalar_arg<typename E::value_type> >::expression_type
      expression_type;
    return expression_type (e ());
  }

}}}

-- 
http://aeminium.org/slug
D30B 54C0 40A7 7D61 C44F  4BA4 F071 2168 F494 ACB9