|
From: <in...@dn...> - 2006-01-18 16:12:38
|
Author: marcus
Date: 2006-01-18 11:12:15 -0500 (Wed, 18 Jan 2006)
New Revision: 176
Added:
trunk/LinearAlgebra/Decomposition/DenseQR.cs
trunk/LinearAlgebra/Decomposition/QR.cs
trunk/TestMatrices/random_real_general_array_20_10.matrix_market
Modified:
trunk/LinearAlgebra/Decomposition/Householder.cs
trunk/LinearAlgebra/Decomposition/IQR.cs
trunk/LinearAlgebra/DenseMatrix.cs
trunk/LinearAlgebra/DenseVector.cs
trunk/LinearAlgebra/ManagedBlas.cs
trunk/LinearAlgebra/ManagedLapack.cs
trunk/LinearAlgebra/NativeBlas.cs
trunk/LinearAlgebra/NativeLapack.cs
trunk/NumericalLibrary.csproj
trunk/Settings.cs
trunk/UnitTests/LinearAlgebra/AbstractVectorTest.cs
trunk/UnitTests/LinearAlgebra/Decomposition/AbstractLUTest.cs
trunk/UnitTests/UnitTests.csproj
Log:
finished QR classes.
fixed a blas multiply bug.
fixed a native blas addition and subtraction bug.
Added: trunk/LinearAlgebra/Decomposition/DenseQR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/Decomposition/DenseQR.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -0,0 +1,163 @@
+/*
+* DenseQR.cs
+*
+* Copyright (c) 2006, dnAnalytics. All rights reserved.
+*/
+
+using System;
+using dnAnalytics.Math;
+using dnAnalytics.Resources;
+using dnAnalytics.Exceptions;
+
+namespace dnAnalytics.LinearAlgebra.Decomposition
+{
+ /// <summary>
+ /// Computes the QR decomposition of a <see cref="Matrix"/>.
+ /// </summary>
+ public sealed class DenseQR : Algorithm, IQR
+ {
+ #region Fields
+ private bool isFullRank = true;
+ private double det = 1;
+ private DenseMatrix r;
+ private DenseMatrix q;
+ #endregion Fields
+
+ #region Constructor
+ /// <summary>
+ /// Constructs an QR object for the given matrix.
+ /// </summary>
+ /// <param name="matrix">The matrix to factor.</param>
+ /// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception>
+ public DenseQR(Matrix matrix)
+ {
+ if (matrix == null)
+ {
+ throw new ArgumentNullException("matrix", Strings.NullParameterException);
+ }
+ this.r = (DenseMatrix)matrix.Clone();
+ }
+
+ #endregion Constructor
+
+ #region Public Methods
+
+ /// <summary>
+ /// Returns the orthogonal Q matrix.
+ /// </summary>
+ /// <returns>The orthogonal Q matrix</returns>
+ public Matrix Q()
+ {
+ Compute();
+ return q;
+ }
+
+ /// <summary>
+ /// Returns the upper triangular factor R.
+ /// </summary>
+ /// <returns>The upper triangular factor R</returns>
+ public Matrix R()
+ {
+ Compute();
+ return r;
+ }
+
+ /// <summary>
+ /// Copies the orthogonal Q matrix into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy the orthogonal Q matrix into.</param>
+ public void Q(Matrix result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException("result", Strings.NullParameterException);
+ }
+
+ if (result.Rows != q.Rows || result.Columns != q.Columns)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
+
+ q.CopyTo(result);
+ }
+
+ /// <summary>
+ /// Copies the upper triangular factor R into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy upper triangular factor R into.</param>
+ public void R(Matrix result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException("result", Strings.NullParameterException);
+ }
+
+ if (result.Rows != r.Rows || result.Columns != r.Columns)
+ {
+ throw new NotConformableException("result", Strings.ParameterNotConformable);
+ }
+
+ r.CopyTo(result);
+ }
+
+ #endregion Public Methods
+
+ #region Public Properties
+
+ /// <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
+ {
+ get
+ {
+ Compute();
+ return isFullRank;
+ }
+ }
+
+ ///<summary>Calculates the determinant (absolute value) of the matrix.</summary>
+ ///<value>The determinant of the matrix.</value>
+ ///<exception cref="NotSquareMatrixException">If the matrix is not square.</exception>
+ public double Determinant
+ {
+ get
+ {
+ if (r.Rows != r.Columns)
+ {
+ throw new NotSquareMatrixException();
+ }
+ Compute();
+ return det;
+ }
+ }
+ #endregion Public Properties
+
+ #region Protected Members
+
+ /// <summary>
+ /// Delegates the actual computation to the correct QR subtype.
+ /// </summary>
+ protected override void InternalCompute()
+ {
+ q = (DenseMatrix)MatrixBuilder.CreateMatrix(r.Rows, r.Rows, MatrixType.Dense);
+ r.lapack.QRFactor(r.Rows, r.Columns, q.data, r.data);
+
+ int min = System.Math.Min(r.Rows, r.Columns);
+
+ for (int i = 0; i < min; i++)
+ {
+ det *= r.ValueAt(i, i);
+ if (System.Math.Abs(r.ValueAt(i, i)) <= 1e-15)
+ {
+ isFullRank = false;
+ det = 0;
+ break;
+ }
+ }
+ det = System.Math.Abs(det);
+ }
+ #endregion Protected Members
+ }
+}
Modified: trunk/LinearAlgebra/Decomposition/Householder.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/Householder.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/Decomposition/Householder.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -29,8 +29,8 @@
for (int i = r1; i <= r2; i++)
{
- u[i - r1] = A[c * m + i];// A.ValueAt(i, c);
- A[tmp + i] = 0.0;// A.ValueAt(i, c, 0.0);
+ u[i - r1] = A[tmp + i];
+ A[tmp + i] = 0.0;
}
@@ -92,7 +92,7 @@
{
for (int j = c1; j <= c2; j++)
{
- v[j - c1] = v[j - c1] + u[i - r1] * A[j * m + i];//.ValueAt(i, j);
+ v[j - c1] = v[j - c1] + u[i - r1] * A[j * m + i];
}
}
@@ -100,7 +100,7 @@
{
for (int j = c1; j <= c2; j++)
{
- A[j * m + i] = A[j * m + i] - u[i - r1] * v[j - c1];// A.ValueAt(i, j, (A[i, j] - u[i - r1] * v[j - c1]));
+ A[j * m + i] = A[j * m + i] - u[i - r1] * v[j - c1];
}
}
}
Modified: trunk/LinearAlgebra/Decomposition/IQR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/IQR.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/Decomposition/IQR.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -22,7 +22,7 @@
/// 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();
+ bool IsFullRank { get; }
/// <summary>
/// Returns the orthogonal Q matrix.
@@ -31,14 +31,26 @@
Matrix Q();
/// <summary>
+ /// Copies the orthogonal Q matrix into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy the orthogonal Q matrix into.</param>
+ void Q(Matrix result);
+
+ /// <summary>
/// Returns the upper triangular factor R.
/// </summary>
/// <returns>The upper triangular factor R</returns>
Matrix R();
+ /// <summary>
+ /// Copies the upper triangular factor R into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy upper triangular factor R into.</param>
+ void R(Matrix result);
+
///<summary>Calculates the determinant (absolute value) of the matrix.</summary>
- ///<returns>The determinant of the matrix.</returns>
+ ///<value>The determinant of the matrix.</value>
///<exception cref="NotSquareMatrixException">If the matrix is not square.</exception>
- double Determinant();
+ double Determinant { get; }
}
}
Added: trunk/LinearAlgebra/Decomposition/QR.cs
===================================================================
--- trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/Decomposition/QR.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -0,0 +1,138 @@
+/*
+* QR.cs
+*
+* Copyright (c) 2006, dnAnalytics. All rights reserved.
+*/
+
+using System;
+using dnAnalytics.Math;
+using dnAnalytics.Resources;
+using dnAnalytics.Exceptions;
+
+namespace dnAnalytics.LinearAlgebra.Decomposition
+{
+ /// <summary>
+ /// Computes the QR decomposition of a <see cref="Matrix"/>.
+ /// </summary>
+ public sealed class QR : Algorithm
+ {
+ #region Fields
+
+ private IQR decomp;
+
+ #endregion Fields
+
+ #region Constructor
+ /// <summary>
+ /// Constructs an QR object for the given matrix.
+ /// </summary>
+ /// <param name="matrix">The matrix to factor.</param>
+ /// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception>
+ public QR(Matrix matrix)
+ {
+ if (matrix == null)
+ {
+ throw new ArgumentNullException("matrix", Strings.NullParameterException);
+ }
+
+ if (matrix.GetType() == typeof(DenseMatrix))
+ {
+ decomp = new DenseQR(matrix);
+ }
+ //add other types, such as sparse here.
+ else
+ {
+ decomp = new DenseQR(matrix);
+ }
+ }
+
+ #endregion Constructor
+
+ #region Public Methods
+
+ /// <summary>
+ /// Returns the orthogonal Q matrix.
+ /// </summary>
+ /// <returns>The orthogonal Q matrix</returns>
+ public Matrix Q()
+ {
+ return decomp.Q();
+ }
+
+ /// <summary>
+ /// Returns the upper triangular factor R.
+ /// </summary>
+ /// <returns>The upper triangular factor R</returns>
+ public Matrix R()
+ {
+ return decomp.R();
+ }
+
+ /// <summary>
+ /// Copies the orthogonal Q matrix into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy the orthogonal Q matrix into.</param>
+ public void Q(Matrix result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException("result", Strings.NullParameterException);
+ }
+ decomp.Q(result);
+ }
+
+ /// <summary>
+ /// Copies the upper triangular factor R into the result matrix.
+ /// </summary>
+ /// <param name="result">A matrix to copy upper triangular factor R into.</param>
+ public void R(Matrix result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException("result", Strings.NullParameterException);
+ }
+ decomp.R(result);
+ }
+
+
+ #endregion Public Methods
+
+ #region Public Properties
+ /// <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
+ {
+ get
+ {
+ return decomp.IsFullRank;
+ }
+ }
+
+
+ ///<summary>Calculates the determinant (absolute value) of the matrix.</summary>
+ ///<value>The determinant of the matrix.</value>
+ ///<exception cref="NotSquareMatrixException">If the matrix is not square.</exception>
+ public double Determinant
+ {
+ get
+ {
+ return decomp.Determinant;
+ }
+ }
+
+ #endregion Public Properites
+
+ #region Protected Members
+
+ /// <summary>
+ /// Delegates the actual computation to the correct QR subtype.
+ /// </summary>
+ protected override void InternalCompute()
+ {
+ decomp.Compute();
+ }
+ #endregion Protected Members
+ }
+}
Modified: trunk/LinearAlgebra/DenseMatrix.cs
===================================================================
--- trunk/LinearAlgebra/DenseMatrix.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/DenseMatrix.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -1340,7 +1340,7 @@
if (other.GetType() == typeof(DenseMatrix) && result.GetType() == typeof(DenseMatrix))
{
- blas.Multiply(Rows, Columns, other.Columns, data, ((DenseMatrix)other).data, ((DenseMatrix)result).data);
+ blas.Multiply(Rows, other.Columns, Columns, data, ((DenseMatrix)other).data, ((DenseMatrix)result).data);
}
else
{
@@ -1381,7 +1381,7 @@
;
if (leftSide.GetType() == typeof(DenseVector) && result.GetType() == typeof(DenseVector))
{
- blas.Multiply(1, leftSide.Count, Columns, ((DenseVector)leftSide).data, data, ((DenseVector)result).data);
+ blas.Multiply(1, Columns, leftSide.Count, ((DenseVector)leftSide).data, data, ((DenseVector)result).data);
}
else
{
Modified: trunk/LinearAlgebra/DenseVector.cs
===================================================================
--- trunk/LinearAlgebra/DenseVector.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/DenseVector.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -673,7 +673,7 @@
{
DenseVector rightVector = (DenseVector)rightSide;
DenseMatrix result = new DenseMatrix(this.Count, rightSide.Count, Settings.UseNativeLibrary);
- blas.Multiply(this.Count, 1, rightSide.Count, data, rightVector.data, result.data);
+ blas.Multiply(this.Count, rightSide.Count, 1, data, rightVector.data, result.data);
return result;
}
else
@@ -708,7 +708,7 @@
{
DenseVector rightVector = (DenseVector)rightSide;
DenseMatrix resultMatrix = (DenseMatrix)result;
- blas.Multiply(this.Count, 1, rightSide.Count, data, rightVector.data, resultMatrix.data);
+ blas.Multiply(this.Count, rightSide.Count, 1, data, rightVector.data, resultMatrix.data);
}
else
{
Modified: trunk/LinearAlgebra/ManagedBlas.cs
===================================================================
--- trunk/LinearAlgebra/ManagedBlas.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/ManagedBlas.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -92,14 +92,14 @@
double s = 0;
int ntmp = 0;
int mtmp = 0;
- for (j = 0; j < k; ++j)
+ for (j = 0; j < n; ++j)
{
- ntmp = n * j;
+ ntmp = k * j;
mtmp = m * j;
for (i = 0; i < m; ++i)
{
s = 0;
- for (l = 0; l < n; ++l)
+ for (l = 0; l < k; ++l)
{
s += x[m * l + i] * y[ntmp + l];
}
Modified: trunk/LinearAlgebra/ManagedLapack.cs
===================================================================
--- trunk/LinearAlgebra/ManagedLapack.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/ManagedLapack.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -217,7 +217,7 @@
}
double[] tmp = new double[rows * rows];
- blas.Multiply(rows, columns, rows, data, trans, tmp);
+ blas.Multiply(rows, rows, columns, data, trans, tmp);
for (int i = 0; i < rows; i++)
{
ret += System.Math.Abs(tmp[i * rows + i]);
@@ -293,14 +293,19 @@
public void QRFactor(int m, int n, double[] q, double[] r)
{
+ for (int i = 0; i < m; i++)
+ {
+ q[i * m + i] = 1;
+ }
int minmn = m < n ? m : n;
+
double[][] u = new double[minmn][];
for (int i = 0; i < minmn; i++)
{
u[i] = Householder.GenerateColumn(r, m, i, m - 1, i);
Householder.UA(u[i], r, m, i, m - 1, i + 1, n - 1);
}
- //q = DoubleMatrix.CreateIdentity(m);
+
for (int i = minmn - 1; i >= 0; i--)
{
Householder.UA(u[i], q, m, i, m - 1, i, m - 1);
Modified: trunk/LinearAlgebra/NativeBlas.cs
===================================================================
--- trunk/LinearAlgebra/NativeBlas.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/NativeBlas.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -7,52 +7,66 @@
*/
using dnAnalytics.LinearAlgebra.Native;
-namespace dnAnalytics.LinearAlgebra {
- internal sealed class NativeBlas : ISimplifiedBlas {
- private IBlas blas = Provider.BlasInstance;
+namespace dnAnalytics.LinearAlgebra
+{
+ internal sealed class NativeBlas : ISimplifiedBlas
+ {
+ private IBlas blas = Provider.BlasInstance;
- public int AbsoluteMaximumIndex(double[] data) {
- return blas.Idamax(data.Length, data, 1);
- }
+ public int AbsoluteMaximumIndex(double[] data)
+ {
+ return blas.Idamax(data.Length, data, 1);
+ }
- public double SumMagnitudes(double[] data) {
- return blas.Dasum(data.Length, data, 1);
- }
+ public double SumMagnitudes(double[] data)
+ {
+ return blas.Dasum(data.Length, data, 1);
+ }
- public double DotProduct(double[] x, double[] y) {
- return blas.Ddot(x.Length, x, 1, y, 1);
- }
+ public double DotProduct(double[] x, double[] y)
+ {
+ return blas.Ddot(x.Length, x, 1, y, 1);
+ }
- public void Scale(double constant, double[] data) {
- blas.Dscal(data.Length, constant, data, 1);
- }
+ public void Scale(double constant, double[] data)
+ {
+ blas.Dscal(data.Length, constant, data, 1);
+ }
- public void Subtract(double[] vector, double constant) {
- double[] temp = new double[vector.Length];
- for (int i = 0; i < 0; ++i) {
- temp[i] = constant;
- }
- blas.Daxpy(vector.Length, -1, temp, 1, vector, 1);
- }
+ public void Subtract(double[] vector, double constant)
+ {
+ double[] temp = new double[vector.Length];
+ for (int i = 0; i < temp.Length; i++)
+ {
+ temp[i] = constant;
+ }
+ blas.Daxpy(vector.Length, -1, temp, 1, vector, 1);
+ }
- public void Subtract(double[] x, double[] y) {
- blas.Daxpy(x.Length, -1, y, 1, x, 1);
- }
+ public void Subtract(double[] x, double[] y)
+ {
+ blas.Daxpy(x.Length, -1, y, 1, x, 1);
+ }
- public void Add(double[] vector, double constant) {
- double[] temp = new double[vector.Length];
- for (int i = 0; i < 0; ++i) {
- temp[i] = constant;
- }
- blas.Daxpy(vector.Length, 1, temp, 1, vector, 1);
- }
+ public void Add(double[] vector, double constant)
+ {
+ double[] temp = new double[vector.Length];
+ for (int i = 0; i < temp.Length; i++)
+ {
+ temp[i] = constant;
+ }
- public void Add(double[] x, double[] y) {
- blas.Daxpy(x.Length, 1, y, 1, x, 1);
- }
+ blas.Daxpy(vector.Length, 1, temp, 1, vector, 1);
+ }
- public void Multiply(int m, int n, int k, double[] x, double[] y, double[] result) {
- blas.Dgemm(BlasOrderType.Column, BlasTransType.NoTrans, BlasTransType.NoTrans, m, n, k, 1, x, m, y, n, 1, result, k);
- }
- }
+ public void Add(double[] x, double[] y)
+ {
+ blas.Daxpy(x.Length, 1, y, 1, x, 1);
+ }
+
+ public void Multiply(int m, int n, int k, double[] x, double[] y, double[] result)
+ {
+ blas.Dgemm(BlasOrderType.Column, BlasTransType.NoTrans, BlasTransType.NoTrans, m, n, k, 1, x, m, y, k, 0, result, m);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/LinearAlgebra/NativeLapack.cs
===================================================================
--- trunk/LinearAlgebra/NativeLapack.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/LinearAlgebra/NativeLapack.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -28,7 +28,7 @@
lapack.Dgetrf(order, order, factor, order, out ipiv);
for (int i = 0; i < pivots.Length; i++)
{
- pivots[i] = ipiv[i] - 1;
+ pivots[i] = ipiv[i] - 1;
}
}
@@ -82,7 +82,46 @@
public void QRFactor(int m, int n, double[] q, double[] r)
{
- throw new Exception("The method or operation is not implemented.");
+ double[] tau = new double[System.Math.Min(m, n)];
+ double[] qr = new double[r.Length];
+ Buffer.BlockCopy(r, 0, qr, 0, r.Length * Constants.SizeOfDouble);
+
+ lapack.Dgeqrf(m, n, qr, m, tau);
+
+ for (int i = 0; i < m; i++)
+ {
+ for (int j = 0; j < n; j++)
+ {
+ if (i <= j)
+ {
+ r[j * m + i] = qr[j * m + i];
+ }
+ else
+ {
+ r[j * m + i] = 0.0;
+ }
+ }
+ }
+ for (int i = 0; i < m; i++)
+ {
+ for (int j = 0; j < m && j < n; j++)
+ {
+ if (i > j)
+ {
+ q[j * m + i] = qr[j * m + i];
+ }
+ }
+ }
+
+
+ if (m <= n)
+ {
+ lapack.Dorgqr(m, m, m, q, m, tau);
+ }
+ else
+ {
+ lapack.Dorgqr(m, m, n, q, m, tau);
+ }
}
#endregion Public Methods
}
Modified: trunk/NumericalLibrary.csproj
===================================================================
--- trunk/NumericalLibrary.csproj 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/NumericalLibrary.csproj 2006-01-18 16:12:15 UTC (rev 176)
@@ -33,6 +33,14 @@
<DocumentationFile>bin\Release\dnAnalytics.dll.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="nunit.core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Program Files\Mailframe\TestRunner\nunit.core.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.2.5.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Program Files\Mailframe\TestRunner\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
Modified: trunk/Settings.cs
===================================================================
--- trunk/Settings.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/Settings.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -16,7 +16,7 @@
/// </summary>
public static class Settings
{
- private static bool native;
+ private static bool native = false;
private static BlasProvider blasProvider;
private static LapackProvider lapackProvider;
private static MatrixType matrixType = MatrixType.Dense;
Added: trunk/TestMatrices/random_real_general_array_20_10.matrix_market
===================================================================
--- trunk/TestMatrices/random_real_general_array_20_10.matrix_market 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/TestMatrices/random_real_general_array_20_10.matrix_market 2006-01-18 16:12:15 UTC (rev 176)
@@ -0,0 +1,207 @@
+%%MatrixMarket matrix array real general
+%==============================================================
+% A Random 20x10 matrix with density = 1.0,
+% elements from -100.0 to 100.0
+% Generated by MatrixMarketDeli @ Fri Nov 11 17:06:08 EET 2005
+%==============================================================
+20 10
+3.8657857973798E+1
+-4.9614141943821E+0
+9.8367529614337E+1
+-8.2830239960130E+1
+-4.8001834141995E+1
+1.8538795105779E+0
+8.8913280903105E+0
+7.6433590250342E+1
+3.9112716073559E+1
+3.9887721176386E+0
+7.1502475973519E+1
+-6.2241679398193E+1
+-1.9561929064987E+0
+3.3027174343978E+1
+2.4007135439120E+1
+8.2689715275099E-1
+-8.1632642030832E+1
+4.9360457021864E+0
+-7.6279897452783E+1
+-7.4269842491989E+0
+-8.6709742218175E+1
+-2.3383344954355E+1
+-9.6814601918678E+1
+-8.9091848158775E+1
+7.8756002367903E+1
+7.5160409139558E+1
+4.9821485912964E+1
+-7.2203103442099E+1
+-8.0841292407509E+1
+8.8169658884781E+1
+7.3532129439538E+1
+-9.4881302335684E+1
+5.8975431339973E+1
+-9.6492050220299E+1
+-7.9279553728695E+1
+3.2251799109820E+1
+5.9347462853748E+0
+-5.9801269728711E+1
+3.7113551592361E+1
+-5.4025279935249E+0
+8.5124240448279E+1
+-5.0657034629351E+1
+-6.7019266503368E+1
+-1.7572213479782E+1
+-4.1060590659680E+1
+-3.7716876288734E+1
+4.8472477178567E+1
+8.7097993571157E-1
+-7.1011388392340E+1
+-5.9417485352436E+1
+6.0302454220710E+1
+7.2841896419677E+1
+-8.0277608153256E+1
+-5.3412553849684E+1
+-5.1571106786546E+1
+2.6798324194892E+1
+8.7932790521780E+1
+-2.7818093307886E+1
+-1.5775292212287E+1
+-2.1083512397918E+1
+2.5065328021297E+1
+7.6851803745298E+1
+2.3727288271726E+1
+-5.6135909760460E+1
+9.7097165855923E+1
+3.0818525947043E+1
+-7.7399463045670E+1
+-5.9195847420585E+1
+-8.9907684389171E+1
+-6.9317317811519E+1
+5.4976526142004E+1
+-5.7711254412963E+1
+-4.2430488846026E+0
+-9.8520336997919E+1
+5.4207931936249E+1
+-9.6502727928745E+1
+-1.7731298536016E+1
+6.5294704112545E+1
+9.9852653099467E+1
+5.1764551074441E+1
+2.2030411483824E+1
+6.3961999694411E-1
+9.0490382297665E+1
+9.4968452852052E+0
+9.6691006175572E+1
+4.4616403469871E+1
+5.1962038778481E+1
+2.6227755837799E+1
+1.2501410937845E+1
+-7.3032758436502E+1
+-4.3799479222919E+1
+-4.8823266783208E+1
+4.8892028772484E+1
+9.8005489461655E+1
+-5.2275562868370E+1
+1.4514592414139E+1
+-1.1026075554457E+1
+7.6577296847270E+1
+2.6350906953621E+1
+6.8136841733325E+1
+5.7795535934622E+1
+-6.4470860476650E+1
+5.6283044025406E+1
+-2.6583238106615E+1
+5.7172990280152E+1
+1.4839208716056E+1
+-5.3063788768535E+1
+-3.0677473549551E+1
+6.8017669017893E+1
+-5.3288687513339E+1
+-3.3607082144278E+1
+-1.7939974765680E+1
+2.2957582823418E+1
+-9.0407494201500E+1
+2.1409839072464E+1
+6.4922138455957E+1
+-4.6327046291443E+1
+5.3995656456756E+1
+2.6505336221819E+1
+-2.4511915982629E+1
+9.1168047319635E+1
+9.9716688040813E+1
+9.8054707298386E+1
+5.9887316030350E+1
+7.8681744287464E+1
+6.9897597029792E+1
+-8.8787531253430E+1
+2.7292048953501E+1
+3.1927009684747E+0
+-5.5726168695277E+1
+-8.6693878979362E+1
+-2.1397824828833E+1
+8.1370822022098E+1
+-1.7270794811094E+1
+-8.1388223901884E+1
+-1.8936484118800E+1
+-4.2889927761586E+1
+7.8482437781550E+1
+7.7075325106993E+1
+8.8869899961860E+1
+-9.3232845693345E+1
+6.1846976789257E+0
+-6.6663261172111E+1
+1.8474958322888E+1
+2.3348744734824E+1
+-7.4897068718330E+1
+-5.7272836386936E+1
+-9.1714308724696E+0
+-8.6336407708615E+1
+7.6778818041074E+1
+-3.3445963164259E+0
+4.3894137549737E+1
+-6.1054965593620E+1
+-8.1991824752178E+1
+-8.8591774350639E+1
+-3.1429357495994E+1
+8.3046062122694E+1
+3.4239494222753E+1
+1.9727267992300E+1
+-8.4478528341323E+1
+6.2027033474417E+1
+9.8545842876554E+1
+-5.3286194233121E+1
+-2.5677202022038E+0
+-7.9209868876695E+1
+6.5041073720403E+1
+-1.5816965556759E+1
+8.3696434105093E+1
+-1.7212688574462E+1
+-4.3479677766491E+1
+-5.8324979805811E+1
+9.2815617577040E+1
+-2.6635511496726E+1
+3.8968282841527E+1
+7.6492961602756E+1
+1.6117066567479E+1
+6.7829313570147E+1
+-4.8571588439503E+1
+1.1974628549357E+1
+4.1744016266844E+1
+8.8861608890694E+1
+-9.3820211873294E+1
+-8.0039282550807E+1
+-4.7286040976801E+0
+2.7500658275720E+1
+8.4074146022574E+0
+2.9721652493472E+1
+7.0202857515499E+1
+-8.8525601516714E+1
+8.3616547659693E+1
+-3.0287777191142E+1
+-3.6989943737820E+1
+4.8802326734341E+1
+-1.8370471958878E+1
+6.4014835211960E+1
+-9.7585733146856E+1
+-5.8531696320096E+1
+-8.7843304424702E+1
+6.7934939698221E+1
+-7.2342764125323E+1
Modified: trunk/UnitTests/LinearAlgebra/AbstractVectorTest.cs
===================================================================
--- trunk/UnitTests/LinearAlgebra/AbstractVectorTest.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/UnitTests/LinearAlgebra/AbstractVectorTest.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -513,7 +513,6 @@
Vector vector1 = GetVector(testArray);
Vector vector2 = vector1.Clone();
Matrix result = vector1.Multiply(vector2);
-
for (int i = 0; i < vector1.Count; i++)
{
for (int j = 0; j < vector2.Count; j++)
@@ -880,7 +879,7 @@
{
expected += System.Math.Abs(testArray[i]);
}
- Assert.AreEqual(expected, actual);
+ Assert.AreEqual(expected, actual, Constants.ACCEPTABLE_ERROR);
}
[Test]
Modified: trunk/UnitTests/LinearAlgebra/Decomposition/AbstractLUTest.cs
===================================================================
--- trunk/UnitTests/LinearAlgebra/Decomposition/AbstractLUTest.cs 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/UnitTests/LinearAlgebra/Decomposition/AbstractLUTest.cs 2006-01-18 16:12:15 UTC (rev 176)
@@ -39,7 +39,7 @@
[Test]
[ExpectedException(typeof(NotSquareMatrixException))]
- public void LUConstructor()
+ public void LUConstructorNotSquare()
{
Matrix matrix = GetMatrix(3, 2);
LU lu = new LU(matrix);
@@ -68,7 +68,7 @@
perm[i, i] = 1;
}
- //there has to be a quicker way to generate the perm matrix?
+ //there has to be a quicker way to generate the perm squareMatrix?
double temp;
for (int i = 0; i < pivots.Length; i++)
{
@@ -117,7 +117,7 @@
perm[i, i] = 1;
}
- //there has to be a quicker way to generate the perm matrix?
+ //there has to be a quicker way to generate the perm squareMatrix?
for (int i = 0; i < pivots.Length; i++)
{
if (pivots[i] != i)
@@ -167,7 +167,7 @@
perm[i, i] = 1;
}
- //there has to be a quicker way to generate the perm matrix?
+ //there has to be a quicker way to generate the perm squareMatrix?
double temp;
for (int i = 0; i < pivots.Length; i++)
{
@@ -220,7 +220,7 @@
perm[i, i] = 1;
}
- //there has to be a quicker way to generate the perm matrix?
+ //there has to be a quicker way to generate the perm squareMatrix?
for (int i = 0; i < pivots.Length; i++)
{
if (pivots[i] != i)
Modified: trunk/UnitTests/UnitTests.csproj
===================================================================
--- trunk/UnitTests/UnitTests.csproj 2006-01-18 11:44:39 UTC (rev 175)
+++ trunk/UnitTests/UnitTests.csproj 2006-01-18 16:12:15 UTC (rev 176)
@@ -31,7 +31,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.2.5.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="nunit.core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Program Files\Mailframe\TestRunner\nunit.core.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.2.5.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Program Files\Mailframe\TestRunner\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
@@ -44,6 +51,8 @@
<Compile Include="LinearAlgebra\AbstractVectorTest.cs" />
<Compile Include="LinearAlgebra\Decomposition\AbstractLUTest.cs" />
<Compile Include="LinearAlgebra\Decomposition\AbstractCholeskyTest.cs" />
+ <Compile Include="LinearAlgebra\Decomposition\AbstractQRTest.cs" />
+ <Compile Include="LinearAlgebra\Decomposition\DenseQRTest.cs" />
<Compile Include="LinearAlgebra\Decomposition\DenseCholeskyTest.cs" />
<Compile Include="LinearAlgebra\Decomposition\DenseLUTest.cs">
<SubType>Code</SubType>
|