diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs index d65226ad..cf2b3287 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs @@ -1053,6 +1053,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra { ComputeQR(work, i, q, rRows, i, rRows - 1, i, rRows - 1); } + + work[0] = rRows * rRows; } #region QR Factor Helper functions @@ -1265,11 +1267,14 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra if (work.Length < rRows * rRows) { - throw new ArgumentException(Resources.ArgumentArraysSameLength, "work"); + work[0] = rRows * rRows; + throw new ArgumentException(Resources.WorkArrayTooSmall, "work"); } QRFactor(r, rRows, rColumns, q, work); QRSolveFactored(q, r, rRows, rColumns, b, bColumns, x); + + work[0] = rRows * rRows; } /// diff --git a/src/Numerics/Properties/Resources.Designer.cs b/src/Numerics/Properties/Resources.Designer.cs index a68693ba..232ead8c 100644 --- a/src/Numerics/Properties/Resources.Designer.cs +++ b/src/Numerics/Properties/Resources.Designer.cs @@ -635,5 +635,14 @@ namespace MathNet.Numerics.Properties { return ResourceManager.GetString("UserDefinedProviderNotSpecified", resourceCulture); } } + + /// + /// Looks up a localized string similar to The given work array is too small. Check work[0] for the corret size.. + /// + internal static string WorkArrayTooSmall { + get { + return ResourceManager.GetString("WorkArrayTooSmall", resourceCulture); + } + } } }