| 646 | */ |
| 647 | template<typename Derived> |
| 648 | bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const |
| 649 | { |
| 650 | RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1); |
| 651 | for(Index j = 0; j < cols(); ++j) |
| 652 | { |
| 653 | Index maxi = numext::mini(j, rows()-1); |
| 654 | for(Index i = 0; i <= maxi; ++i) |
| 655 | { |
| 656 | RealScalar absValue = numext::abs(coeff(i,j)); |
| 657 | if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue; |
| 658 | } |
| 659 | } |
| 660 | RealScalar threshold = maxAbsOnUpperPart * prec; |
| 661 | for(Index j = 0; j < cols(); ++j) |
| 662 | for(Index i = j+1; i < rows(); ++i) |
| 663 | if(numext::abs(coeff(i, j)) > threshold) return false; |
| 664 | return true; |
| 665 | } |
| 666 | |
| 667 | /** \returns true if *this is approximately equal to a lower triangular matrix, |
| 668 | * within the precision given by \a prec. |
no test coverage detected