Browse Source

fixed the QR methods to be more work better with the managed provider

pull/36/head
Marcus Cuda 17 years ago
parent
commit
3e4a31ec8a
  1. 54
      src/Numerics/Algorithms/LinearAlgebra/ILinearAlgebraProvider.cs
  2. 29
      src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs

54
src/Numerics/Algorithms/LinearAlgebra/ILinearAlgebraProvider.cs

@ -284,8 +284,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <summary>
/// Computes the Cholesky factorization of A.
/// </summary>
/// <param name="a">A square, positive definite matrix. The matrix is overwritten with the
/// the Cholesky factorization On exit.</param>
/// <param name="a">On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the
/// the Cholesky factorization.</param>
/// <remarks>This is equivalent to the POTRF LAPACK routine.</remarks>
void CholeskyFactor(double[] a);
@ -310,64 +310,36 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <summary>
/// Computes the QR factorization of A.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// the elements on and above the diagonal of the array
/// contain the min(M,N)-by-N upper trapezoidal matrix R (R is
/// upper triangular if m >= n); the elements below the diagonal,
/// with the array <paramref name="tau"/>, represent the orthogonal matrix Q as a
/// product of min(m,n) elementary reflectors. </param>
/// <param name="r">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the R matrix of the QR factorization. </param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">On exit, tau contains information needed by the <see cref="QRSolve(int,double[],double[],double[],double[])"/>
/// method.</param>
/// <remarks>This is equivalent to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(double[] a, double[] q, double[] tau);
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(double[] r, double[] q);
/// <summary>
/// Computes the QR factorization of A.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// the elements on and above the diagonal of the array
/// contain the min(M,N)-by-N upper trapezoidal matrix R (R is
/// upper triangular if m >= n); the elements below the diagonal,
/// with the array <paramref name="tau"/>, represent the orthogonal matrix Q as a
/// product of min(m,n) elementary reflectors. </param>
/// <param name="r">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the R matrix of the QR factorization. </param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">On exit, tau contains information needed by the <see cref="QRSolve(int,double[],double[],double[],double[])"/>
/// method.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(double[] a, double[] q, double[] tau, double[] work);
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(double[] r, double[] q, double[] work);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The matrix obtained by calling <see cref="QRFactor(double[],double[],double[])"/>.</param>
/// <param name="tau">The tau vector obtained by calling <see cref="QRFactor(double[],double[],double[])"/>. </param>
/// <param name="q">The Q matrix obtained by calling <see cref="QRFactor(double[],double[])"/>.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(double[],double[])"/>. </param>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>This is equivalent to the ORMQR LAPACK routine with the TRSM BLAS routine.</remarks>
void QRSolve(int columnsOfB, double[] a, double[] tau, double[] b, double[] x);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The M by N</param>
/// <param name="tau">The tau vector obtained by calling <see cref="QRFactor(double[],double[],double[])"/>. </param>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the ORMQR LAPACK routine with the TRSM BLAS routine.</remarks>
void QRSolve(int columnsOfB, double[] a, double[] tau, double[] b, double[] x, double[] work);
void QRSolve(int columnsOfB, double[] q, double[] r, double[] b, double[] x);
/// <summary>
/// Computes the singular value decomposition of A.

29
src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs

@ -1,4 +1,4 @@
// <copyright file="ManagedLinearAlgebra.cs" company="Math.NET">
// <copyright file="ManagedLinearAlgebraProvider.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
// Copyright (c) 2009 Math.NET
@ -21,16 +21,19 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.Algorithms.LinearAlgebra
{
using System;
using Properties;
using Threading;
/// <summary>
/// The managed linear algebra provider.
/// </summary>
public class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
{
#region ILinearAlgebraProvider Members
/// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
/// </summary>
@ -52,7 +55,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
if (y.Length != x.Length)
{
throw new ArgumentException(Properties.Resources.ArgumentVectorsSameLength);
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (alpha == 0.0)
@ -86,8 +89,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
Parallel.For(0, x.Length, i => x[i] = alpha * x[i]);
}
#region ILinearAlgebraProvider Members
public int QueryWorkspaceBlockSize(string methodName)
{
throw new NotImplementedException();
@ -193,22 +194,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
throw new NotImplementedException();
}
public void QRFactor(double[] a, double[] q, double[] tau)
{
throw new NotImplementedException();
}
public void QRFactor(double[] a, double[] q, double[] tau, double[] work)
public void QRFactor(double[] r, double[] q)
{
throw new NotImplementedException();
}
public void QRSolve(int columnsOfB, double[] a, double[] tau, double[] b, double[] x)
public void QRFactor(double[] r, double[] q, double[] work)
{
throw new NotImplementedException();
}
public void QRSolve(int columnsOfB, double[] a, double[] tau, double[] b, double[] x, double[] work)
public void QRSolve(int columnsOfB, double[] q, double[] r, double[] b, double[] x)
{
throw new NotImplementedException();
}
@ -218,7 +214,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
throw new NotImplementedException();
}
public void SinguarValueDecomposition(bool computeVectors, double[] a, double[] s, double[] u, double[] vt, double[] work)
public void SingularValueDecomposition(
bool computeVectors, double[] a, double[] s, double[] u, double[] vt, double[] work)
{
throw new NotImplementedException();
}

Loading…
Cancel
Save