blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Add option to zero-initialize new elements created by resizeAndPreserve.

Open aaronmswan opened this issue 7 years ago • 2 comments

I found it useful to have new elements of an array created by resizeAndPreserve zero-initialize on request. For example when performing FFT interpolation. This can be a bit of a pain to do after the fact because multiple regions could need to be zeroed. I suppose this behavior could also be achieved externally to the library by re-implementing most of what resizeAndPreserve currently does.

Testing: passes "make check-testsuite".

Updated documentation.

Grateful for any feedback.

aaronmswan avatar Nov 11 '18 04:11 aaronmswan

Thank you! Let me though suggest adding a test program so that the new functionality will be covered.

Also, thinking out loud, I'm wondering if we could make the API more general by e.g. making the new argument an element-type pointer: if ==null nothing happens, while non-null value gives the user the option to provide a non-zero value for initialisation? @citibeth - any comments?

slayoo avatar Nov 12 '18 07:11 slayoo

Not sure what I think of it in the current context... This is the kind of change that could have unintended consequences. For example, what if someone wants to make blitz::Array<MyStruct,1>???

citibeth avatar May 10 '19 13:05 citibeth