|
From: <in...@dn...> - 2006-01-19 08:22:42
|
Author: marcus
Date: 2006-01-19 03:22:30 -0500 (Thu, 19 Jan 2006)
New Revision: 177
Modified:
trunk/LinearAlgebra/Decomposition/LU.cs
trunk/LinearAlgebra/Decomposition/QR.cs
Log:
added size checks.
Modified: trunk/LinearAlgebra/Decomposition/LU.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/LU.cs 2006-01-18 16:12:15 UTC (rev 176)
+++ trunk/LinearAlgebra/Decomposition/LU.cs 2006-01-19 08:22:30 UTC (rev 177)
@@ -23,6 +23,7 @@
{
#region Fields
private ILU decomp;
+ private int readonly order;
#endregion Fields
#region Constructor
@@ -48,11 +49,12 @@
{
decomp = new DenseLU(matrix);
}
- //add other types, such as sparse here.
+ //add other types, such as sparse here.
else
{
decomp = new DenseLU(matrix);
}
+ order = matrix.Rows;
}
#endregion Constructor
@@ -88,6 +90,10 @@
{
throw new ArgumentNullException("result", Strings.NullParameterException);
}
+ if (result.Rows != order || result.Columns != order)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
decomp.LowerFactor(result);
}
@@ -113,6 +119,10 @@
{
throw new ArgumentNullException("result", Strings.NullParameterException);
}
+ if (result.Rows != order || result.Columns != order)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
decomp.UpperFactor(result);
}
@@ -180,6 +190,10 @@
{
throw new ArgumentNullException("result", Strings.NullParameterException);
}
+ if (result.Rows != order || result.Columns != order)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
if (IsSingular)
{
Modified: trunk/LinearAlgebra/Decomposition/QR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-18 16:12:15 UTC (rev 176)
+++ trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-19 08:22:30 UTC (rev 177)
@@ -19,6 +19,8 @@
#region Fields
private IQR decomp;
+ private readonly int rows;
+ private readonly int columns;
#endregion Fields
@@ -44,6 +46,8 @@
{
decomp = new DenseQR(matrix);
}
+ rows = matrix.Rows;
+ columns = matrix.Columns;
}
#endregion Constructor
@@ -78,6 +82,10 @@
{
throw new ArgumentNullException("result", Strings.NullParameterException);
}
+ if (result.Rows != rows || result.Columns != rows)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
decomp.Q(result);
}
@@ -91,6 +99,11 @@
{
throw new ArgumentNullException("result", Strings.NullParameterException);
}
+ if (result.Rows != rows || result.Columns != columns)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
+
decomp.R(result);
}
|