|
From: <in...@dn...> - 2006-01-25 12:50:56
|
Author: marcus
Date: 2006-01-25 07:50:47 -0500 (Wed, 25 Jan 2006)
New Revision: 192
Modified:
trunk/LinearAlgebra/Decomposition/DenseCholesky.cs
trunk/LinearAlgebra/Decomposition/DenseLU.cs
trunk/LinearAlgebra/Decomposition/DenseQR.cs
trunk/LinearAlgebra/Decomposition/DenseSvd.cs
trunk/LinearAlgebra/Decomposition/ICholesky.cs
Log:
made corrections as suggested in code review ticket #38.
Modified: trunk/LinearAlgebra/Decomposition/DenseCholesky.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseCholesky.cs 2006-01-25 12:38:37 UTC (rev 191)
+++ trunk/LinearAlgebra/Decomposition/DenseCholesky.cs 2006-01-25 12:50:47 UTC (rev 192)
@@ -10,16 +10,26 @@
namespace dnAnalytics.LinearAlgebra.Decomposition
{
+
+ /// <summary>
+ /// The Compute method locks the object and call InteranlCompute. InternalCompute will
+ /// decompse the matrix, overwritting the current matrix with the decomposition, and sets the
+ /// the value of isPositiveDefinite.
+ /// </summary>
internal sealed class DenseCholesky : Algorithm, ICholesky
{
#region Fields
- private bool ispd = false;
+ private bool isPositiveDefinite = false;
private DenseMatrix matrix;
#endregion Fields
#region Constructor
+ /// <summary>
+ /// Constructs a DenseCholesky object.
+ /// </summary>
+ /// <param name="matrix">The matrix to decompose.</param>
public DenseCholesky(Matrix matrix)
{
if (matrix == null)
@@ -37,60 +47,53 @@
#endregion Constructor
- #region Properties
-
-
- #endregion Properties
-
#region Public Methods
+ ///<summary>Return a value indicating whether the matrix is positive definite.</summary>
+ ///<returns><c>true</c> if the matrix is positive definite; otherwise, <c>false</c>.</returns>
public bool IsPositiveDefinite()
{
Compute();
- return ispd;
+ return isPositiveDefinite;
}
+ ///<summary>Returns the Cholesky factored matrix (lower triangular form).</summary>
+ ///<returns>The lower triangular Cholesky factored matrix.</returns>
+ ///<exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
public Matrix Factor()
{
Compute();
- if (!ispd)
+ if (!isPositiveDefinite)
{
throw new NotPositiveDefiniteException();
}
return matrix.Clone();
}
+ /// <summary>
+ /// Copies the Cholesky factored matrix (lower triangular form) into the result <see cref="Matrix"/>.
+ /// </summary>
+ /// <param name="result">The <see cref="Matrix"/> store factored matrix into.</param>
+ /// <exception cref="ArgumentNullException">If <paramref name="result"/> is <c>null</c>.</exception>
+ /// <exception cref="NotSquareMatrixException">If <paramref name="result"/> is not a square matrix.</exception>
+ /// <exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
public void Factor(Matrix result)
{
Compute();
- if (!ispd)
+ if (!isPositiveDefinite)
{
throw new NotPositiveDefiniteException();
}
- for (int i = 0; i < result.Rows; i++)
- {
- for (int j = 0; j < result.Columns; j++)
- {
- result.ValueAt(i, j, matrix.ValueAt(i, j));
- }
- }
+ matrix.CopyTo(result);
}
-
- public void Factor(DenseMatrix result)
- {
- Compute();
- if (!ispd)
- {
- throw new NotPositiveDefiniteException();
- }
- Buffer.BlockCopy(matrix.data, 0, result.data, 0, matrix.data.Length * Constants.SizeOfDouble);
- }
-
+ /// <summary>Calculates the determinant of the matrix.</summary>
+ /// <returns>The determinant of the matrix.</returns>
+ /// <exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
public double Determinant()
{
Compute();
- if (!ispd)
+ if (!isPositiveDefinite)
{
throw new NotPositiveDefiniteException();
}
@@ -114,7 +117,7 @@
int ret = matrix.lapack.CholeskyFactor(matrix.Rows, matrix.data);
if (ret == 0)
{
- ispd = true;
+ isPositiveDefinite = true;
}
}
Modified: trunk/LinearAlgebra/Decomposition/DenseLU.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseLU.cs 2006-01-25 12:38:37 UTC (rev 191)
+++ trunk/LinearAlgebra/Decomposition/DenseLU.cs 2006-01-25 12:50:47 UTC (rev 192)
@@ -15,6 +15,11 @@
namespace dnAnalytics.LinearAlgebra.Decomposition
{
+ /// <summary>
+ /// The Compute method locks the object and call InteranlCompute. InternalCompute will
+ /// decompose the matrix, overwritting the current matrix with the decomposition, and sets the
+ /// the value of l1Norm, infNorm, and pivots.
+ /// </summary>
internal sealed class DenseLU : Algorithm, ILU
{
#region Fields
Modified: trunk/LinearAlgebra/Decomposition/DenseQR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-25 12:38:37 UTC (rev 191)
+++ trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-25 12:50:47 UTC (rev 192)
@@ -12,7 +12,9 @@
namespace dnAnalytics.LinearAlgebra.Decomposition
{
/// <summary>
- /// Computes the QR decomposition of a dense <see cref="Matrix"/>.
+ /// The Compute method locks the object and call InteranlCompute. InternalCompute will
+ /// decompose the matrix, overwritting the current matrix with the decomposition, and sets the
+ /// the value of q, det and isFullRank.
/// </summary>
internal sealed class DenseQR : Algorithm, IQR
{
Modified: trunk/LinearAlgebra/Decomposition/DenseSvd.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseSvd.cs 2006-01-25 12:38:37 UTC (rev 191)
+++ trunk/LinearAlgebra/Decomposition/DenseSvd.cs 2006-01-25 12:50:47 UTC (rev 192)
@@ -15,7 +15,9 @@
namespace dnAnalytics.LinearAlgebra.Decomposition
{
/// <summary>
- /// Class for computing the Singular Value Decomposition of a <see cref="Matrix"/>.
+ /// The Compute method locks the object and call InteranlCompute. InternalCompute will
+ /// decompose the matrix, set the values of u,v,s, and rank. It will will also set the
+ /// intial matrix to null.
/// </summary>
internal sealed class DenseSvd : Algorithm, ISvd
{
Modified: trunk/LinearAlgebra/Decomposition/ICholesky.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/ICholesky.cs 2006-01-25 12:38:37 UTC (rev 191)
+++ trunk/LinearAlgebra/Decomposition/ICholesky.cs 2006-01-25 12:50:47 UTC (rev 192)
@@ -12,13 +12,13 @@
///<summary>Interface to compute the Cholesky factorization of a n by n <see cref="Matrix"/>.</summary>
internal interface ICholesky : IAlgorithm
{
- ///<summary>Return a value indicating whether the matrix is positive definite.</summary>
- ///<returns><c>true</c> if the matrix is positive definite; otherwise, <c>false</c>.</returns>
+ /// <summary>Return a value indicating whether the matrix is positive definite.</summary>
+ /// <returns><c>true</c> if the matrix is positive definite; otherwise, <c>false</c>.</returns>
bool IsPositiveDefinite();
- ///<summary>Returns the Cholesky factored matrix (lower triangular form).</summary>
- ///<returns>The lower triangular Cholesky factored matrix.</returns>
- ///<exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
+ /// <summary>Returns the Cholesky factored matrix (lower triangular form).</summary>
+ /// <returns>The lower triangular Cholesky factored matrix.</returns>
+ /// <exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
Matrix Factor();
/// <summary>
@@ -27,12 +27,12 @@
/// <param name="result">The <see cref="Matrix"/> store factored matrix into.</param>
/// <exception cref="ArgumentNullException">If <paramref name="result"/> is <c>null</c>.</exception>
/// <exception cref="NotSquareMatrixException">If <paramref name="result"/> is not a square matrix.</exception>
- ///<exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
+ /// <exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
void Factor(Matrix result);
- ///<summary>Calculates the determinant of the matrix.</summary>
- ///<returns>The determinant of the matrix.</returns>
- ///<exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
+ /// <summary>Calculates the determinant of the matrix.</summary>
+ /// <returns>The determinant of the matrix.</returns>
+ /// <exception cref="NotPositiveDefiniteException">If the matrix is not positive definite.</exception>
double Determinant();
}
}
|