From eec1e40c258156827cae846be66f5c6a82d30444 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 01:38:56 +0200 Subject: [PATCH] cultmath: pin that a fixed column is never released Co-Authored-By: Claude Sonnet 5 --- .../tests/CultMath.Tests/BoundedLeastSquaresTests.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs b/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs index 653b9158..6cf65fd4 100644 --- a/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/BoundedLeastSquaresTests.cs @@ -292,15 +292,17 @@ public sealed class BoundedLeastSquaresTests } [Fact] - public void FixedColumnStaysPut() + public void FixedColumnStaysPutEvenWhenItsGradientWantsOut() { const int m = 5, n = 3; - var lo = new[] { -1f, 0.25f, -1f }; - var hi = new[] { 1f, 0.25f, 1f }; + var lo = new[] { -1f, -1f, -1f }; + var hi = new[] { 1f, -1f, 1f }; var x = new float[n]; - var status = Solve(m, n, A54, B5, lo, hi, x, out _); + var status = Solve(m, n, A54, B5, lo, hi, x, out var iterations); Assert.Equal(BoundedLeastSquaresStatus.Converged, status); - Assert.Equal(0.25f, x[1]); + Assert.Equal(-1f, x[1]); + Assert.True(Gradient(m, n, A54, B5, x)[1] < -1e-3, "fixture must pull the fixed column inward"); + Assert.Equal(0, iterations); AssertKkt(m, n, A54, B5, lo, hi, x); }