Glue_join

Classes

class  glue_join

Functions

template<typename T1 , typename T2 >
static void glue_join::apply (Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_join > &X)

Function Documentation

template<typename T1 , typename T2 >
void glue_join::apply ( Mat< typename T1::elem_type > &  out,
const Glue< T1, T2, glue_join > &  X 
) [inline, static, inherited]

Definition at line 25 of file glue_join_meat.hpp.

References Glue< T1, T2, glue_type >::A, Glue< T1, T2, glue_type >::aux_u32, Glue< T1, T2, glue_type >::B, unwrap< T1 >::M, Mat< eT >::mem, Mat< eT >::mem_local, Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, Mat< eT >::reset(), access::rw(), Mat< eT >::set_size(), and Mat< eT >::submat().

00026   {
00027   arma_extra_debug_sigprint();
00028   
00029   typedef typename T1::elem_type eT;
00030 
00031   const unwrap<T1> A_tmp(X.A);
00032   const unwrap<T2> B_tmp(X.B);
00033   
00034   const Mat<eT>& A = A_tmp.M;
00035   const Mat<eT>& B = B_tmp.M;
00036   
00037   const u32 join_type = X.aux_u32;
00038   
00039   if(join_type == 0)
00040     {
00041     arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of columns must be the same" );
00042     }
00043   else
00044     {
00045     arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" );
00046     }
00047   
00048   
00049   
00050   if( (&out != &A) && (&out != &B) )
00051     {
00052     if(join_type == 0)   // join columns (i.e. result matrix has more rows)
00053       {
00054       out.set_size(A.n_rows + B.n_rows, A.n_cols);
00055       
00056       out.submat(0,        0, A.n_rows-1,   out.n_cols-1) = A;
00057       out.submat(A.n_rows, 0, out.n_rows-1, out.n_cols-1) = B;
00058       }
00059     else   // join rows  (i.e. result matrix has more columns)
00060       {
00061       out.set_size(A.n_rows, A.n_cols + B.n_cols);
00062       
00063       out.submat(0, 0,        out.n_rows-1, A.n_cols-1  ) = A;
00064       out.submat(0, A.n_cols, out.n_rows-1, out.n_cols-1) = B;
00065       }
00066     }
00067   else  // we have aliasing
00068     {
00069     Mat<eT> C;
00070     
00071     if(join_type == 0)
00072       {
00073       C.set_size(A.n_rows + B.n_rows, A.n_cols);
00074       
00075       C.submat(0,        0, A.n_rows-1, C.n_cols-1) = A;
00076       C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B;
00077       }
00078     else
00079       {
00080       C.set_size(A.n_rows, A.n_cols + B.n_cols);
00081       
00082       C.submat(0, 0,        C.n_rows-1, A.n_cols-1) = A;
00083       C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B;
00084       }
00085     
00086     if(C.n_elem > sizeof(C.mem_local)/sizeof(eT))
00087       {
00088       out.reset();
00089       
00090       access::rw(out.n_elem) = C.n_elem;
00091       access::rw(out.n_rows) = C.n_rows;
00092       access::rw(out.n_cols) = C.n_cols;
00093       access::rw(out.mem   ) = C.mem;
00094       
00095       access::rw(C.n_elem) = 0;
00096       access::rw(C.n_rows) = 0;
00097       access::rw(C.n_cols) = 0;
00098       }
00099     else
00100       {
00101       out = C;
00102       }
00103     }
00104   
00105   }