Consider a numpy array X
with m
elements. Each element it’s itself a numpy matrix of a generic (but, more importantly, fixed shape (n0, n1, ..., n)
so that X
shape is (m, n0, n1, ..., n)
.
Now, take a list of m (different) scalar, let’s say something like this:
c = np.arange(m)
c
and X
have the same number of elements: c
is an array of m
scalar, while X
it’s an array of m
matrixes.
I would like to add to every elements of X[i]
the constant c[i]
for i in range(m):
X[i] += c[i]
is it possible to perform this calculation without the for loop? Something like X+c
(but ofc it does not work)
Thank you for your help
1