Skip to content

Commit 084b4c5

Browse files
committed
Fix for #501 proposed by @kevinushey
1 parent 201718f commit 084b4c5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2026-02-19 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* inst/include/current/armadillo_bits/subview_meat.hpp: Cover special
4+
case of empty subview (by Kevin)
5+
16
2026-01-07 Dirk Eddelbuettel <edd@debian.org>
27

38
* .github/workflows/ci.yaml: Switch to actions/checkout@v6

inst/include/current/armadillo_bits/subview_meat.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,8 @@ subview<eT>::extract(Mat<eT>& out, const subview<eT>& in)
15941594
const uword n_cols = in.n_cols; // number of columns in the subview
15951595

15961596
arma_debug_print(arma_str::format("out.n_rows: %u; out.n_cols: %u; in.m.n_rows: %u; in.m.n_cols: %u") % out.n_rows % out.n_cols % in.m.n_rows % in.m.n_cols );
1597-
1597+
1598+
if(in.n_elem == 0) { return; }
15981599

15991600
if(in.is_vec())
16001601
{
@@ -1662,6 +1663,8 @@ subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in)
16621663
arma_debug_sigprint();
16631664

16641665
arma_conform_assert_same_size(out, in, "addition");
1666+
1667+
if(in.n_elem == 0) { return; }
16651668

16661669
const uword n_rows = in.n_rows;
16671670
const uword n_cols = in.n_cols;
@@ -1710,6 +1713,8 @@ subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in)
17101713
arma_debug_sigprint();
17111714

17121715
arma_conform_assert_same_size(out, in, "subtraction");
1716+
1717+
if(in.n_elem == 0) { return; }
17131718

17141719
const uword n_rows = in.n_rows;
17151720
const uword n_cols = in.n_cols;
@@ -1758,6 +1763,8 @@ subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in)
17581763
arma_debug_sigprint();
17591764

17601765
arma_conform_assert_same_size(out, in, "element-wise multiplication");
1766+
1767+
if(in.n_elem == 0) { return; }
17611768

17621769
const uword n_rows = in.n_rows;
17631770
const uword n_cols = in.n_cols;
@@ -1806,6 +1813,8 @@ subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in)
18061813
arma_debug_sigprint();
18071814

18081815
arma_conform_assert_same_size(out, in, "element-wise division");
1816+
1817+
if(in.n_elem == 0) { return; }
18091818

18101819
const uword n_rows = in.n_rows;
18111820
const uword n_cols = in.n_cols;

0 commit comments

Comments
 (0)