inline void subview_cube<eT>::operator/= (const subview_cube<eT>& x) { arma_extra_debug_sigprint(); if(check_overlap(x)) { const Cube<eT> tmp(x); (*this).operator/=(tmp); return; } subview_cube<eT>& t = *this; arma_debug_assert_same_size(t, x, "element-wise division"); const uword t_n_rows = t.n_rows; const uword t_n_cols = t.n_cols; const uword t_n_slices = t.n_slices; for(uword slice = 0; slice < t_n_slices; ++slice) { for(uword col = 0; col < t_n_cols; ++col) { arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows ); } } }
inline void subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "element-wise cube division"); const u32 n_rows = out.n_rows; const u32 n_cols = out.n_cols; const u32 n_slices = out.n_slices; for(u32 slice = 0; slice<n_slices; ++slice) { for(u32 col = 0; col<n_cols; ++col) { eT* out_coldata = out.slice_colptr(slice,col); const eT* in_coldata = in.slice_colptr(slice,col); for(u32 row = 0; row<n_rows; ++row) { out_coldata[row] /= in_coldata[row]; } } } }
inline void subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "matrix element-wise division"); const u32 in_n_rows = in.n_rows; const u32 in_n_cols = in.n_cols; const u32 in_aux_slice1 = in.aux_slice1; for(u32 col = 0; col < in_n_cols; ++col) { arrayops::inplace_div( out.colptr(col), in.slice_colptr(in_aux_slice1, col), in_n_rows ); } }
inline void subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "matrix schur product"); const u32 in_n_rows = in.n_rows; const u32 in_n_cols = in.n_cols; const u32 in_aux_slice1 = in.aux_slice1; for(u32 col = 0; col < in_n_cols; ++col) { arrayops::inplace_mul( out.colptr(col), in.slice_colptr(in_aux_slice1, col), in_n_rows ); } }
inline void subview_cube<eT>::extract(Cube<eT>& actual_out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); // const bool alias = (&actual_out == &in.m); Cube<eT>* tmp = (alias) ? new Cube<eT> : 0; Cube<eT>& out = (alias) ? (*tmp) : actual_out; // const u32 n_rows = in.n_rows; const u32 n_cols = in.n_cols; const u32 n_slices = in.n_slices; out.set_size(n_rows, n_cols, n_slices); arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_slices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n_cols % in.m.n_slices); for(u32 slice = 0; slice<n_slices; ++slice) { for(u32 col = 0; col<n_cols; ++col) { eT* out_coldata = out.slice_colptr(slice,col); const eT* in_coldata = in.slice_colptr(slice,col); for(u32 row = 0; row<n_rows; ++row) { out_coldata[row] = in_coldata[row]; } } } if(alias) { actual_out = out; delete tmp; } }
inline void subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given subcube doesn't have exactly one slice" ); const u32 n_rows = in.n_rows; const u32 n_cols = in.n_cols; const u32 aux_slice1 = in.aux_slice1; out.set_size(n_rows, n_cols); for(u32 col = 0; col < n_cols; ++col) { syslib::copy_elem( out.colptr(col), in.slice_colptr(aux_slice1, col), n_rows ); } }
inline void subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "element-wise division"); const uword n_rows = out.n_rows; const uword n_cols = out.n_cols; const uword n_slices = out.n_slices; for(uword slice = 0; slice<n_slices; ++slice) { for(uword col = 0; col<n_cols; ++col) { arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows ); } } }
inline void subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "cube addition"); const u32 n_rows = out.n_rows; const u32 n_cols = out.n_cols; const u32 n_slices = out.n_slices; for(u32 slice = 0; slice<n_slices; ++slice) { for(u32 col = 0; col<n_cols; ++col) { arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows ); } } }
inline void subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_same_size(out, in, "matrix element-wise division"); for(u32 col = 0; col < in.n_cols; ++col) { const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); eT* out_coldata = out.colptr(col); for(u32 row = 0; row < in.n_rows; ++row) { out_coldata[row] /= in_coldata[row]; } } }
inline void subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given subcube doesn't have exactly one slice" ); out.set_size(in.n_rows, in.n_cols); for(u32 col = 0; col < in.n_cols; ++col) { const eT* in_coldata = in.slice_colptr(in.aux_slice1, col); eT* out_coldata = out.colptr(col); for(u32 row = 0; row < in.n_rows; ++row) { out_coldata[row] = in_coldata[row]; } } }
inline void op_vectorise_cube_col::apply_subview(Mat<eT>& out, const subview_cube<eT>& sv) { arma_extra_debug_sigprint(); const uword sv_n_rows = sv.n_rows; const uword sv_n_cols = sv.n_cols; const uword sv_n_slices = sv.n_slices; out.set_size(sv.n_elem, 1); eT* out_mem = out.memptr(); for(uword slice=0; slice < sv_n_slices; ++slice) for(uword col=0; col < sv_n_cols; ++col ) { arrayops::copy(out_mem, sv.slice_colptr(slice,col), sv_n_rows); out_mem += sv_n_rows; } }
inline void subview_cube<eT>::extract(Cube<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); // NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing; // size setting and alias checking is done by either the Cube contructor or operator=() const uword n_rows = in.n_rows; const uword n_cols = in.n_cols; const uword n_slices = in.n_slices; arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_slices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n_cols % in.m.n_slices); for(uword slice = 0; slice < n_slices; ++slice) { for(uword col = 0; col < n_cols; ++col) { arrayops::copy( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows ); } } }
inline void subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_cube_as_mat(out, in, "element-wise division", true); const uword in_n_rows = in.n_rows; const uword in_n_cols = in.n_cols; const uword in_n_slices = in.n_slices; const uword out_n_rows = out.n_rows; const uword out_n_cols = out.n_cols; const uword out_vec_state = out.vec_state; if(in_n_slices == 1) { for(uword col=0; col < in_n_cols; ++col) { arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n_rows ); } } else { if(out_vec_state == 0) { if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) { for(uword i=0; i < in_n_slices; ++i) { arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ); } } else if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) ) { const Cube<eT>& Q = in.m; const uword in_aux_row1 = in.aux_row1; const uword in_aux_col1 = in.aux_col1; const uword in_aux_slice1 = in.aux_slice1; for(uword slice=0; slice < in_n_slices; ++slice) { const uword mod_slice = in_aux_slice1 + slice; eT* out_colptr = out.colptr(slice); uword i,j; for(i=0, j=1; j < in_n_cols; i+=2, j+=2) { const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice); const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice); out_colptr[i] /= tmp_i; out_colptr[j] /= tmp_j; } if(i < in_n_cols) { out_colptr[i] /= Q.at(in_aux_row1, in_aux_col1 + i, mod_slice); } } } } else { eT* out_mem = out.memptr(); const Cube<eT>& Q = in.m; const uword in_aux_row1 = in.aux_row1; const uword in_aux_col1 = in.aux_col1; const uword in_aux_slice1 = in.aux_slice1; for(uword i=0; i<in_n_slices; ++i) { out_mem[i] /= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); } } } }
inline void subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false); const uword in_n_rows = in.n_rows; const uword in_n_cols = in.n_cols; const uword in_n_slices = in.n_slices; const uword out_vec_state = out.vec_state; if(in_n_slices == 1) { out.set_size(in_n_rows, in_n_cols); for(uword col=0; col < in_n_cols; ++col) { arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ); } } else { if(out_vec_state == 0) { if(in_n_cols == 1) { out.set_size(in_n_rows, in_n_slices); for(uword i=0; i < in_n_slices; ++i) { arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ); } } else if(in_n_rows == 1) { const Cube<eT>& Q = in.m; const uword in_aux_row1 = in.aux_row1; const uword in_aux_col1 = in.aux_col1; const uword in_aux_slice1 = in.aux_slice1; out.set_size(in_n_cols, in_n_slices); for(uword slice=0; slice < in_n_slices; ++slice) { const uword mod_slice = in_aux_slice1 + slice; eT* out_colptr = out.colptr(slice); uword i,j; for(i=0, j=1; j < in_n_cols; i+=2, j+=2) { const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice); const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice); out_colptr[i] = tmp_i; out_colptr[j] = tmp_j; } if(i < in_n_cols) { out_colptr[i] = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice); } } } } else { out.set_size(in_n_slices); eT* out_mem = out.memptr(); const Cube<eT>& Q = in.m; const uword in_aux_row1 = in.aux_row1; const uword in_aux_col1 = in.aux_col1; const uword in_aux_slice1 = in.aux_slice1; for(uword i=0; i<in_n_slices; ++i) { out_mem[i] = Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); } } } }
inline void subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_cube_as_mat(out, in, "element-wise division", true); const u32 in_n_rows = in.n_rows; const u32 in_n_cols = in.n_cols; const u32 in_n_slices = in.n_slices; const u32 out_n_rows = out.n_rows; const u32 out_n_cols = out.n_cols; const u32 out_vec_state = out.vec_state; if(in_n_slices == 1) { for(u32 col=0; col < in_n_cols; ++col) { arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n_rows ); } } else { if(out_vec_state == 0) { if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) ) { for(u32 i=0; i < in_n_slices; ++i) { arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ); } } else if( (in_n_rows == 1) && (in_n_cols == out_n_cols) && (in_n_slices == out_n_rows) ) { const Cube<eT>& Q = in.m; const u32 in_aux_row1 = in.aux_row1; const u32 in_aux_col1 = in.aux_col1; const u32 in_aux_slice1 = in.aux_slice1; for(u32 col=0; col < in_n_cols; ++col) { eT* out_colptr = out.colptr(col); for(u32 i=0; i < in_n_slices; ++i) { out_colptr[i] /= Q.at(in_aux_row1, in_aux_col1 + col, in_aux_slice1 + i); } } } } else { eT* out_mem = out.memptr(); const Cube<eT>& Q = in.m; const u32 in_aux_row1 = in.aux_row1; const u32 in_aux_col1 = in.aux_col1; const u32 in_aux_slice1 = in.aux_slice1; for(u32 i=0; i<in_n_slices; ++i) { out_mem[i] /= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); } } } }
inline void subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in) { arma_extra_debug_sigprint(); arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false); const u32 in_n_rows = in.n_rows; const u32 in_n_cols = in.n_cols; const u32 in_n_slices = in.n_slices; const u32 out_vec_state = out.vec_state; if(in_n_slices == 1) { out.set_size(in_n_rows, in_n_cols); for(u32 col=0; col < in_n_cols; ++col) { arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows ); } } else { if(out_vec_state == 0) { if(in_n_cols == 1) { out.set_size(in_n_rows, in_n_slices); for(u32 i=0; i < in_n_slices; ++i) { arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows ); } } else if(in_n_rows == 1) { out.set_size(in_n_slices, in_n_cols); const Cube<eT>& Q = in.m; const u32 in_aux_row1 = in.aux_row1; const u32 in_aux_col1 = in.aux_col1; const u32 in_aux_slice1 = in.aux_slice1; for(u32 col=0; col < in_n_cols; ++col) { eT* out_colptr = out.colptr(col); for(u32 i=0; i < in_n_slices; ++i) { out_colptr[i] = Q.at(in_aux_row1, in_aux_col1 + col, in_aux_slice1 + i); } } } } else { out.set_size(in_n_slices); eT* out_mem = out.memptr(); const Cube<eT>& Q = in.m; const u32 in_aux_row1 = in.aux_row1; const u32 in_aux_col1 = in.aux_col1; const u32 in_aux_slice1 = in.aux_slice1; for(u32 i=0; i<in_n_slices; ++i) { out_mem[i] = Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i); } } } }