#ifndef glas_conj_expression_hpp #define glas_conj_expression_hpp //#include //#ifdef GLAS_BACKEND_GLAS //# include //#endif //#ifdef GLAS_BACKEND_BLAS //# include //#endif //#ifdef GLAS_BACKEND_VSIPLPP //# include //#endif #include #include #include #include #include #include #include #include #ifdef GLAS_COMPLEX # include #endif namespace glas { template struct conj_functor { typedef T argument_type ; typedef T result_type ; result_type operator()(argument_type const & v) const { return v ; } } ; #ifdef GLAS_COMPLEX template struct conj_functor< std::complex > { typedef std::complex argument_type ; typedef std::complex result_type ; result_type operator()(argument_type const & v) const { return std::conj( v ) ; } } ; #endif template class scalar_conj_expression { public: typedef T argument_type ; public: scalar_conj_expression(T const & t) : argument_( t ) {} argument_type const & argument() const { return argument_ ; } template operator C () const { return conj_functor()(argument_) ; } private: void operator=(scalar_conj_expression const &) ; private: argument_type const & argument_ ; } ; template class vector_conj_expression { public: typedef V argument_type ; typedef typename V::value_type value_type ; typedef typename V::size_type size_type ; // required by VectorExpression typedef typename V::value_type const_reference ; public: // required by binary-expression vector_conj_expression(V const & v) : argument_( v ) {} // required by binary-expression argument_type const& argument() const { return argument_ ; } // required by VectorExpression size_type size() const { return argument_.size() ; } // required by VectorExpression const_reference operator[](size_type i) const { return conj_functor()(argument_[i]) ; } private: void operator=(vector_conj_expression const &) ; private: argument_type const& argument_ ; } ; template struct concept< scalar_conj_expression > { typedef boost::mpl::vector< scalar_expression_concept > type ; } ; template struct concept< vector_conj_expression > { typedef boost::mpl::vector< vector_expression_concept > type ; } ; namespace detail { /// Helper class to determine the return-type of the conj template struct conj_return_type : boost::mpl::if_< ::glas::is_vector_expression, vector_conj_expression, scalar_conj_expression > {} ; } /// conj free functor. /// /// create scalar_conj_expression for scalar arguments /// create vector_conj_expression for vector arguments template typename detail::conj_return_type::type conj( T const& v ) { typename detail::conj_return_type::type ret( v ) ; return ret ; } } #endif // glas_conj_expression_hpp