1
$\begingroup$

I have a 2D vector $v$, where each component is in the range -1 to +1.

I'd like a function $f(v, x)$, where x is a real number, and the result is a vector, such that each $component$ of the result is zero if abs($component$) < $x$ where $abs(x) < 1$.

  • 0
    @Ilmari: Hah, yes. :) Sadly, Knuth's evangelizing for the Iverson brackets hasn't been spectacularly successful, but oh well... I guess whichever of piecewise notation, Iverson brackets, or C-ish constructs should you use depends on the audience.2011-07-27

1 Answers 1

1

The definition of such a function isn't very far from your verbal description.

I wouldn't bother formalizing it further, but if you must, you can define $f(u,v) = (g_x(u),g_x(v))$ where $ g_x(t) = \begin{cases} 0 & t < |x| \\ t & \mbox{otherwise} \end{cases} $

  • 0
    ...or in Iverson bracket form: $t[t\geq|x|]$. That can be rewritten as $t(1+|t-|x||/(t-|x|))/2$, but I see no advantage in rewriting it that way, except if for some reason you abhor the use of Iverson brackets...2011-07-27