Improve test coverage for inner product, fill, reductions, and IO

libeigen/eigen!2286

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-03-12 12:48:45 -07:00
parent 5e478d3285
commit c93116b43d
5 changed files with 209 additions and 1 deletions

View File

@@ -87,6 +87,32 @@ void block(const MatrixType& m) {
m1.col(c1).setZero();
VERIFY_IS_CWISE_EQUAL(m1.col(c1), DynamicVectorType::Zero(rows));
m1 = m1_copy;
// test setZero/setConstant/setOnes on non-contiguous multi-row/multi-col blocks
// This exercises the non-fill_n path in Fill.h and verifies no data corruption
if (r2 > r1 && c2 > c1) {
Index br = r2 - r1, bc = c2 - c1;
m1 = m1_copy;
m1.block(r1, c1, br, bc).setZero();
VERIFY_IS_CWISE_EQUAL(m1.block(r1, c1, br, bc), DynamicMatrixType::Zero(br, bc));
for (Index j = 0; j < cols; ++j)
for (Index i = 0; i < rows; ++i)
if (i < r1 || i >= r2 || j < c1 || j >= c2) VERIFY_IS_EQUAL(m1(i, j), m1_copy(i, j));
m1 = m1_copy;
m1.block(r1, c1, br, bc).setConstant(s1);
VERIFY_IS_CWISE_EQUAL(m1.block(r1, c1, br, bc), DynamicMatrixType::Constant(br, bc, s1));
for (Index j = 0; j < cols; ++j)
for (Index i = 0; i < rows; ++i)
if (i < r1 || i >= r2 || j < c1 || j >= c2) VERIFY_IS_EQUAL(m1(i, j), m1_copy(i, j));
m1 = m1_copy;
m1.block(r1, c1, br, bc).setOnes();
VERIFY_IS_CWISE_EQUAL(m1.block(r1, c1, br, bc), DynamicMatrixType::Ones(br, bc));
for (Index j = 0; j < cols; ++j)
for (Index i = 0; i < rows; ++i)
if (i < r1 || i >= r2 || j < c1 || j >= c2) VERIFY_IS_EQUAL(m1(i, j), m1_copy(i, j));
}
m1 = m1_copy;
// check row() and col()
VERIFY_IS_EQUAL(m1.col(c1).transpose(), m1.transpose().row(c1));