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