4

I'm having trouble using the pinv function from the numpy.linalg module. I want to invert a rectangular matrix A:

try:
    Binv = np.linalg.pinv(A)
except:
    print("an error occurs")

When I run the code no exception is raised, but in my Python prompt the following red text appears: init_dgesdd failed init.

However when I use my code with other matrices in other contexts (different shapes, different conditioning values...) it works fine.

ali_m
  • 71,714
  • 23
  • 223
  • 298
clemescolle
  • 71
  • 1
  • 5
  • When you say "red text", do you mean a full traceback, or does it literally only print `init_dgesdd failed init`? Could you post an example matrix that `pinv` fails on? – ali_m Mar 16 '15 at 20:49
  • No, the red text is not a full traceback. I will try to post an example matrix. – clemescolle Mar 16 '15 at 21:55

1 Answers1

3

After investigation of the error, it seems to come from memory issues. When I use a matrix with a (105 x 177144) shape, it works. But when I use a matrix with a (105 x 178668) shape, it does not work.

Moreover, a quik look at the numpy.linalg.umath_linalg.c.src code shows that the error mentionned in my previous post raised when the memory allocation of the memory buffer failed. This memory buffer is used to store the U, S, VT and all the intermediate arrays needed during the svd computation.

clemescolle
  • 71
  • 1
  • 5
  • 1
    Do you know if it blocks the script or if it is a problem that can be fixed at runtime by numpy? – LucG Jun 02 '17 at 05:38