From fd437d41beeaa207fc13f5a7f488568114eba095 Mon Sep 17 00:00:00 2001 From: conrad Date: Tue, 14 Feb 2023 01:29:26 +1000 Subject: [PATCH] constructor with optional memory zeroing --- include/armadillo_bits/podarray_bones.hpp | 3 +++ include/armadillo_bits/podarray_meat.hpp | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/armadillo_bits/podarray_bones.hpp b/include/armadillo_bits/podarray_bones.hpp index 07a2b860..852c2410 100644 --- a/include/armadillo_bits/podarray_bones.hpp +++ b/include/armadillo_bits/podarray_bones.hpp @@ -53,6 +53,9 @@ class podarray arma_inline explicit podarray(const uword new_N); + template + inline explicit podarray(const uword new_N, const arma_initmode_indicator&); + arma_inline explicit podarray(const eT* X, const uword new_N); // template diff --git a/include/armadillo_bits/podarray_meat.hpp b/include/armadillo_bits/podarray_meat.hpp index c42f4576..044124d8 100644 --- a/include/armadillo_bits/podarray_meat.hpp +++ b/include/armadillo_bits/podarray_meat.hpp @@ -94,6 +94,25 @@ podarray::podarray(const uword new_n_elem) +template +template +inline +podarray::podarray(const uword new_n_elem, const arma_initmode_indicator&) + : n_elem(new_n_elem) + { + arma_extra_debug_sigprint_this(this); + + init_cold(new_n_elem); + + if(do_zeros) + { + arma_extra_debug_print("podarray::constructor: zeroing memory"); + arrayops::fill_zeros(memptr(), n_elem); + } + } + + + template arma_inline podarray::podarray(const eT* X, const uword new_n_elem)