mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Global: Avoid floating-point equality checks where possible
This commit is contained in:
parent
081b1ff216
commit
28414a6af8
150 changed files with 762 additions and 672 deletions
|
|
@ -176,7 +176,7 @@ bool Matrix<ElementType>::solve (Matrix& b) const noexcept
|
|||
{
|
||||
auto denominator = A (0,0);
|
||||
|
||||
if (denominator == 0)
|
||||
if (approximatelyEqual (denominator, (ElementType) 0))
|
||||
return false;
|
||||
|
||||
b (0, 0) /= denominator;
|
||||
|
|
@ -187,7 +187,7 @@ bool Matrix<ElementType>::solve (Matrix& b) const noexcept
|
|||
{
|
||||
auto denominator = A (0, 0) * A (1, 1) - A (0, 1) * A (1, 0);
|
||||
|
||||
if (denominator == 0)
|
||||
if (approximatelyEqual (denominator, (ElementType) 0))
|
||||
return false;
|
||||
|
||||
auto factor = (1 / denominator);
|
||||
|
|
@ -204,7 +204,7 @@ bool Matrix<ElementType>::solve (Matrix& b) const noexcept
|
|||
+ A (0, 1) * (A (1, 2) * A (2, 0) - A (1, 0) * A (2, 2))
|
||||
+ A (0, 2) * (A (1, 0) * A (2, 1) - A (1, 1) * A (2, 0));
|
||||
|
||||
if (denominator == 0)
|
||||
if (approximatelyEqual (denominator, (ElementType) 0))
|
||||
return false;
|
||||
|
||||
auto factor = 1 / denominator;
|
||||
|
|
@ -231,10 +231,10 @@ bool Matrix<ElementType>::solve (Matrix& b) const noexcept
|
|||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
if (M (j, j) == 0)
|
||||
if (approximatelyEqual (M (j, j), (ElementType) 0))
|
||||
{
|
||||
auto i = j;
|
||||
while (i < n && M (i, j) == 0)
|
||||
while (i < n && approximatelyEqual (M (i, j), (ElementType) 0))
|
||||
++i;
|
||||
|
||||
if (i == n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue