Eglue_core

Classes

struct  eglue_core< eglue_type >

Functions

template<typename T1 , typename T2 >
static arma_inline T1::elem_type eglue_core::get_elem (const eGlue< T1, T2, eglue_type > &x, const u32 i)
template<typename T1 , typename T2 >
static arma_inline T1::elem_type eglue_core::get_elem (const eGlue< T1, T2, eglue_type > &x, const u32 row, const u32 col)
template<typename T1 , typename T2 >
static arma_inline void eglue_core::apply (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_proxy (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_unwrap (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_inplace_plus (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_inplace_minus (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_inplace_schur (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)
template<typename T1 , typename T2 >
static arma_hot void eglue_core::apply_inplace_div (Mat< typename T1::elem_type > &out, const eGlue< T1, T2, eglue_type > &x)

Function Documentation

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_inline T1::elem_type eglue_core< eglue_type >::get_elem ( const eGlue< T1, T2, eglue_type > &  x,
const u32  i 
) [inline, static, inherited]

Definition at line 26 of file eglue_core_meat.hpp.

References arma_stop(), eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00027   {
00028   // arma_extra_debug_sigprint();
00029   
00030   typedef typename T1::elem_type eT;
00031   
00032   // the optimiser will keep only one return statement
00033   
00034        if(is_same_type<eglue_type, eglue_plus >::value == true) { return x.P1[i] + x.P2[i]; }
00035   else if(is_same_type<eglue_type, eglue_minus>::value == true) { return x.P1[i] - x.P2[i]; }
00036   else if(is_same_type<eglue_type, eglue_div  >::value == true) { return x.P1[i] / x.P2[i]; }
00037   else if(is_same_type<eglue_type, eglue_schur>::value == true) { return x.P1[i] * x.P2[i]; }
00038   else
00039     {
00040     arma_stop("eglue_core::get_elem(): unhandled eglue_type");
00041     return eT(0);
00042     }
00043   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_inline T1::elem_type eglue_core< eglue_type >::get_elem ( const eGlue< T1, T2, eglue_type > &  x,
const u32  row,
const u32  col 
) [inline, static, inherited]

Definition at line 51 of file eglue_core_meat.hpp.

References arma_stop(), eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00052   {
00053   // arma_extra_debug_sigprint();
00054   
00055   typedef typename T1::elem_type eT;
00056   
00057        if(is_same_type<eglue_type, eglue_plus >::value == true) { return x.P1.at(row,col) + x.P2.at(row,col); }
00058   else if(is_same_type<eglue_type, eglue_minus>::value == true) { return x.P1.at(row,col) - x.P2.at(row,col); }
00059   else if(is_same_type<eglue_type, eglue_div  >::value == true) { return x.P1.at(row,col) / x.P2.at(row,col); }
00060   else if(is_same_type<eglue_type, eglue_schur>::value == true) { return x.P1.at(row,col) * x.P2.at(row,col); }
00061   else
00062     {
00063     arma_stop("eglue_core::get_elem(): unhandled eglue_type");
00064     return eT(0);
00065     }
00066   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_inline void eglue_core< eglue_type >::apply ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 74 of file eglue_core_meat.hpp.

References eglue_core< eglue_type >::apply_proxy(), and eglue_core< eglue_type >::apply_unwrap().

00075   {
00076   arma_extra_debug_sigprint();
00077   
00078   if( (is_Mat<T1>::value == true) && (is_Mat<T2>::value == true) )
00079     {
00080     eglue_core<eglue_type>::apply_unwrap(out, x);
00081     }
00082   else
00083     {
00084     eglue_core<eglue_type>::apply_proxy(out, x);
00085     }
00086   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_proxy ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 95 of file eglue_core_meat.hpp.

References arma_stop(), Mat< eT >::memptr(), eGlue< T1, T2, eglue_type >::P1, eGlue< T1, T2, eglue_type >::P2, and Mat< eT >::set_size().

Referenced by eglue_core< eglue_type >::apply().

00096   {
00097   arma_extra_debug_sigprint();
00098   
00099   // eglue_type::apply_proxy() function is not allowed to unwrap things
00100   // (in order to get the input into a common format).
00101   // the proxy class is already providing objects with element access
00102   
00103   typedef typename T1::elem_type eT;
00104   
00105   const Proxy<T1>& P1 = x.P1;
00106   const Proxy<T2>& P2 = x.P2;
00107   
00108   out.set_size(P1.n_rows, P1.n_cols);
00109   
00110         eT* out_mem = out.memptr();
00111   const u32 n_elem  = P1.n_elem;
00112   
00113        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] + P2[i]; }
00114   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] - P2[i]; }
00115   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] / P2[i]; }
00116   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = P1[i] * P2[i]; }
00117   else
00118     {
00119     arma_stop("eglue_core::apply_proxy(): unhandled eglue_type");
00120     }
00121   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_unwrap ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 130 of file eglue_core_meat.hpp.

References arma_stop(), unwrap< T1 >::M, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, eGlue< T1, T2, eglue_type >::P1, eGlue< T1, T2, eglue_type >::P2, and Mat< eT >::set_size().

Referenced by eglue_core< eglue_type >::apply().

00131   {
00132   arma_extra_debug_sigprint();
00133   
00134   typedef typename T1::elem_type eT;
00135   
00136   const unwrap<typename Proxy<T1>::stored_type> tmp1(x.P1.Q);
00137   const unwrap<typename Proxy<T2>::stored_type> tmp2(x.P2.Q);
00138   
00139   const Mat<eT>& A = tmp1.M;
00140   const Mat<eT>& B = tmp2.M;
00141   
00142   out.set_size(A.n_rows, A.n_cols);
00143   
00144         eT* out_mem = out.memptr();
00145   const eT* A_mem   = A.memptr();
00146   const eT* B_mem   = B.memptr();
00147   const u32 n_elem  = A.n_elem;
00148   
00149        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] + B_mem[i]; }
00150   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] - B_mem[i]; }
00151   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] / B_mem[i]; }
00152   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] = A_mem[i] * B_mem[i]; }
00153   else
00154     {
00155     arma_stop("eglue_core::apply_unwrap(): unhandled eglue_type");
00156     }
00157   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_inplace_plus ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 166 of file eglue_core_meat.hpp.

References arma_assert_same_size(), arma_stop(), Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_rows, eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00167   {
00168   arma_extra_debug_sigprint();
00169   
00170   typedef typename T1::elem_type eT;
00171   
00172   const Proxy<T1>& P1 = x.P1;
00173   const Proxy<T2>& P2 = x.P2;
00174   
00175   arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "matrix addition");
00176   
00177         eT* out_mem = out.memptr();
00178   const u32 n_elem  = P1.n_elem;
00179   
00180        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] + P2[i]; }
00181   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] - P2[i]; }
00182   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] / P2[i]; }
00183   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] += P1[i] * P2[i]; }
00184   else
00185     {
00186     arma_stop("eglue_core::apply_inplace_plus(): unhandled eglue_type");
00187     }
00188   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_inplace_minus ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 197 of file eglue_core_meat.hpp.

References arma_assert_same_size(), arma_stop(), Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_rows, eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00198   {
00199   arma_extra_debug_sigprint();
00200   
00201   typedef typename T1::elem_type eT;
00202   
00203   const Proxy<T1>& P1 = x.P1;
00204   const Proxy<T2>& P2 = x.P2;
00205   
00206   arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "matrix subtraction");
00207   
00208         eT* out_mem = out.memptr();
00209   const u32 n_elem  = P1.n_elem;
00210   
00211        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] + P2[i]; }
00212   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] - P2[i]; }
00213   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] / P2[i]; }
00214   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] -= P1[i] * P2[i]; }
00215   else 
00216     {
00217     arma_stop("eglue_core::apply_inplace_minus(): unhandled eglue_type");
00218     }
00219   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_inplace_schur ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 228 of file eglue_core_meat.hpp.

References arma_assert_same_size(), arma_stop(), Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_rows, eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00229   {
00230   arma_extra_debug_sigprint();
00231   
00232   typedef typename T1::elem_type eT;
00233   
00234   const Proxy<T1>& P1 = x.P1;
00235   const Proxy<T2>& P2 = x.P2;
00236   
00237   arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "element-wise matrix multiplication");
00238   
00239         eT* out_mem = out.memptr();
00240   const u32 n_elem  = P1.n_elem;
00241   
00242        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] + P2[i]; }
00243   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] - P2[i]; }
00244   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] / P2[i]; }
00245   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] *= P1[i] * P2[i]; }
00246   else
00247     {
00248     arma_stop("eglue_core::apply_inplace_schur(): unhandled eglue_type");
00249     }
00250   }

template<typename eglue_type>
template<typename T1 , typename T2 >
arma_hot void eglue_core< eglue_type >::apply_inplace_div ( Mat< typename T1::elem_type > &  out,
const eGlue< T1, T2, eglue_type > &  x 
) [inline, static, inherited]

Definition at line 259 of file eglue_core_meat.hpp.

References arma_assert_same_size(), arma_stop(), Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_rows, eGlue< T1, T2, eglue_type >::P1, and eGlue< T1, T2, eglue_type >::P2.

00260   {
00261   arma_extra_debug_sigprint();
00262   
00263   typedef typename T1::elem_type eT;
00264   
00265   const Proxy<T1>& P1 = x.P1;
00266   const Proxy<T2>& P2 = x.P2;
00267   
00268   arma_assert_same_size(out.n_rows, out.n_cols, P1.n_rows, P1.n_cols, "element-wise matrix division");
00269   
00270         eT* out_mem = out.memptr();
00271   const u32 n_elem  = P1.n_elem;
00272   
00273        if(is_same_type<eglue_type, eglue_plus >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] + P2[i]; }
00274   else if(is_same_type<eglue_type, eglue_minus>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] - P2[i]; }
00275   else if(is_same_type<eglue_type, eglue_div  >::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] / P2[i]; }
00276   else if(is_same_type<eglue_type, eglue_schur>::value == true) for(u32 i=0; i<n_elem; ++i) { out_mem[i] /= P1[i] * P2[i]; }
00277   else
00278     {
00279     arma_stop("eglue_core::apply_inplace_div(): unhandled eglue_type");
00280     }
00281   }