On Fri, Apr 4, 2025 at 5:48 AM Riccardo (Jack) Lucchetti
<p002264(a)staff.univpm.it> wrote:
> Hi all,
>
> yesterday me and a colleague found ourselves writing, for the millionth
> time, a hansl function implementing the so-called "soft thresholding"
> operator, and I was thinking that, although it's very easy, it'd be nice
> if it were a builtin function. So I wrote a hansl function that IMO is
> quite nice and general (works with scalars, series and matrices) and is
> in the attached script, along with a few usage examples[*].
>
> Note that the function could be made more general, for example
> introducing the scalar rho as in
>
https://www.sciencedirect.com/topics/computer-science/soft-thresholding
> , eq. (11.46) or allowing for "hard thresholding", like in the
> Mathematica function "wthresh", but maybe not for now.
>
> What I'm asking the community is:
>
> 1) Is it worthwhile having a dedicated function for this at all?
>
> 2) If so, should we have this as a builtin function[**], or should it
> just be in extra?
It's quite similar to -- although more general than -- the function
zeroifclose() that's already present in the "extra" addon. Not sure if
that suggests it's "extra" material.
Thanks for pointing this out. My spontaneous reaction would then be to
generalize the existing zeroifclose() in extra. Perhaps the old name
could be retained as an alias which would invoke a special case of the
new function, at least for some time.
cheers
sven