| 665 | */ |
| 666 | template<typename Derived> |
| 667 | bool 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. |