I use NumPy.
I have defined a vector x with NumPy and other variables with numerical values.
I will return a vector y of same length as x but the values y[i] in this vector y need to be computed from different formulas depending on the corresponding x[i].
Can I with NumPy do something smart or do I have to iterate through the vector x and for each element in x determine if x[i] is either greater than or less than a specific value and determine which formula to use for the specific element?
I guess I could do something like
y[x > a] = 2*x+7
y[x <= a] = 3*x+9
return y