|
From: <in...@dn...> - 2006-01-25 08:54:45
|
Author: marcus
Date: 2006-01-25 03:54:33 -0500 (Wed, 25 Jan 2006)
New Revision: 185
Modified:
trunk/LinearAlgebra/Decomposition/Cholesky.cs
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
trunk/LinearAlgebra/Decomposition/ILU.cs
trunk/LinearAlgebra/Decomposition/IQR.cs
trunk/LinearAlgebra/Decomposition/ISvd.cs
trunk/LinearAlgebra/Decomposition/LU.cs
trunk/LinearAlgebra/Decomposition/QR.cs
trunk/LinearAlgebra/Decomposition/Svd.cs
Log:
changed all properties in the decomposition classes to methods, since they all call compute (which can be expensive).
Modified: trunk/LinearAlgebra/Decomposition/Cholesky.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/Cholesky.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/Cholesky.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -55,9 +55,9 @@
///<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
+ public bool IsPositiveDefinite()
{
- get { return decomp.IsPositiveDefinite; }
+ return decomp.IsPositiveDefinite();
}
///<summary>Returns the Cholesky factored matrix (lower triangular form).</summary>
Modified: trunk/LinearAlgebra/Decomposition/DenseCholesky.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseCholesky.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/DenseCholesky.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -38,19 +38,18 @@
#endregion Constructor
#region Properties
- public bool IsPositiveDefinite
- {
- get
- {
- Compute();
- return ispd;
- }
- }
+
#endregion Properties
#region Public Methods
+ public bool IsPositiveDefinite()
+ {
+ Compute();
+ return ispd;
+ }
+
public Matrix Factor()
{
Compute();
Modified: trunk/LinearAlgebra/Decomposition/DenseLU.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseLU.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/DenseLU.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -58,14 +58,11 @@
/// <summary>
/// Returns a value indicating whether the matrix is singular.
/// </summary>
- /// <value><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</value>
- public bool IsSingular
+ /// <returns><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</returns>
+ public bool IsSingular()
{
- get
- {
- Compute();
- return singular;
- }
+ Compute();
+ return singular;
}
Matrix ILU.LowerFactor()
@@ -148,74 +145,66 @@
/// <summary>
/// The determinant of the matrix.
/// </summary>
- public double Determinant
+ /// <returns>The determinant of the matrix.</returns>
+ public double Determinant()
{
- get
+ Compute();
+ if (singular)
{
- Compute();
- if (singular)
+ return 0;
+ }
+ if (det == Double.MinValue)
+ {
+ det = 1.0;
+ for (int j = 0; j < matrix.Rows; j++)
{
- return 0;
- }
- if (det == Double.MinValue)
- {
- det = 1.0;
- for (int j = 0; j < matrix.Rows; j++)
+ if (pivots[j] != j)
{
- if (pivots[j] != j)
- {
- det = -det * matrix.data[j * matrix.Rows + j];
- }
- else
- {
- det *= matrix.data[j * matrix.Rows + j];
- }
+ det = -det * matrix.data[j * matrix.Rows + j];
}
+ else
+ {
+ det *= matrix.data[j * matrix.Rows + j];
+ }
}
- return det;
}
+ return det;
}
/// <summary>
/// The L1 norm condition number of the matrix. The number is calculated as ||A|| * ||AInverse|| where ||.|| is the L1 norm.
/// </summary>
- public double L1NormConditionNumber
+ public double L1NormConditionNumber()
{
- get
+ Compute();
+ if (singular)
{
- Compute();
- if (singular)
- {
- return Double.PositiveInfinity;
- }
- if (l1Condition == Double.MinValue)
- {
- l1Condition = matrix.lapack.ConditionNumber('1', matrix.Rows, l1Norm, matrix.data, pivots);
- }
-
- return l1Condition;
+ return Double.PositiveInfinity;
}
+ if (l1Condition == Double.MinValue)
+ {
+ l1Condition = matrix.lapack.ConditionNumber('1', matrix.Rows, l1Norm, matrix.data, pivots);
+ }
+
+ return l1Condition;
}
/// <summary>
/// The infinity norm condition number of the matrix. The number is calculated as ||A|| * ||AInverse|| where ||.|| is the infinity norm.
/// </summary>
- public double InfinityNormConditionNumber
+ public double InfinityNormConditionNumber()
{
- get
+ Compute();
+ if (singular)
{
- Compute();
- if (singular)
- {
- return Double.PositiveInfinity;
- }
- if (infCondition == Double.MinValue)
- {
- infCondition = matrix.lapack.ConditionNumber('I', matrix.Rows, infNorm, matrix.data, pivots);
- }
-
- return infCondition;
+ return Double.PositiveInfinity;
}
+ if (infCondition == Double.MinValue)
+ {
+ infCondition = matrix.lapack.ConditionNumber('I', matrix.Rows, infNorm, matrix.data, pivots);
+ }
+
+ return infCondition;
}
Matrix ILU.Inverse()
Modified: trunk/LinearAlgebra/Decomposition/DenseQR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -14,7 +14,7 @@
/// <summary>
/// Computes the QR decomposition of a <see cref="Matrix"/>.
/// </summary>
- public sealed class DenseQR : Algorithm, IQR
+ internal sealed class DenseQR : Algorithm, IQR
{
#region Fields
private bool isFullRank = true;
@@ -113,26 +113,19 @@
Compute();
return det;
}
-
- #endregion Public Methods
-
- #region Public Properties
-
/// <summary>
- /// Determine whether the matrix is full rank or not
+ /// Determine whether the matrix is full rank or not.
/// </summary>
- /// <value>Boolean value indicates whether the given matrix is full rank or not</value>
- public bool IsFullRank
+ /// <returns>Boolean value indicates whether the given matrix is full rank or not.</returns>
+ public bool IsFullRank()
{
- get
- {
- Compute();
- return isFullRank;
- }
+ Compute();
+ return isFullRank;
}
- #endregion Public Properties
+ #endregion Public Methods
+
#region Protected Members
/// <summary>
Modified: trunk/LinearAlgebra/Decomposition/DenseSvd.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseSvd.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/DenseSvd.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -17,7 +17,7 @@
/// <summary>
/// Class for computing the Singular Value Decomposition of a <see cref="Matrix"/>.
/// </summary>
- public sealed class DenseSvd : Algorithm, ISvd
+ internal sealed class DenseSvd : Algorithm, ISvd
{
#region Fields
private readonly bool computeVectors;
@@ -55,37 +55,28 @@
#region Properties
///<summary>Returns the two norm of the <see cref="Matrix"/>.</summary>
- ///<value>The two norm of the <see cref="Matrix"/>.</value>
- public double Norm2
+ ///<returns>The two norm of the <see cref="Matrix"/>.</returns>
+ public double Norm2()
{
- get
- {
- Compute();
- return s[0];
- }
+ Compute();
+ return s[0];
}
///<summary>Returns the condition number <c>max(S) / min(S)</c>.</summary>
- ///<value>The condition number.</value>
- public double ConditionNumber
+ ///<returns>The condition number.</returns>
+ public double ConditionNumber()
{
- get
- {
- Compute();
- int tmp = System.Math.Min(rows, columns) - 1;
- return s[0] / s[tmp];
- }
+ Compute();
+ int tmp = System.Math.Min(rows, columns) - 1;
+ return s[0] / s[tmp];
}
///<summary>Returns the effective numerical matrix rank.</summary>
- ///<value>The number of non-negligible singular values.</value>
- public int Rank
+ ///<returns>The number of non-negligible singular values.</returns>
+ public int Rank()
{
- get
- {
- Compute();
- return rank;
- }
+ Compute();
+ return rank;
}
#endregion Properties
Modified: trunk/LinearAlgebra/Decomposition/ICholesky.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/ICholesky.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/ICholesky.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -13,8 +13,8 @@
internal interface ICholesky : IAlgorithm
{
///<summary>Return a value indicating whether the matrix is positive definite.</summary>
- ///<value><c>true</c> if the matrix is positive definite; otherwise, <c>false</c>.</value>
- bool IsPositiveDefinite { get; }
+ ///<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>
Modified: trunk/LinearAlgebra/Decomposition/ILU.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/ILU.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/ILU.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -21,8 +21,8 @@
/// <summary>
/// Returns a value indicating whether the matrix is singular.
/// </summary>
- /// <value><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</value>
- bool IsSingular { get;}
+ /// <returns><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</returns>
+ bool IsSingular();
/// <summary>
/// Returns the lower factor of the factorization.
@@ -55,7 +55,8 @@
/// <summary>
/// The determinant of the matrix.
/// </summary>
- double Determinant { get; }
+ /// <returns>The determinant of the matrix.</returns>
+ double Determinant();
/// <summary>
/// Returns the inverse of the matrix.
@@ -83,13 +84,14 @@
/// Estimates the reciprocal the L1 norm condition number of the matrix. The number is calculated
/// as ||A|| * ||AInverse|| where ||.|| is the L1 norm.
/// </summary>
- double L1NormConditionNumber { get; }
+ /// <returns>The reciprocal the L1 norm condition number of the matrix</returns>
+ double L1NormConditionNumber();
/// <summary>
/// Estimates the reciprocal the infinity norm condition number of the matrix. The number is calculated
/// as ||A|| * ||AInverse|| where ||.|| is the infinity norm.
/// </summary>
- double InfinityNormConditionNumber { get; }
-
+ /// <returns>The reciprocal the infinity norm condition number of the matrix</returns>
+ double InfinityNormConditionNumber();
}
}
Modified: trunk/LinearAlgebra/Decomposition/IQR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/IQR.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/IQR.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -21,8 +21,8 @@
/// <summary>
/// Determine whether the matrix is full rank or not.
/// </summary>
- /// <value>Boolean value indicates whether the given matrix is full rank or not.</value>
- bool IsFullRank { get; }
+ /// <returns>Boolean value indicates whether the given matrix is full rank or not.</returns>
+ bool IsFullRank();
/// <summary>
/// Returns the orthogonal Q matrix.
Modified: trunk/LinearAlgebra/Decomposition/ISvd.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/ISvd.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/ISvd.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -71,16 +71,16 @@
void S(Vector result);
///<summary>Returns the two norm of the <see cref="Matrix"/>.</summary>
- ///<value>The two norm of the <see cref="Matrix"/>.</value>
- double Norm2 { get; }
+ ///<returns>The two norm of the <see cref="Matrix"/>.</returns>
+ double Norm2();
///<summary>Returns the condition number <c>max(S) / min(S)</c>.</summary>
- ///<value>The condition number.</value>
- double ConditionNumber { get; }
+ ///<returns>The condition number.</returns>
+ double ConditionNumber();
///<summary>Returns the effective numerical matrix rank.</summary>
- ///<value>The number of non-negligible singular values.</value>
- int Rank { get; }
+ ///<returns>The number of non-negligible singular values.</returns>
+ int Rank();
}
}
Modified: trunk/LinearAlgebra/Decomposition/LU.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/LU.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/LU.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -56,10 +56,10 @@
/// <summary>
/// Returns a value indicating whether the matrix is singular.
/// </summary>
- /// <value><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</value>
- public bool IsSingular
+ /// <returns><c>true</c> if the matrix is singular; otherwise, <c>false</c>.</returns>
+ public bool IsSingular()
{
- get { return decomp.IsSingular; }
+ return decomp.IsSingular();
}
/// <summary>
@@ -123,12 +123,10 @@
/// <summary>
/// The determinant of the matrix.
/// </summary>
- public double Determinant
+ /// <returns>The determinant of the matrix.</returns>
+ public double Determinant()
{
- get
- {
- return decomp.Determinant;
- }
+ return decomp.Determinant();
}
@@ -136,24 +134,20 @@
/// Estimates the reciprocal the L1 norm condition number of the matrix. The number is calculated
/// as ||A|| * ||AInverse|| where ||.|| is the L1 norm.
/// </summary>
- public double L1NormConditionNumber
+ /// <returns>The reciprocal of the L1 norm condition number (estimated) of the matrix.</returns>
+ public double L1NormConditionNumber()
{
- get
- {
- return decomp.L1NormConditionNumber;
- }
+ return decomp.L1NormConditionNumber();
}
/// <summary>
/// Estimates the reciprocal the infinity norm condition number of the matrix. The number is calculated
/// as ||A|| * ||AInverse|| where ||.|| is the infinity norm.
/// </summary>
- public double InfinityNormConditionNumber
+ /// <returns>The reciprocal of the infinity norm condition number (estimated) of the matrix.</returns>
+ public double InfinityNormConditionNumber()
{
- get
- {
- return decomp.InfinityNormConditionNumber;
- }
+ return decomp.InfinityNormConditionNumber();
}
/// <summary>
@@ -163,7 +157,7 @@
/// <exception cref="SingularMatrixException">If the matrix is singular.</exception>
public Matrix Inverse()
{
- if (IsSingular)
+ if (IsSingular())
{
throw new SingularMatrixException();
}
@@ -188,7 +182,7 @@
throw new NotConformableException("result", Strings.ParameterNotConformable);
}
- if (IsSingular)
+ if (IsSingular())
{
throw new SingularMatrixException();
}
Modified: trunk/LinearAlgebra/Decomposition/QR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -106,13 +106,10 @@
/// <summary>
/// Determine whether the matrix is full rank or not.
/// </summary>
- /// <value>Boolean value indicates whether the given matrix is full rank or not.</value>
- public bool IsFullRank
+ /// <returns>Boolean value indicates whether the given matrix is full rank or not.</returns>
+ public bool IsFullRank()
{
- get
- {
- return decomp.IsFullRank;
- }
+ return decomp.IsFullRank();
}
Modified: trunk/LinearAlgebra/Decomposition/Svd.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/Svd.cs 2006-01-25 03:50:51 UTC (rev 184)
+++ trunk/LinearAlgebra/Decomposition/Svd.cs 2006-01-25 08:54:33 UTC (rev 185)
@@ -50,34 +50,26 @@
#region Properties
///<summary>Returns the two norm of the <see cref="Matrix"/>.</summary>
- ///<value>The two norm of the <see cref="Matrix"/>.</value>
- public double Norm2
+ ///<returns>The 2-norm of the <see cref="Matrix"/>.</returns>
+ public double Norm2()
{
- get
- {
- return decomp.Norm2;
- }
+ return decomp.Norm2();
}
///<summary>Returns the condition number <c>max(S) / min(S)</c>.</summary>
- ///<value>The condition number.</value>
- public double ConditionNumber
+ ///<returns>The condition number.</returns>
+ public double ConditionNumber()
{
- get
- {
- return decomp.ConditionNumber;
- }
+ return decomp.ConditionNumber();
}
///<summary>Returns the effective numerical matrix rank.</summary>
- ///<value>The number of non-negligible singular values.</value>
- public int Rank
+ ///<returns>The number of non-negligible singular values.</returns>
+ public int Rank()
{
- get
- {
- return decomp.Rank;
- }
+ return decomp.Rank();
}
+
#endregion Properties
#region Public Methods
|