Open Artur-Arstamyan opened 1 month ago
Thanks.
>>> A = np.arange(3).reshape(3,1)
>>> B = np.arange(3).reshape(1,3)
>>> it = np.nditer([A,B,None])
>>> print(it.operands[2])
[[ 4607825790175356065 -4611042647052049243 4603322190547985584]
[-4611042647052049244 4617283349392834114 -4613744806828471525]
[ 4603322190547985580 -4613744806828471528 4606153024599475605]]
>>> for x,y,z in it: z[...] = x + y
>>> print(it.operands[2])
[[0 1 2]
[1 2 3]
[2 3 4]]
Exercise 62 - Considering two arrays with shape (1,3) and (3,1), how to compute their sum using an iterator? Code
Unnecessary part
After
it = np.nditer([a,b,None])
it.operands[2]
already has that value.Exercise N80 Current code that gives error
Output
Solution - Use tuples