I want to index a lot of python matrices to carry out calculations (mainly dot products) on corresponding elements. I'm having a problem using the non-zero values of one matrix to index a matrix that has fewer columns - it throws errors saying the index is out of bounds. Is there a way for me to tell python not to care about when the index is out of bounds - to ignore those ones and just deal with the ones that are in bounds? The code is something like this:
for u in range (n): # u = row:
U[R[u,:]!=0, u] ...
the dimension of U is (dxn) and dimension of R is (nxm) where m > n > d (usually).
I was hoping there is something built in in python to ignore when the index is out of bounds?