davideberly / GeometricTools

A collection of source code for computing in the fields of mathematics, geometry, graphics, image analysis and physics.
Boost Software License 1.0
1.14k stars 214 forks source link

Why did the LInfinityNorm function M [0] of Matrix not take an absolute value #85

Closed WuyangPeng closed 8 months ago

WuyangPeng commented 8 months ago

template <int32_t NumRows, int32_t NumCols, typename Real> Real LInfinityNorm(Matrix<NumRows, NumCols, Real> const& M) { Real maxAbsElement = M[0]; for (int32_t i = 1; i < NumRows * NumCols; ++i) { Real absElement = std::fabs(M[i]); if (absElement > maxAbsElement) { maxAbsElement = absElement; } } return maxAbsElement; }

davideberly commented 8 months ago

You have a polite way of saying "There is a bug in your code." Thank you for reporting this. I have pushed the fix to the repository. This is GTE code. I looked at the GTL code and verified that code is correct.

davideberly commented 8 months ago

Closing the issue because the bug is fixed.