matvec_promotions.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00018 #ifndef matvec_promotions_h
00019 #define matvec_promotions_h
00020 
00021 #include <cml/et/scalar_promotions.h>
00022 #include <cml/vector/vector_promotions.h>
00023 
00024 namespace cml {
00025 namespace et {
00026 
00027 /* Default mat/vec type promotion template. */
00028 template<typename LeftT, typename RightT> struct MatVecPromote;
00029 
00031 template<
00032     typename E1, class AT1, typename BO, typename L,
00033     typename E2, class AT2>
00034 struct MatVecPromote< cml::matrix<E1,AT1,BO,L>, cml::vector<E2,AT2> >
00035 {
00036     typedef cml::matrix<E1,AT1,BO,L> matrix_type;
00037     typedef cml::vector<E2,AT2> vector_type;
00038 
00039     /* Promote the arrays: */
00040     typedef typename ArrayPromote<
00041         typename matrix_type::array_type,
00042         typename vector_type::array_type
00043     >::type promoted_array;
00044 
00045     /* The deduced vector result type: */
00046     typedef cml::vector<
00047         typename promoted_array::value_type,
00048         typename promoted_array::generator_type
00049     > type;
00050 
00051     /* The deduced temporary type: */
00052     typedef typename type::temporary_type temporary_type;
00053     /* Note: this is to avoid an "incomplete type" error from ICC9, which
00054      * can't handle e.g. <X>::<Y>::<Z> when <X> is a template type.
00055      */
00056 };
00057 
00059 template<
00060     typename E1, class AT1,
00061     typename E2, class AT2, typename BO, typename L>
00062 struct MatVecPromote< cml::vector<E1,AT1>, cml::matrix<E2,AT2,BO,L> >
00063 {
00064     typedef cml::vector<E1,AT1> vector_type;
00065     typedef cml::matrix<E2,AT2,BO,L> matrix_type;
00066 
00067     /* Promote the arrays: */
00068     typedef typename ArrayPromote<
00069         typename vector_type::array_type,
00070         typename matrix_type::array_type
00071     >::type promoted_array;
00072 
00073     /* The deduced vector result type: */
00074     typedef cml::vector<
00075         typename promoted_array::value_type,
00076         typename promoted_array::generator_type
00077     > type;
00078 
00079     /* The deduced temporary type: */
00080     typedef typename type::temporary_type temporary_type;
00081     /* Note: this is to avoid an "incomplete type" error from ICC9, which
00082      * can't handle e.g. <X>::<Y>::<Z> when <X> is a template type.
00083      */
00084 };
00085 
00086 } // namespace et
00087 } // namespace cml
00088 
00089 #endif
00090 
00091 // -------------------------------------------------------------------------
00092 // vim:ft=cpp

Generated on Sat Jul 18 19:35:27 2009 for CML 1.0 by  doxygen 1.5.9