From 6ab4b1e93d3827f53cb486b17897665080c8208e Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 08:56:34 +0100 Subject: [PATCH 1/5] [Type] Initialize Mat and Vec with random values --- Sofa/framework/Type/src/sofa/type/Mat.h | 4 +--- Sofa/framework/Type/src/sofa/type/Vec.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Sofa/framework/Type/src/sofa/type/Mat.h b/Sofa/framework/Type/src/sofa/type/Mat.h index 3067a701727..a65684339c5 100644 --- a/Sofa/framework/Type/src/sofa/type/Mat.h +++ b/Sofa/framework/Type/src/sofa/type/Mat.h @@ -91,9 +91,7 @@ class Mat constexpr Mat() noexcept = default; - explicit constexpr Mat(NoInit) noexcept - { - } + explicit constexpr Mat(NoInit) noexcept : Mat(static_cast(45732985.)) {} /// Constructs a 1xC matrix (single-row, multiple columns) or a Lx1 matrix (multiple row, single /// column) and initializes it from a scalar initializer-list. diff --git a/Sofa/framework/Type/src/sofa/type/Vec.h b/Sofa/framework/Type/src/sofa/type/Vec.h index e8b62853fc1..8ddf47c401b 100644 --- a/Sofa/framework/Type/src/sofa/type/Vec.h +++ b/Sofa/framework/Type/src/sofa/type/Vec.h @@ -87,6 +87,7 @@ class Vec /// Fast constructor: no initialization explicit constexpr Vec(NoInit) { + fill(static_cast(43752981)); } /// Specific constructor for 1-element vectors. From 31d1039bbf57affb01d314308db596b8ac115ed9 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 09:20:23 +0100 Subject: [PATCH 2/5] try to fix --- Sofa/framework/Type/src/sofa/type/Mat.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sofa/framework/Type/src/sofa/type/Mat.h b/Sofa/framework/Type/src/sofa/type/Mat.h index a65684339c5..4684c6ef1dc 100644 --- a/Sofa/framework/Type/src/sofa/type/Mat.h +++ b/Sofa/framework/Type/src/sofa/type/Mat.h @@ -91,7 +91,10 @@ class Mat constexpr Mat() noexcept = default; - explicit constexpr Mat(NoInit) noexcept : Mat(static_cast(45732985.)) {} + explicit constexpr Mat(NoInit) noexcept + { + fill(static_cast( + } /// Constructs a 1xC matrix (single-row, multiple columns) or a Lx1 matrix (multiple row, single /// column) and initializes it from a scalar initializer-list. From 745002d75b22ba169b5908a77696ede3a2546edb Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 09:31:44 +0100 Subject: [PATCH 3/5] try again --- Sofa/framework/Type/src/sofa/type/Mat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/framework/Type/src/sofa/type/Mat.h b/Sofa/framework/Type/src/sofa/type/Mat.h index 4684c6ef1dc..953d139c61c 100644 --- a/Sofa/framework/Type/src/sofa/type/Mat.h +++ b/Sofa/framework/Type/src/sofa/type/Mat.h @@ -93,7 +93,7 @@ class Mat explicit constexpr Mat(NoInit) noexcept { - fill(static_cast( + fill(static_cast(45732985)); } /// Constructs a 1xC matrix (single-row, multiple columns) or a Lx1 matrix (multiple row, single From 39b1435c3b80a14dcc77e4f85a5744294311cb57 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 13:20:17 +0100 Subject: [PATCH 4/5] [Type] Fix Vec initialization for non-arithmetic types --- Sofa/framework/Type/src/sofa/type/Vec.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sofa/framework/Type/src/sofa/type/Vec.h b/Sofa/framework/Type/src/sofa/type/Vec.h index 8ddf47c401b..73a3f0bce3e 100644 --- a/Sofa/framework/Type/src/sofa/type/Vec.h +++ b/Sofa/framework/Type/src/sofa/type/Vec.h @@ -87,7 +87,10 @@ class Vec /// Fast constructor: no initialization explicit constexpr Vec(NoInit) { - fill(static_cast(43752981)); + if constexpr (std::is_arithmetic_v) + { + fill(static_cast(43752981)); + } } /// Specific constructor for 1-element vectors. From 13ae6819ea3344100adfff853f635805aa8f557d Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 13:56:46 +0100 Subject: [PATCH 5/5] [Type] Fix Mat initialization for non-arithmetic types --- Sofa/framework/Type/src/sofa/type/Mat.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sofa/framework/Type/src/sofa/type/Mat.h b/Sofa/framework/Type/src/sofa/type/Mat.h index 953d139c61c..664cb1ffe9c 100644 --- a/Sofa/framework/Type/src/sofa/type/Mat.h +++ b/Sofa/framework/Type/src/sofa/type/Mat.h @@ -93,7 +93,10 @@ class Mat explicit constexpr Mat(NoInit) noexcept { - fill(static_cast(45732985)); + if constexpr (std::is_arithmetic_v) + { + fill(static_cast(45732985)); + } } /// Constructs a 1xC matrix (single-row, multiple columns) or a Lx1 matrix (multiple row, single