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

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.)

• In your example it seems that if a and x have different cardinality you would have the same problem I presented. – Septimus G Oct 25 '16 at 21:26
• Projections projections projections. – Asaf Karagila Oct 25 '16 at 21:29

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$.