| 423 | } |
| 424 | |
| 425 | template<typename ArrayType> void min_max(const ArrayType& m) |
| 426 | { |
| 427 | typedef typename ArrayType::Index Index; |
| 428 | typedef typename ArrayType::Scalar Scalar; |
| 429 | |
| 430 | Index rows = m.rows(); |
| 431 | Index cols = m.cols(); |
| 432 | |
| 433 | ArrayType m1 = ArrayType::Random(rows, cols); |
| 434 | |
| 435 | // min/max with array |
| 436 | Scalar maxM1 = m1.maxCoeff(); |
| 437 | Scalar minM1 = m1.minCoeff(); |
| 438 | |
| 439 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)(ArrayType::Constant(rows,cols, minM1))); |
| 440 | VERIFY_IS_APPROX(m1, (m1.min)(ArrayType::Constant(rows,cols, maxM1))); |
| 441 | |
| 442 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)(ArrayType::Constant(rows,cols, maxM1))); |
| 443 | VERIFY_IS_APPROX(m1, (m1.max)(ArrayType::Constant(rows,cols, minM1))); |
| 444 | |
| 445 | // min/max with scalar input |
| 446 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, minM1), (m1.min)( minM1)); |
| 447 | VERIFY_IS_APPROX(m1, (m1.min)( maxM1)); |
| 448 | |
| 449 | VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)( maxM1)); |
| 450 | VERIFY_IS_APPROX(m1, (m1.max)( minM1)); |
| 451 | |
| 452 | } |
| 453 | |
| 454 | void test_array() |
| 455 | { |