2

I'm struggling to write my algorithm in a concise and correct way.
The following is an explanation for an optimizer's update step of **part of a** vector of weights (not a matrix in my case).

I have a vector $\alpha \in \mathbb{R}^d$, and a set $S$ that includes some indices $1\leq i \leq d$ ($S \subseteq \{1,\dots, d\}$). Now, I want to denote that $\alpha$ is 0 for every index $i\in S$, and otherwise it's the value as in $\alpha_i$. At first I denoted it $\alpha_S$, but I'm not sure it is properly defined or understandable.

I could use the following notation:

$\alpha_S = \begin{cases} \alpha_j & j \in S\\ 0 & j \notin S \end{cases}$

But its line height is twice the size, and I want to avoid that.

Is there any other formal, simplistic way to notate this correctly? Maybe some kind of a masking vector to be multiplied with $\alpha$?

Thanks!

So if I have a vector $\alpha$ and I want to "mask it", I would have to do something like: $\alpha \leftarrow (\alpha_1 * 1_S(\alpha_1), ... , \alpha_d * 1_S(\alpha_d))$? Isn't there a vectorized variant of this function to make this simple, like $\alpha \leftarrow \alpha * 1_S$? – pp1 – 2020-05-29T16:44:57.480

I meant $\alpha \leftarrow 1_S(\alpha)$ – pp1 – 2020-05-29T16:50:34.003

Indicator vector does not quite work in my case. – pp1 – 2020-05-29T16:53:55.297

This was going to be my first suggestion too: define the indicator vector, and define a coordinate-wise product of vectors. – Ben Reiniger – 2020-05-29T17:59:07.240

@leed see my edit. – NiklasvMoers – 2020-05-30T11:38:44.197

You defined a sum over the vector's components. I meant to produce a masked vector. A simple solution to this would be in a for loop: for all $i \in S, x_i = x_i + \alpha_i$. – pp1 – 2020-05-30T15:11:10.797

1The vector $\alpha_S$ that I defined is masked as in it has the component $\alpha_i$ in the i-th entry if $i \notin S$ and $0$ if $i \in S$. Notice how I am not adding up the elements $a_i$ but I am multiplying them with the unit vector $e_i$. Therefore, $\alpha_S$ is a d-dimensional vector as well. – NiklasvMoers – 2020-05-30T16:38:10.060