From 95fe9321dbbd056827814fb9d37d62092cbc7280 Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Sun, 4 Jul 2010 21:43:00 +0800 Subject: [PATCH] tweaked work[0] return value --- .../LinearAlgebra/ManagedLinearAlgebraProvider.cs | 7 ++++++- src/Numerics/Properties/Resources.Designer.cs | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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); + } + } } }