So I have a matrix call it Vjunk which is 70x70x70x70. I have another matrix which is 70x70 call it V.
What I wanna do is that for every i, j the matrix Vjunk[:,:,i,j]
is 70 by 70. I want to change this matrix so that it is replaced by itself + V[i,j]
where V[i,j]
is the ij-th element of my matrix V.
I tried
[Vjunk[:,:,i,j]=Vjunk[:,:,i,j]-beta*V[i,j] for i in range(humangrid_size) for j in range(assetgrid_size)]
but this command was unsucessful.
Let's use this indice on Vjunk : (m, n, i, j)
If I'm correct, you want that for every m, n combination, Vjunk(m,n,i,j) get replaced by Vjunk(m,n,i,j) -beta * V[i,j]. If that's the goal, this loop should do the trick :
Dunno if it's gonna be fast enough, even if it's only a 70*70*70*70 matrix. Still more than 20M operations.
The loop on i, j could probably get replaced by list comprehension.