| 585 | } |
| 586 | |
| 587 | template<typename ArrayType> void min_max(const ArrayType& m) |
| 588 | { |
| 589 | typedef typename ArrayType::Scalar Scalar; |
| 590 | |
| 591 | Index rows = m.rows(); |
| 592 | Index cols = m.cols(); |
| 593 | |
| 594 | ArrayType m1 = ArrayType::Random(rows, cols); |
| 595 | |
| 596 | // min/max with array |
| 597 | Scalar maxM1 = m1.maxCoeff(); |
| 598 | Scalar minM1 = m1.minCoeff(); |
| 599 | |
| 600 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)(ArrayType::Constant(rows,cols, minM1))); |
| 601 | VERIFY_IS_APPROX(m1, (m1.min)(ArrayType::Constant(rows,cols, maxM1))); |
| 602 | |
| 603 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)(ArrayType::Constant(rows,cols, maxM1))); |
| 604 | VERIFY_IS_APPROX(m1, (m1.max)(ArrayType::Constant(rows,cols, minM1))); |
| 605 | |
| 606 | // min/max with scalar input |
| 607 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)( minM1)); |
| 608 | VERIFY_IS_APPROX(m1, (m1.min)( maxM1)); |
| 609 | |
| 610 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)( maxM1)); |
| 611 | VERIFY_IS_APPROX(m1, (m1.max)( minM1)); |
| 612 | |
| 613 | |
| 614 | // min/max with various NaN propagation options. |
| 615 | if (m1.size() > 1 && !NumTraits<Scalar>::IsInteger) { |
| 616 | m1(0,0) = NumTraits<Scalar>::quiet_NaN(); |
| 617 | maxM1 = m1.template maxCoeff<PropagateNaN>(); |
| 618 | minM1 = m1.template minCoeff<PropagateNaN>(); |
| 619 | VERIFY((numext::isnan)(maxM1)); |
| 620 | VERIFY((numext::isnan)(minM1)); |
| 621 | |
| 622 | maxM1 = m1.template maxCoeff<PropagateNumbers>(); |
| 623 | minM1 = m1.template minCoeff<PropagateNumbers>(); |
| 624 | VERIFY(!(numext::isnan)(maxM1)); |
| 625 | VERIFY(!(numext::isnan)(minM1)); |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | template<int N> |
| 630 | struct shift_left { |