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) |
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 00040 if(A.n_elem == 0) 00041 { 00042 out = B; 00043 return; 00044 } 00045 00046 if(B.n_elem == 0) 00047 { 00048 out = A; 00049 return; 00050 } 00051 00052 00053 if(join_type == 0) 00054 { 00055 arma_debug_check( (A.n_cols != B.n_cols), "join_cols(): number of columns must be the same" ); 00056 } 00057 else 00058 { 00059 arma_debug_check( (A.n_rows != B.n_rows), "join_rows(): number of rows must be the same" ); 00060 } 00061 00062 00063 00064 if( (&out != &A) && (&out != &B) ) 00065 { 00066 if(join_type == 0) // join columns (i.e. result matrix has more rows) 00067 { 00068 out.set_size(A.n_rows + B.n_rows, A.n_cols); 00069 00070 out.submat(0, 0, A.n_rows-1, out.n_cols-1) = A; 00071 out.submat(A.n_rows, 0, out.n_rows-1, out.n_cols-1) = B; 00072 } 00073 else // join rows (i.e. result matrix has more columns) 00074 { 00075 out.set_size(A.n_rows, A.n_cols + B.n_cols); 00076 00077 out.submat(0, 0, out.n_rows-1, A.n_cols-1 ) = A; 00078 out.submat(0, A.n_cols, out.n_rows-1, out.n_cols-1) = B; 00079 } 00080 } 00081 else // we have aliasing 00082 { 00083 Mat<eT> C; 00084 00085 if(join_type == 0) 00086 { 00087 C.set_size(A.n_rows + B.n_rows, A.n_cols); 00088 00089 C.submat(0, 0, A.n_rows-1, C.n_cols-1) = A; 00090 C.submat(A.n_rows, 0, C.n_rows-1, C.n_cols-1) = B; 00091 } 00092 else 00093 { 00094 C.set_size(A.n_rows, A.n_cols + B.n_cols); 00095 00096 C.submat(0, 0, C.n_rows-1, A.n_cols-1) = A; 00097 C.submat(0, A.n_cols, C.n_rows-1, C.n_cols-1) = B; 00098 } 00099 00100 if(C.n_elem > sizeof(C.mem_local)/sizeof(eT)) 00101 { 00102 out.reset(); 00103 00104 access::rw(out.n_elem) = C.n_elem; 00105 access::rw(out.n_rows) = C.n_rows; 00106 access::rw(out.n_cols) = C.n_cols; 00107 access::rw(out.mem ) = C.mem; 00108 00109 access::rw(C.n_elem) = 0; 00110 access::rw(C.n_rows) = 0; 00111 access::rw(C.n_cols) = 0; 00112 } 00113 else 00114 { 00115 out = C; 00116 } 00117 } 00118 00119 }