my_expression.hpp

00001 //
00002 //  Copyright (c) 2005-2007
00003 //  James N Knight
00004 //
00005 //  Permission to use, copy, modify, distribute and sell this software
00006 //  and its documentation for any purpose is hereby granted without fee,
00007 //  provided that the above copyright notice appear in all copies and
00008 //  that both that copyright notice and this permission notice appear
00009 //  in supporting documentation.  The authors make no representations
00010 //  about the suitability of this software for any purpose.
00011 //  It is provided "as is" without express or implied warranty.
00012 //
00013 //  
00014 // See http://homepages.inf.ed.ac.uk/svijayak/publications/vijayakumar-NeuCom2005.pdf
00015 // for the original publication of this algorithm.
00016 
00017 
00018 
00019 #ifndef MY_EXPRESSION_HPP
00020 #define MY_EXPRESSION_HPP
00021 
00022 #include <boost/numeric/ublas/expression_types.hpp>
00023 #include <boost/numeric/ublas/functional.hpp>
00024 
00025 namespace boost { namespace numeric { namespace ublas {
00026 
00027   // (op v) [i] = op( v [i] )
00028   template<class OP, class E> 
00029   BOOST_UBLAS_INLINE
00030   typename vector_unary_traits<E, OP>::result_type
00031   apply_to_all (const vector_expression<E> &e, const OP& op = OP() ) {
00032     typedef typename vector_unary_traits<E, OP>::expression_type expression_type;
00033     return expression_type (e ());
00034   };
00035 
00036   // (op v) [i] = op( v [i] )
00037   template<class OP, class E> 
00038   BOOST_UBLAS_INLINE
00039   typename matrix_unary1_traits<E, OP>::result_type
00040   apply_to_all (const matrix_expression<E> &e, const OP& op = OP() ) {
00041     typedef typename matrix_unary1_traits<E, OP>::expression_type expression_type;
00042     return expression_type (e ());
00043   };
00044 
00045 }}}
00046 
00047 namespace boost { namespace numeric { namespace ublas {
00048     template<class T>
00049     struct scalar_exp:
00050         public scalar_real_unary_functor<T> {
00051         typedef typename scalar_real_unary_functor<T>::value_type value_type;
00052         typedef typename scalar_real_unary_functor<T>::argument_type argument_type;
00053         typedef typename scalar_real_unary_functor<T>::result_type result_type;
00054 
00055         static BOOST_UBLAS_INLINE
00056         result_type apply (argument_type t) {
00057             return std::exp(t);
00058         }
00059     };
00060 
00061 }}}
00062 
00063 #endif

Generated on Fri Jul 27 00:24:01 2007 for LWPR by  doxygen 1.5.1