MCPcopy Create free account
hub / github.com/PX4/eigen / min_max

Function min_max

test/array.cpp:425–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423}
424
425template<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
454void test_array()
455{

Callers 1

test_arrayFunction · 0.85

Calls 4

rowsMethod · 0.45
colsMethod · 0.45
maxCoeffMethod · 0.45
minCoeffMethod · 0.45

Tested by 1

test_arrayFunction · 0.68