From 39231f8d520c9c53e721faba0aa8d08867eb0cb8 Mon Sep 17 00:00:00 2001 From: conrad Date: Fri, 3 Jun 2022 14:16:12 +1000 Subject: [PATCH] simplification --- include/armadillo_bits/fn_ones.hpp | 12 ++++-------- include/armadillo_bits/fn_zeros.hpp | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/armadillo_bits/fn_ones.hpp b/include/armadillo_bits/fn_ones.hpp index 0335756d..ae8b6220 100644 --- a/include/armadillo_bits/fn_ones.hpp +++ b/include/armadillo_bits/fn_ones.hpp @@ -43,14 +43,10 @@ ones(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), cons arma_ignore(junk1); arma_ignore(junk2); - if(is_Row::value) - { - return Gen(1, n_elem); - } - else - { - return Gen(n_elem, 1); - } + const uword n_rows = (is_Row::value) ? uword(1) : n_elem; + const uword n_cols = (is_Row::value) ? n_elem : uword(1); + + return Gen(n_rows, n_cols); } diff --git a/include/armadillo_bits/fn_zeros.hpp b/include/armadillo_bits/fn_zeros.hpp index cb45d405..5f069223 100644 --- a/include/armadillo_bits/fn_zeros.hpp +++ b/include/armadillo_bits/fn_zeros.hpp @@ -43,14 +43,10 @@ zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), con arma_ignore(junk1); arma_ignore(junk2); - if(is_Row::value) - { - return Gen(1, n_elem); - } - else - { - return Gen(n_elem, 1); - } + const uword n_rows = (is_Row::value) ? uword(1) : n_elem; + const uword n_cols = (is_Row::value) ? n_elem : uword(1); + + return Gen(n_rows, n_cols); }