glue_times_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2010 NICTA and the authors listed below
00002 // http://nicta.com.au
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // 
00007 // This file is part of the Armadillo C++ library.
00008 // It is provided without any warranty of fitness
00009 // for any purpose. You can redistribute this file
00010 // and/or modify it under the terms of the GNU
00011 // Lesser General Public License (LGPL) as published
00012 // by the Free Software Foundation, either version 3
00013 // of the License or (at your option) any later version.
00014 // (see http://www.opensource.org/licenses for more info)
00015 
00016 
00017 //! \addtogroup glue_times
00018 //! @{
00019 
00020 
00021 
00022 //! \brief
00023 //! Template metaprogram depth_lhs
00024 //! calculates the number of Glue<Tx,Ty, glue_type> instances on the left hand side argument of Glue<Tx,Ty, glue_type>
00025 //! i.e. it recursively expands each Tx, until the type of Tx is not "Glue<..,.., glue_type>"  (i.e the "glue_type" changes)
00026 
00027 template<typename glue_type, typename T1>
00028 struct depth_lhs
00029   {
00030   static const u32 num = 0;
00031   };
00032 
00033 template<typename glue_type, typename T1, typename T2>
00034 struct depth_lhs< glue_type, Glue<T1,T2,glue_type> >
00035   {
00036   static const u32 num = 1 + depth_lhs<glue_type, T1>::num;
00037   };
00038 
00039 
00040 
00041 template<u32 N>
00042 struct glue_times_redirect
00043   {
00044   template<typename T1, typename T2>
00045   inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
00046   };
00047 
00048 
00049 template<>
00050 struct glue_times_redirect<3>
00051   {
00052   template<typename T1, typename T2, typename T3>
00053   inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
00054   };
00055 
00056 
00057 template<>
00058 struct glue_times_redirect<4>
00059   {
00060   template<typename T1, typename T2, typename T3, typename T4>
00061   inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X);
00062   };
00063 
00064 
00065 
00066 //! Class which implements the immediate multiplication of two or more matrices
00067 class glue_times
00068   {
00069   public:
00070   
00071   
00072   template<typename T1, typename T2>
00073   inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
00074   
00075   
00076   template<typename T1>
00077   inline static void apply_inplace(Mat<typename T1::elem_type>& out, const T1& X);
00078   
00079   template<typename T1, typename T2>
00080   arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times>& X, const s32 sign);
00081   
00082   template<typename eT1, typename eT2>
00083   inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, const Mat<eT1>& X, const Mat<eT2>& Y);
00084   
00085   
00086   template<typename eT>
00087   arma_inline static u32  mul_storage_cost(const Mat<eT>& A, const Mat<eT>& B, const bool do_trans_A, const bool do_trans_B);
00088   
00089   template<typename eT>
00090   arma_hot inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const eT val, const bool do_trans_A, const bool do_trans_B, const bool do_scalar_times);
00091   
00092   template<typename eT>
00093   inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat<eT>& C, const eT val, const bool do_trans_A, const bool do_trans_B, const bool do_trans_C, const bool do_scalar_times);
00094   
00095   template<typename eT>
00096   inline static void apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat<eT>& C, const Mat<eT>& D, const eT val, const bool do_trans_A, const bool do_trans_B, const bool do_trans_C, const bool do_trans_D, const bool do_scalar_times);
00097 
00098   };
00099 
00100 
00101 
00102 class glue_times_diag
00103   {
00104   public:
00105   
00106   template<typename T1, typename T2>
00107   arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X);
00108   
00109   };
00110 
00111 
00112 
00113 //! @}
00114