I have quite a basic question but I don't know how to do it. EDIT: Sorry for writing it unclearly I hope I can clarify it.
I want to write an if-else statement as a vector in linear algebra. However, this vector is the result of an if-else-statement of the form:
if b>1
then a=0
else a=c
I try to replicate it in the following form: I have a vector three vectors with length $n$.
Vector $b$'s elements are between 0 and 2 for example like this:
$b=\begin{pmatrix}
2 \\
0.5 \\
\vdots \\
1.5 \\
\end{pmatrix} $
Vector $C$'s elements are between 0 and 1 for example like this
$c=\begin{pmatrix} 0.1 \\ 0.2 \\ \vdots \\ 0.8 \\ \end{pmatrix} $
Now I want to set up an equation to construct vector $a$ with elements $a_1$ to $a_n$ so that
$a=\begin{pmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \\ \end{pmatrix}$.
I want to set all the enteries $a_i$ to 0 if $b_i$ is below a specific value e.g. 1. Otherwise I want set $a_i$ to $c_i$. So in this example: $a=\begin{pmatrix} 0 \\ 0.2 \\ \vdots \\ 0.8 \\ \end{pmatrix}$.
Linearily I would write it like this $a(i) = \begin{cases} 0 & \text{if } b(i)<1 \\ c(i) & \text{otherwise.} \end{cases}$ with $a, b,c,$ being functions that contain the same values of my example.
But how can I define such a vector? I want to to use this vector in a later multiplication.
I know that the questions is very familiar to these questions but they do not look at linear algebra:
- How to do If and Else in math?
- Representing IF … THEN … ELSE … in math notation
- Can you encode if-then-else in arithmetic
Thank you so much!