Speed up python code for computing matrix cofactors

前端 未结 4 1667
庸人自扰
庸人自扰 2021-01-05 00:40

As part of a complex task, I need to compute matrix cofactors. I did this in a straightforward way using this nice code for computing matrix minors. Here is my code:

4条回答
  •  梦谈多话
    2021-01-05 01:21

    The calculation of np.array(range(row)+range(row+1,nrows))[:,np.newaxis] does not depended on col so you could could move that outside the inner loop and cache the value. Depending on the number of columns you have this might give a small optimization.

提交回复
热议问题