Classes | |
class | op_reshape |
Functions | |
template<typename T1 > | |
static void | op_reshape::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_reshape > &in) |
template<typename T1 > | |
static void | op_reshape::apply (Cube< typename T1::elem_type > &out, const OpCube< T1, op_reshape > &in) |
void op_reshape::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_reshape > & | in | |||
) | [inline, static, inherited] |
Definition at line 26 of file op_reshape_meat.hpp.
References Mat< eT >::at(), Op< T1, op_type >::aux, Op< T1, op_type >::aux_u32_a, Op< T1, op_type >::aux_u32_b, syslib::copy_elem(), unwrap_check< T1 >::M, unwrap< T1 >::M, Op< T1, op_type >::m, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, access::rw(), and Mat< eT >::set_size().
00027 { 00028 arma_extra_debug_sigprint(); 00029 00030 typedef typename T1::elem_type eT; 00031 00032 const unwrap<T1> tmp(in.m); 00033 const Mat<eT>& A = tmp.M; 00034 00035 const u32 in_n_rows = in.aux_u32_a; 00036 const u32 in_n_cols = in.aux_u32_b; 00037 00038 const u32 in_n_elem = in_n_rows * in_n_cols; 00039 00040 arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimensions"); 00041 00042 if(in.aux == eT(0)) 00043 { 00044 if(&out != &A) 00045 { 00046 out.set_size(in_n_rows, in_n_cols); 00047 syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem ); 00048 } 00049 else 00050 { 00051 access::rw(out.n_rows) = in_n_rows; 00052 access::rw(out.n_cols) = in_n_cols; 00053 } 00054 } 00055 else 00056 { 00057 unwrap_check< Mat<eT> > tmp(A, out); 00058 const Mat<eT>& B = tmp.M; 00059 00060 out.set_size(in_n_rows, in_n_cols); 00061 00062 eT* out_mem = out.memptr(); 00063 u32 i = 0; 00064 00065 for(u32 row=0; row<B.n_rows; ++row) 00066 { 00067 for(u32 col=0; col<B.n_cols; ++col) 00068 { 00069 out_mem[i] = B.at(row,col); 00070 ++i; 00071 } 00072 } 00073 00074 } 00075 00076 }
void op_reshape::apply | ( | Cube< typename T1::elem_type > & | out, | |
const OpCube< T1, op_reshape > & | in | |||
) | [inline, static, inherited] |
Definition at line 83 of file op_reshape_meat.hpp.
References Cube< eT >::at(), OpCube< T1, op_type >::aux, OpCube< T1, op_type >::aux_u32_a, OpCube< T1, op_type >::aux_u32_b, OpCube< T1, op_type >::aux_u32_c, syslib::copy_elem(), unwrap_cube_check< T1 >::M, unwrap_cube< T1 >::M, OpCube< T1, op_type >::m, Cube< eT >::memptr(), Cube< eT >::n_cols, Cube< eT >::n_elem, Cube< eT >::n_rows, Cube< eT >::n_slices, access::rw(), and Cube< eT >::set_size().
00084 { 00085 arma_extra_debug_sigprint(); 00086 00087 typedef typename T1::elem_type eT; 00088 00089 const unwrap_cube<T1> tmp(in.m); 00090 const Cube<eT>& A = tmp.M; 00091 00092 const u32 in_n_rows = in.aux_u32_a; 00093 const u32 in_n_cols = in.aux_u32_b; 00094 const u32 in_n_slices = in.aux_u32_c; 00095 00096 const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices; 00097 00098 arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimensions"); 00099 00100 if(in.aux == eT(0)) 00101 { 00102 if(&out != &A) 00103 { 00104 out.set_size(in_n_rows, in_n_cols, in_n_slices); 00105 syslib::copy_elem( out.memptr(), A.memptr(), out.n_elem ); 00106 } 00107 else 00108 { 00109 access::rw(out.n_rows) = in_n_rows; 00110 access::rw(out.n_cols) = in_n_cols; 00111 access::rw(out.n_slices) = in_n_slices; 00112 } 00113 } 00114 else 00115 { 00116 unwrap_cube_check< Cube<eT> > tmp(A, out); 00117 const Cube<eT>& B = tmp.M; 00118 00119 out.set_size(in_n_rows, in_n_cols, in_n_slices); 00120 00121 eT* out_mem = out.memptr(); 00122 u32 i = 0; 00123 00124 for(u32 slice=0; slice<B.n_slices; ++slice) 00125 { 00126 for(u32 row=0; row<B.n_rows; ++row) 00127 { 00128 for(u32 col=0; col<B.n_cols; ++col) 00129 { 00130 out_mem[i] = B.at(row,col,slice); 00131 ++i; 00132 } 00133 } 00134 } 00135 00136 } 00137 00138 }