MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / isUpperTriangular

Method isUpperTriangular

include/Eigen/Eigen/src/Core/TriangularMatrix.h:667–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665 */
666template<typename Derived>
667bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
668{
669 RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);
670 for(Index j = 0; j < cols(); ++j)
671 {
672 Index maxi = numext::mini(j, rows()-1);
673 for(Index i = 0; i <= maxi; ++i)
674 {
675 RealScalar absValue = numext::abs(coeff(i,j));
676 if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
677 }
678 }
679 RealScalar threshold = maxAbsOnUpperPart * prec;
680 for(Index j = 0; j < cols(); ++j)
681 for(Index i = j+1; i < rows(); ++i)
682 if(numext::abs(coeff(i, j)) > threshold) return false;
683 return true;
684}
685
686/** \returns true if *this is approximately equal to a lower triangular matrix,
687 * within the precision given by \a prec.

Callers

nothing calls this directly

Calls 5

miniFunction · 0.85
colsFunction · 0.70
rowsFunction · 0.70
absFunction · 0.70
coeffFunction · 0.70

Tested by

no test coverage detected