# Epsilon on determinant

This topic is 2093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all,

Determinant of a matrix can be very very tiny so the epsilon to check it should be really tiny as well.

I use epsilon 1.0e-04f but it's not enough to check determinant of a matrix.

Is it safe to use FLT_EPSILON on this case or it's better to do : if(det == 0.0f) ?

Thanks

##### Share on other sites

What you using the determinant for? How do you know if some method is enough for you?

##### Share on other sites

I got prob on the polar decomp, using 1.0e-04f got problem, so I changed to "== 0.0f" and all worked fine but a floating point needs to be tested using epsilon to be safe.

Maybe on the determinant it's better to not use epsilon or use FLT_EPSILON on this case ?

##### Share on other sites

What algorithm are you using to compute the polar decomposition? There is no generally acceptable epsilon to test two floating points and the epsilon you should use in your case depends on what you are trying to achieve.

##### Share on other sites

I don't see any determinant computation in the paper you have linked.. Are you using it to test if the algorithm has converged? Wouldn't it be easier/better to simply compute some matrix norm (like the max norm or the Frobenius norm or some p-norm)?

Why are you writing the algorithm yourself instead of using some linear algebra library? For example, in Lapack or Eigen you may use easily compute the SVD decomposition and then get the polar decomposition from the resulting matrices.

EDIT: How big are your matrices?

Edited by apatriarca

##### Share on other sites
if (det==0.0) {do_rank2(Mk, MadjTk, Mk); break;}

Find on the .c you will see this line, it was the line who caused the problem on the animation system.

Why are you writing the algorithm yourself instead of using some linear algebra library?

Polar Decomp of Ken Shoemake works good, it's used on a lot of system and no dependency, the question is not the decomp but the epsilon on a matrix.

#define MATRIX_INVERSE_EPSILON 1e-14
#define MATRIX_EPSILON 1e-6
Doom3 BFG uses theses epsilon, is it a good option ?
Edited by Alundra

##### Share on other sites

It really depends on your algorithm and your numeric types. There's lots of algorithms that evaluate determinants. Some algorithms can handle high tolerances for epsilon, like 1e-12. Using floats instead of doubles limits the accuracy of the arithmetic, so high tolerances are probably not going to mean much. That all has to be taken into account. Like you probably know, you never want to just test for exact equivalence to zero unless you're testing for a very specific case.

det = vdot(Mk[0], MadjTk[0]);
if (det==0.0) {do_rank2(Mk, MadjTk, Mk); break;}


In Ken Shoemake's code above, he's just avoiding dividing by zero exception with the "if (det == 0)" check. It seems the algorithm can work for incredibly small numbers, so you don't need anything else other than just avoiding division by zero. Besides, he's using the vdot() function, which as far as I can tell isn't a determinant algorithm, but rather a dot product operation.

##### Share on other sites

Good catch that it's only to avoid division by zero.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 20
• 20
• 11
• 9
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!