Finding a Singular Matrix

I’ve just tripped over a crash that seems to be caused by the presence, somewhere, of a singular matrix. Specifically, it seems to be happening in “graphicsEngine.renderFrame()”.

Alas, however, I don’t know where this singular matrix is–I know which scenario it seems to appear in, and can with good reliability reproduce it, but I haven’t found an apparent application of a zero-scale that might be causing the problem.

Having searched the forum, I tried the PRC-option “no-singular-invert 1”–but, as noted where I found that option, if I want to get specific information at the point of the attempted inversion I would presumably want to debug the C++ code. Which… I suppose that I could do, but I’d rather not build from source and attempt to debug there if there’s another way–especially as I don’t know whether PyCharm can debug into C++ code…

As a result, I’m somewhat stuck as to how to proceed in locating the problem. Does anyone have any suggestions…?

Hi Thaumaturge,

I do not know the pipeline and why this is done, but I do know a bit about matrix math.

The inverse of a matrix T can be solved for: T^(-1) = Adj(T) / det (T)

For a 2x2 matrix T = [[a,b],[c,d]], the adjucate is defined as Adj(T) = [[d,-c],[-b,a]] and the determinant is defiend as det(T) = ad-bc. In the special case that your matrix is singular, it means that ad==bc rather for any matrix T, if det(T) == 0 it is said to be singular. You cannot compute the inverse of the matrix.

I don’t know best practices for managing this, but I am not sure there exist an inverse of a singular matrix. But I am not an expert of these things.

That may be helpful based on this post

I think based on what I read, when computing the singular matrix, we are solving for T(-1) such that T(-1)*T = I and in the Moore Penrose inverse, I believe you calculate T+, such that TT+ = I. Keep in mind that matrix are not commutative, i.e. AB != BA thus, T^(-1) != T+.

You can also make it non singular :slight_smile:

Or try singular value decomp (This one I don’t understand)

I don’t know if that is helpful because again, I am not sure for what reason is it needed to inert the matrix and since those matrices are not equal, I don’t now how that helps. Sorry =)

Thank you for the answer. :slight_smile:

To be clear, the matrix-inversion is being done by Panda, I believe–it’s not something that I’m attempting to do.

That said, this issue would nevertheless seem to indicate that I’m doing something incorrect somewhere–that I’m doing something that is resulting in a matrix that is singular, but that Panda expects to be able to invert.

(This can, for example, happen if one sets a scaling-factor to zero, I believe.)

The problem, then, is determining where that unknown incorrect operation is happening–what it is that’s resulting in this problematic singular matrix…

Ah, I’ve found the problem, I do believe!

Indeed, there was a zero-scale being applied: a particular constructor was taking as one of its parameters a scaling-factor, and for some reason I had given a zero for one dimension of that scaling-factor.

(I do wonder, then, whether it’s worth having the engine issue a warning about zero-scales.)

Ah, I see your point! The issue came when setting up your matrix and not that you were having issues computing something from a matrix that happened to be singular. Heh, I was worried it may be a common issue =)

Glad you solved it!

1 Like

I also regret that there is no good way to track down a singular matrix. This is a persistent source of annoyance. I’ve opened this feature request:

1 Like

Thank you for that! :slight_smile: