amaurea / enlib

5 stars 12 forks source link

segmentation fault in array_ops.eigpow() #42

Closed ajvanengelen closed 6 years ago

ajvanengelen commented 6 years ago

Matrices of modest size are throwing segmentation faults in this routine. It happens for (1, 1, 1000, 1000) but not (1, 1, 100, 100)

In [4]: a = np.random.randn(1, 1, 1000, 1000)

In [5]: a.shape
Out[5]: (1, 1, 1000, 1000)

In [6]: from enlib import array_ops 

In [7]: zz = array_ops.eigpow(a, 0.5)
Segmentation fault
ajvanengelen commented 6 years ago

It turns out that in my case this was due to calling this routine with the wrong arguments for the typical use case. If one wants to diagonalize on the first two indices, as we do when we want to make correlated gaussian random variables, then one must pass axis = [0,1] to array_ops.eigpow. This is different from utils.eigpow (and enmap.multipow, which is a wrapper for utils.eigpow), which assumes this by default.

msyriac commented 6 years ago

Hi @ajvanengelen , should we consider this issue resolved?

ajvanengelen commented 6 years ago

Sure -- while I guess seg faults are bugs by definition, I think it's unlikely that anyone would legitimately try to call this routine in the way that I did here (unless they were just doing it incorrectly, as I was).