Home > database >  Determinant over a specific axis using numpy
Determinant over a specific axis using numpy

Time:01-26

Suppose I have a numpy array A with shape (j,d,d) and I want to obtain an array with shape j, in which each entry corresponds to the determinant of each (d,d) array.

I tried using np.apply_along_axis(np.linalg.det(A), axis=0), but np.apply_along_axis only seems to work for 1D slices.

Is there an efficient way of doing that using only numpy?

CodePudding user response:

np.linalg.det can already do this for an array of arbitrary shape as long as the last two dimensions are square. You can see the documentation here.

  •  Tags:  
  • Related