From 4e728758afd54d7203151d58b85bd1dd30e12abc Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Fri, 28 Aug 2026 11:00:51 +0200 Subject: [PATCH 1/2] Fix SIMD assignment to xfunctor_view destinations (#2892) xt::real(e) = w failed to compile with XTENSOR_USE_XSIMD: the SIMD gate only probed load_simd, but the linear assigner also needs data() on the destination, which functor views lack. Gate the SIMD paths on data_interface_expression instead; functor views fall back to scalar assignment while containers keep the SIMD path. Adds a regression test (test_xcomplex.assign_to_real_part). --- include/xtensor/core/xassign.hpp | 3 ++- test/test_xcomplex.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/xtensor/core/xassign.hpp b/include/xtensor/core/xassign.hpp index 174ddcdc0..f9a05b183 100644 --- a/include/xtensor/core/xassign.hpp +++ b/include/xtensor/core/xassign.hpp @@ -392,7 +392,8 @@ namespace xt static constexpr bool simd_interface() { - return has_simd_interface() + return data_interface_expression + && has_simd_interface() && has_simd_interface(); } diff --git a/test/test_xcomplex.cpp b/test/test_xcomplex.cpp index 920d21b8e..43d1f856a 100644 --- a/test/test_xcomplex.cpp +++ b/test/test_xcomplex.cpp @@ -319,6 +319,16 @@ namespace xt EXPECT_EQ(a(4, 4), cmplx(-123.321L, -123.321L)); } + TEST(xcomplex, assign_to_real_part) + { + using cpx = std::complex; + xt::xtensor a = {cpx(1, 2), cpx(3, 4), cpx(5, 6), cpx(7, 8), cpx(9, 10)}; + xt::xtensor wr = {11, 12, 13, 14, 15}; + xt::real(a) = wr; + xt::xtensor expected = {cpx(11, 2), cpx(12, 4), cpx(13, 6), cpx(14, 8), cpx(15, 10)}; + EXPECT_EQ(a, expected); + } + TEST(xcomplex, build_from_double) { xt::xarray r = {1., 2., 3.}; From 4597ce51e1aa4a40d6ac912a22a35b83f96a36f1 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Fri, 28 Aug 2026 11:41:50 +0200 Subject: [PATCH 2/2] formatting --- include/xtensor/core/xassign.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/xtensor/core/xassign.hpp b/include/xtensor/core/xassign.hpp index f9a05b183..e305b19c7 100644 --- a/include/xtensor/core/xassign.hpp +++ b/include/xtensor/core/xassign.hpp @@ -392,8 +392,7 @@ namespace xt static constexpr bool simd_interface() { - return data_interface_expression - && has_simd_interface() + return data_interface_expression && has_simd_interface() && has_simd_interface(); }