Add hcat/vcat DenseBase concatenation expressions

Summary

Add hcat() and vcat() free functions for concatenating dense expressions horizontally and vertically.

Design:

  • New ConcatOp<Direction, LhsType, RhsType> expression class following the Replicate.h pattern
  • internal::traits specialization with compile-time dimension propagation
  • Custom evaluator with coeff(row, col) dispatching to lhs/rhs based on boundary index
  • Uses ref_selector in the expression + nested_eval in the evaluator for proper rvalue lifetime handling
  • Binary-only API (no variadic) for CUDA device code compatibility
  • EIGEN_DEVICE_FUNC on all methods

Files:

  • Eigen/src/Core/ConcatOp.h — expression class, traits, evaluator, hcat()/vcat() free functions
  • Eigen/src/Core/util/ForwardDeclarations.h — forward declaration
  • Eigen/Core — include directive
  • test/concat.cpp — 13 test suites (1062 lines)
  • test/CMakeLists.txt — test registration

Test plan

Local Docker (GCC 15, CMake 3.31, Debian trixie, C++17):

# Test suite What it covers
1 test_concat_dynamic Dynamic-size vcat/hcat with float, double, complex float; different-sized operands
2 test_concat_with_expressions Scalar multiply, sum/diff, transpose, block expression inputs
3 test_concat_fixed Fixed-size matrices; compile-time RowsAtCompileTime/ColsAtCompileTime verification
4 test_concat_mixed_fixed_dynamic Fixed+dynamic → Dynamic rows; size_prefer_fixed cols propagation
5 test_concat_rvalue_temporaries Product temporaries, additive temporaries, auto storage, nested chains
6 test_concat_chained vcat(vcat(a,b),c), hcat(hcat(a,b),c), mixed vcat→hcat, 4-way chain
7 test_concat_vectors Column vectors, row vectors, fixed-size Vector3+Vector4, RowVector3+RowVector4
8 test_concat_array Dynamic/fixed-size Arrays, coefficient-wise expression inputs, XprKind propagation
9 test_concat_coeff_access Element-by-element verification of every coefficient
10 test_concat_in_expressions Matrix multiply on concat result, .sum(), .squaredNorm(), assignment to block
11 test_concat_single_row_col Single-row vcat, single-column hcat, 1×1 matrices
12 test_concat_row_major RowMajor+RowMajor, RowMajor+ColMajor, fixed-size RowMajor
13 test_concat_self Self-concat vcat(a,a), hcat(a,a), vector self-concat, self-expression concat

Results: 13/13 test suites pass, 0 compiler warnings (GCC 15 -Wall -Wextra), each suite tested with both float and double.

Also verified no regressions in basicstuff, product_small, block tests.

Addresses #2691

Edited by Pavel Guzenfeld

Merge request reports

Loading