From fa52e3f5eff3b16593e709d6c2f56824e754e4e2 Mon Sep 17 00:00:00 2001 From: conrad Date: Wed, 25 Feb 2026 13:11:14 +1000 Subject: [PATCH] speedup for empty subcubes --- include/armadillo_bits/subview_cube_meat.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/armadillo_bits/subview_cube_meat.hpp b/include/armadillo_bits/subview_cube_meat.hpp index 651eafc0..50576999 100644 --- a/include/armadillo_bits/subview_cube_meat.hpp +++ b/include/armadillo_bits/subview_cube_meat.hpp @@ -1704,21 +1704,24 @@ void subview_cube::extract(Cube& out, const subview_cube& in) { arma_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 constructor or operator=() - const uword n_rows = in.n_rows; - const uword n_cols = in.n_cols; - const uword n_slices = in.n_slices; + const uword n_rows = in.n_rows; + const uword n_cols = in.n_cols; + const uword n_slices = in.n_slices; + const uword n_elem_slice = in.n_elem_slice; arma_debug_print(arma_str::format("out.n_rows: %u; out.n_cols: %u; out.n_slices: %u; in.m.n_rows: %u; in.m.n_cols: %u; in.m.n_slices: %u") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n_cols % in.m.n_slices); + if(n_elem_slice == 0) { return; } + if( (in.aux_row1 == 0) && (n_rows == in.m.n_rows) ) { for(uword s=0; s < n_slices; ++s) { - arrayops::copy( out.slice_colptr(s,0), in.slice_colptr(s,0), in.n_elem_slice ); + arrayops::copy( out.slice_colptr(s,0), in.slice_colptr(s,0), n_elem_slice ); } return;