How to Index Vectors of Different Cardinality with the Same Set?

49 Views Asked by At

This is a notation question which I will illustrate with the following example: Given $x\in \mathbb{R}^4$ and $y\in \mathbb{R}^2$, and two sets $I:=\{1,2,3,4\}$ and $J:=\{2,4\}$. So $J$ represents some subvector of $x$ that I care about for certain operations with $y$, such as $x_j y_j \forall j\in J$. To me the meaning of the statement is clear, but it seems to be wrong since we are indexing the first element of $y$ as $y_2$ and the second one as $y_4$.

What is the clearest way to write this type of statements without inaccuracy?

Let me add that I would like to avoid defining new variables.

(I have come to this issue while writing constraints for optimization problems.)

1

There are 1 best solutions below

0
On

Let me assume $J$ is ordered.

You could define the $|J| \times |I|$ selection matrix $S(J)$ such that $S(J)x$ is the required subvector.

Alternatively, you can refer to $x_{J(i)} y_i$, where $J(i)$ is the $i^{th}$ element of $J$.