Browse Source

LA Provider: maintain excluded ACML & GotoBLAS providers, minor cleanup

optimization-1
Christoph Ruegg 13 years ago
parent
commit
207a08eb9e
  1. 1
      src/Numerics/Numerics.csproj
  2. 117
      src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.Complex.cs
  3. 145
      src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.Complex32.cs
  4. 145
      src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.double.cs
  5. 143
      src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.float.cs
  6. 42
      src/Numerics/Providers/LinearAlgebra/Acml/SafeNativeMethods.cs
  7. 50
      src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Common.cs
  8. 147
      src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Complex.cs
  9. 145
      src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Complex32.cs
  10. 145
      src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.double.cs
  11. 141
      src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.float.cs
  12. 42
      src/Numerics/Providers/LinearAlgebra/GotoBlas/SafeNativeMethods.cs
  13. 503
      src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
  14. 533
      src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProviderOfT.cs
  15. 20
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
  16. 520
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
  17. 509
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
  18. 496
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
  19. 40
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Common.cs
  20. 136
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
  21. 58
      src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs

1
src/Numerics/Numerics.csproj

@ -101,7 +101,6 @@
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Single.cs" />
<Compile Include="Providers\LinearAlgebra\ILinearAlgebraProvider.cs" />
<Compile Include="Providers\LinearAlgebra\ILinearAlgebraProviderOfT.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Common.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex.cs" />

117
src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.Complex.cs

@ -27,14 +27,13 @@
#if NATIVEACML
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
using System;
using System.Numerics;
using System.Security;
using Properties;
/// <summary>
/// AMD Core Math Library (ACML) linear algebra provider.
/// </summary>
@ -189,7 +188,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
@ -224,7 +223,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -251,7 +250,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -280,7 +279,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -311,7 +310,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -352,7 +351,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -391,12 +390,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -431,7 +430,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -441,7 +440,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -474,7 +473,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -509,7 +508,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -543,7 +542,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -581,7 +580,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -591,12 +590,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
SafeNativeMethods.z_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -633,7 +632,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -643,14 +642,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -667,7 +666,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x)
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -684,17 +683,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -704,7 +703,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex[columns * Control.BlockSize];
var work = new Complex[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -721,7 +720,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, Complex[] work)
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, Complex[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -743,17 +742,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -765,7 +764,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -786,7 +785,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x)
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -808,22 +807,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -833,7 +832,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -854,7 +853,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, Complex[] work)
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, Complex[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -881,22 +880,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -908,7 +907,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -951,12 +950,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -966,7 +965,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -996,20 +995,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var s = new Complex[Math.Min(rowsA, columnsA)];
var u = new Complex[rowsA * rowsA];
var vt = new Complex[columnsA * columnsA];
var u = new Complex[rowsA*rowsA];
var vt = new Complex[columnsA*columnsA];
var clone = new Complex[a.Length];
a.Copy(clone);
@ -1061,12 +1060,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1081,9 +1080,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
if (work.Length < (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
{
work[0] = (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
work[0] = (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

145
src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.Complex32.cs

@ -31,13 +31,12 @@
#if NATIVEACML
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
using System;
using System.Security;
using Properties;
/// <summary>
/// AMD Core Math Library (ACML) linear algebra provider.
/// </summary>
@ -70,7 +69,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
return SafeNativeMethods.c_dot_product(x.Length, x, y);
}
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
@ -123,8 +122,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -192,9 +191,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -227,7 +226,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -236,7 +235,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.c_lu_factor(order, data, ipiv);
}
@ -254,13 +253,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new Complex32[order];
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -283,7 +282,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -294,7 +293,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
}
var work = new Complex32[order];
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -314,7 +313,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -329,7 +328,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -355,7 +354,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -375,7 +374,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -394,22 +393,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.c_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -434,7 +433,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -444,7 +443,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -454,7 +453,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.c_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -477,7 +476,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -512,7 +511,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -522,7 +521,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.c_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -546,7 +545,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.c_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -584,7 +583,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -594,12 +593,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new Complex32[columnsR * Control.BlockSize];
var work = new Complex32[columnsR*Control.BlockSize];
SafeNativeMethods.c_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -636,7 +635,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -646,14 +645,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -670,7 +669,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x)
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -687,17 +686,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -707,7 +706,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex32[columns * Control.BlockSize];
var work = new Complex32[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -724,7 +723,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work)
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -746,17 +745,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -768,7 +767,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -789,7 +788,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x)
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -811,22 +810,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -835,8 +834,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex32[columnsR * Control.BlockSize];
var work = new Complex32[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -857,7 +856,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work)
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -884,22 +883,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -911,7 +910,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -954,12 +953,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -969,7 +968,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new Complex32[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex32[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -999,20 +998,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new Complex32[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex32[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var s = new Complex32[Math.Min(rowsA, columnsA)];
var u = new Complex32[rowsA * rowsA];
var vt = new Complex32[columnsA * columnsA];
var u = new Complex32[rowsA*rowsA];
var vt = new Complex32[columnsA*columnsA];
var clone = new Complex32[a.Length];
a.Copy(clone);
@ -1064,12 +1063,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1084,9 +1083,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
if (work.Length < (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
{
work[0] = (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
work[0] = (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

145
src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.double.cs

@ -31,13 +31,12 @@
#if NATIVEACML
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
using System;
using System.Security;
using Properties;
/// <summary>
/// AMD Core Math Library (ACML) linear algebra provider.
/// </summary>
@ -70,7 +69,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
return SafeNativeMethods.d_dot_product(x.Length, x, y);
}
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
@ -123,8 +122,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -192,9 +191,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -227,7 +226,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -236,7 +235,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.d_lu_factor(order, data, ipiv);
}
@ -254,13 +253,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new double[order];
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -283,7 +282,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -294,7 +293,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
}
var work = new double[order];
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -314,7 +313,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -329,7 +328,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -355,7 +354,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -375,7 +374,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -394,22 +393,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.d_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -434,7 +433,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -444,7 +443,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -454,7 +453,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.d_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -477,7 +476,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -512,7 +511,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -522,7 +521,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.d_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -546,7 +545,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.d_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -584,7 +583,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -594,12 +593,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new double[columnsR * Control.BlockSize];
var work = new double[columnsR*Control.BlockSize];
SafeNativeMethods.d_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -636,7 +635,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -646,14 +645,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -670,7 +669,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x)
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -687,17 +686,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -707,7 +706,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new double[columns * Control.BlockSize];
var work = new double[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -724,7 +723,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, double[] work)
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, double[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -746,17 +745,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -768,7 +767,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -789,7 +788,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x)
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -811,22 +810,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -835,8 +834,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new double[columnsR * Control.BlockSize];
var work = new double[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -857,7 +856,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, double[] work)
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, double[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -884,22 +883,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -911,7 +910,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -954,12 +953,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -969,7 +968,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new double[Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))];
var work = new double[Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA))];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -999,20 +998,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new double[Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))];
var work = new double[Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA))];
var s = new double[Math.Min(rowsA, columnsA)];
var u = new double[rowsA * rowsA];
var vt = new double[columnsA * columnsA];
var u = new double[rowsA*rowsA];
var vt = new double[columnsA*columnsA];
var clone = new double[a.Length];
a.Copy(clone);
@ -1064,12 +1063,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1084,9 +1083,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA)))
if (work.Length < Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA)))
{
work[0] = Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA));
work[0] = Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA));
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

143
src/Numerics/Providers/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.float.cs

@ -31,13 +31,12 @@
#if NATIVEACML
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
using System;
using System.Security;
using Properties;
/// <summary>
/// AMD Core Math Library (ACML) linear algebra provider.
/// </summary>
@ -70,7 +69,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
return SafeNativeMethods.s_dot_product(x.Length, x, y);
}
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
@ -123,8 +122,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -192,9 +191,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -227,7 +226,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -236,7 +235,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.s_lu_factor(order, data, ipiv);
}
@ -254,13 +253,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new float[order];
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -283,7 +282,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -314,7 +313,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -328,8 +327,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -355,7 +354,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -394,22 +393,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.s_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -434,7 +433,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -444,7 +443,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -454,7 +453,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.s_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -477,7 +476,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -512,7 +511,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -522,7 +521,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.s_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -546,7 +545,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.s_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -584,7 +583,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -594,12 +593,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new float[columnsR * Control.BlockSize];
var work = new float[columnsR*Control.BlockSize];
SafeNativeMethods.s_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -636,7 +635,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -646,14 +645,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -670,7 +669,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x)
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -687,17 +686,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -707,7 +706,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columns * Control.BlockSize];
var work = new float[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -724,7 +723,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, float[] work)
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, float[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -746,17 +745,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -768,7 +767,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -789,7 +788,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x)
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -811,22 +810,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -835,8 +834,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columnsR * Control.BlockSize];
var work = new float[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -857,7 +856,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, float[] work)
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, float[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -884,22 +883,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -911,7 +910,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -954,12 +953,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -969,7 +968,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
var work = new float[Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA))];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -999,20 +998,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
var work = new float[Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA))];
var s = new float[Math.Min(rowsA, columnsA)];
var u = new float[rowsA * rowsA];
var vt = new float[columnsA * columnsA];
var u = new float[rowsA*rowsA];
var vt = new float[columnsA*columnsA];
var clone = new float[a.Length];
a.Copy(clone);
@ -1064,12 +1063,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1084,9 +1083,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA)))
if (work.Length < Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA)))
{
work[0] = Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA));
work[0] = Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA));
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

42
src/Numerics/Providers/LinearAlgebra/Acml/SafeNativeMethods.cs

@ -44,10 +44,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
/// <summary>
/// Name of the native DLL.
/// </summary>
private const string DllName = "MathNET.Numerics.ACML.dll";
const string DllName = "MathNET.Numerics.ACML.dll";
#region BLAS
#region BLAS
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y);
@ -59,7 +59,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_scale(int n, float alpha, [Out] float[] x);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_dot_product(int n, float[] x, float[] y);
@ -83,22 +83,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out]float[] c);
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c);
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out]Complex32[] c);
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out]Complex[] c);
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c);
#endregion BLAS
#region LAPACK
#endregion BLAS
#region LAPACK
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a, [In, Out] float[] work);
@ -123,7 +123,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_cholesky_factor(int n, [In, Out] Complex[] a);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_factor(int n, [In, Out] float[] a, [In, Out] int[] ipiv);
@ -153,15 +153,15 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_inverse_factored(int n, [In, Out] double[] a, [In, Out] int[] ipiv, [In, Out] double[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int c_lu_inverse_factored(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out]int[] ipiv, [In, Out] float[] b);
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_solve_factored(int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b);
@ -170,7 +170,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
internal static extern int c_lu_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out]int[] ipiv, [In, Out] Complex[] b);
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -182,7 +182,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
internal static extern int c_lu_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_cholesky_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -256,7 +256,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Acml
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_svd_factor(bool computeVectors, int m, int n, [In, Out] Complex[] a, [In, Out] Complex[] s, [In, Out] Complex[] u, [In, Out] Complex[] v, [In, Out] Complex[] work, int len);
#endregion LAPACK
#endregion LAPACK
}
}

50
src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Common.cs

@ -30,13 +30,13 @@
#if NATIVEGOTO
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
using System;
using System.Numerics;
using System.Security;
using Properties;
/// <summary>
/// GotoBLAS2 linear algebra provider.
/// </summary>
@ -70,9 +70,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new float[rows];
@ -109,9 +109,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -119,7 +119,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.s_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.s_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -150,9 +150,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new double[rows];
@ -189,9 +189,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -199,7 +199,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.d_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.d_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -230,9 +230,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new float[rows];
@ -269,9 +269,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -279,7 +279,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.c_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.c_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -310,9 +310,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new double[rows];
@ -349,9 +349,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -359,7 +359,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.z_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.z_matrix_norm((byte) norm, rows, columns, matrix, work);
}
}
}

147
src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Complex.cs

@ -31,14 +31,13 @@
#if NATIVEGOTO
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
using System;
using System.Numerics;
using System.Security;
using Properties;
/// <summary>
/// GotoBLAS2 linear algebra provider.
/// </summary>
@ -96,8 +95,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -165,9 +164,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -200,7 +199,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -209,7 +208,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.z_lu_factor(order, data, ipiv);
}
@ -227,13 +226,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new Complex[order];
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -256,7 +255,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -267,7 +266,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
}
var work = new Complex[order];
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -287,7 +286,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -302,7 +301,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -328,7 +327,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -348,7 +347,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -367,22 +366,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.z_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -407,7 +406,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -417,7 +416,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -427,7 +426,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.z_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -450,7 +449,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -485,7 +484,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -495,7 +494,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.z_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -519,7 +518,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -529,7 +528,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.z_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -545,7 +544,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] tau, QRMethod method = QRMethod.Full)
public override void QRFactor(Complex[] r, int rowsR, int columnsR, Complex[] q, Complex[] tau)
{
if (r == null)
{
@ -557,7 +556,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -567,12 +566,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
SafeNativeMethods.z_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -609,7 +608,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -619,14 +618,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -643,7 +642,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x)
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -660,17 +659,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -680,7 +679,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex[columns * Control.BlockSize];
var work = new Complex[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -697,7 +696,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, Complex[] work)
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, Complex[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -719,17 +718,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -741,7 +740,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -762,7 +761,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x)
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -784,22 +783,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -808,8 +807,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -830,7 +829,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, Complex[] work)
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, Complex[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -857,22 +856,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -884,7 +883,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -927,12 +926,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -942,7 +941,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -972,20 +971,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var s = new Complex[Math.Min(rowsA, columnsA)];
var u = new Complex[rowsA * rowsA];
var vt = new Complex[columnsA * columnsA];
var u = new Complex[rowsA*rowsA];
var vt = new Complex[columnsA*columnsA];
var clone = new Complex[a.Length];
a.Copy(clone);
@ -1037,12 +1036,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1057,9 +1056,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
if (work.Length < (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
{
work[0] = (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
work[0] = (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

145
src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.Complex32.cs

@ -31,13 +31,12 @@
#if NATIVEGOTO
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
using System;
using System.Security;
using Properties;
/// <summary>
/// GotoBLAS2 linear algebra provider.
/// </summary>
@ -95,8 +94,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -164,9 +163,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -199,7 +198,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -208,7 +207,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.c_lu_factor(order, data, ipiv);
}
@ -226,13 +225,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new Complex32[order];
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -255,7 +254,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -266,7 +265,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
}
var work = new Complex32[order];
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -286,7 +285,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -301,7 +300,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.c_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -327,7 +326,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -347,7 +346,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.c_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -366,22 +365,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.c_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -406,7 +405,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -416,7 +415,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -426,7 +425,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.c_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -449,7 +448,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -484,7 +483,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -494,7 +493,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.c_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -518,7 +517,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -528,7 +527,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.c_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.c_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -544,7 +543,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] tau, QRMethod method = QRMethod.Full)
public override void QRFactor(Complex32[] r, int rowsR, int columnsR, Complex32[] q, Complex32[] tau)
{
if (r == null)
{
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -566,12 +565,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new Complex32[columnsR * Control.BlockSize];
var work = new Complex32[columnsR*Control.BlockSize];
SafeNativeMethods.c_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -608,7 +607,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -618,14 +617,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -642,7 +641,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x)
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -659,17 +658,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -679,7 +678,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex32[columns * Control.BlockSize];
var work = new Complex32[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -696,7 +695,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work)
public override void QRSolve(Complex32[] a, int rows, int columns, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -718,17 +717,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -740,7 +739,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -761,7 +760,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x)
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -783,22 +782,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -807,8 +806,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new Complex32[columnsR * Control.BlockSize];
var work = new Complex32[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -829,7 +828,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work)
public override void QRSolveFactored(Complex32[] q, Complex32[] r, int rowsR, int columnsR, Complex32[] tau, Complex32[] b, int columnsB, Complex32[] x, Complex32[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -856,22 +855,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -883,7 +882,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -926,12 +925,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -941,7 +940,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new Complex32[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex32[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -971,20 +970,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new Complex32[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex32[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var s = new Complex32[Math.Min(rowsA, columnsA)];
var u = new Complex32[rowsA * rowsA];
var vt = new Complex32[columnsA * columnsA];
var u = new Complex32[rowsA*rowsA];
var vt = new Complex32[columnsA*columnsA];
var clone = new Complex32[a.Length];
a.Copy(clone);
@ -1036,12 +1035,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1056,9 +1055,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
if (work.Length < (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
{
work[0] = (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
work[0] = (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

145
src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.double.cs

@ -31,13 +31,12 @@
#if NATIVEGOTO
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
using System;
using System.Security;
using Properties;
/// <summary>
/// GotoBLAS2 linear algebra provider.
/// </summary>
@ -95,8 +94,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -164,9 +163,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -199,7 +198,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -208,7 +207,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.d_lu_factor(order, data, ipiv);
}
@ -226,13 +225,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new double[order];
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -255,7 +254,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -266,7 +265,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
}
var work = new double[order];
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -286,7 +285,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -301,7 +300,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.d_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -327,7 +326,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -347,7 +346,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.d_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -366,22 +365,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.d_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -406,7 +405,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -416,7 +415,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -426,7 +425,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.d_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -449,7 +448,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -484,7 +483,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -494,7 +493,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.d_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -518,7 +517,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -528,7 +527,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.d_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.d_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -544,7 +543,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] tau, QRMethod method = QRMethod.Full)
public override void QRFactor(double[] r, int rowsR, int columnsR, double[] q, double[] tau)
{
if (r == null)
{
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -566,12 +565,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new double[columnsR * Control.BlockSize];
var work = new double[columnsR*Control.BlockSize];
SafeNativeMethods.d_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -608,7 +607,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -618,14 +617,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -642,7 +641,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x)
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -659,17 +658,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -679,7 +678,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new double[columns * Control.BlockSize];
var work = new double[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -696,7 +695,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, double[] work)
public override void QRSolve(double[] a, int rows, int columns, double[] b, int columnsB, double[] x, double[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -718,17 +717,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -740,7 +739,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -761,7 +760,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x)
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -783,22 +782,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -807,8 +806,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new double[columnsR * Control.BlockSize];
var work = new double[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -829,7 +828,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, double[] work)
public override void QRSolveFactored(double[] q, double[] r, int rowsR, int columnsR, double[] tau, double[] b, int columnsB, double[] x, double[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -856,22 +855,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -883,7 +882,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -926,12 +925,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -941,7 +940,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new double[Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))];
var work = new double[Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA))];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -971,20 +970,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new double[Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))];
var work = new double[Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA))];
var s = new double[Math.Min(rowsA, columnsA)];
var u = new double[rowsA * rowsA];
var vt = new double[columnsA * columnsA];
var u = new double[rowsA*rowsA];
var vt = new double[columnsA*columnsA];
var clone = new double[a.Length];
a.Copy(clone);
@ -1036,12 +1035,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1056,9 +1055,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA)))
if (work.Length < Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA)))
{
work[0] = Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA));
work[0] = Math.Max((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5*Math.Min(rowsA, columnsA));
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

141
src/Numerics/Providers/LinearAlgebra/GotoBlas/GotoBlasLinearAlgebraProvider.float.cs

@ -31,13 +31,12 @@
#if NATIVEGOTO
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
using System;
using System.Security;
using Properties;
/// <summary>
/// GotoBLAS2 linear algebra provider.
/// </summary>
@ -95,8 +94,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -164,9 +163,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -199,7 +198,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -208,7 +207,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.s_lu_factor(order, data, ipiv);
}
@ -226,13 +225,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new float[order];
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -255,7 +254,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -286,7 +285,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -301,7 +300,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -327,7 +326,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -366,22 +365,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.s_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -406,7 +405,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -416,7 +415,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -426,7 +425,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.s_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -449,7 +448,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -484,7 +483,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -494,7 +493,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.s_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -518,7 +517,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -528,7 +527,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.s_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -544,7 +543,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] tau, QRMethod method = QRMethod.Full)
public override void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] tau)
{
if (r == null)
{
@ -556,7 +555,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -566,12 +565,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new float[columnsR * Control.BlockSize];
var work = new float[columnsR*Control.BlockSize];
SafeNativeMethods.s_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -608,7 +607,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -618,14 +617,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -642,7 +641,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x)
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -659,17 +658,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -679,7 +678,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columns * Control.BlockSize];
var work = new float[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
@ -696,7 +695,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, float[] work)
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, float[] work, QRMethod method = QRMethod.Full)
{
if (a == null)
{
@ -718,17 +717,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -740,7 +739,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -761,7 +760,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x)
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -783,22 +782,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -807,8 +806,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columnsR * Control.BlockSize];
var work = new float[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
@ -829,7 +828,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, float[] work)
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, float[] work, QRMethod method = QRMethod.Full)
{
if (r == null)
{
@ -856,22 +855,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
if (b.Length != rowsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
if (x.Length != columnsR*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -883,7 +882,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
work[0] = rowsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -926,12 +925,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -941,7 +940,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
var work = new float[Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA))];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -971,20 +970,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
var work = new float[Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA))];
var s = new float[Math.Min(rowsA, columnsA)];
var u = new float[rowsA * rowsA];
var vt = new float[columnsA * columnsA];
var u = new float[rowsA*rowsA];
var vt = new float[columnsA*columnsA];
var clone = new float[a.Length];
a.Copy(clone);
@ -1036,12 +1035,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1056,9 +1055,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA)))
if (work.Length < Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA)))
{
work[0] = Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA));
work[0] = Math.Max(((3*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5*Math.Min(rowsA, columnsA));
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}

42
src/Numerics/Providers/LinearAlgebra/GotoBlas/SafeNativeMethods.cs

@ -44,10 +44,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
/// <summary>
/// Name of the native DLL.
/// </summary>
private const string DllName = "MathNET.Numerics.GotoBLAS2.dll";
const string DllName = "MathNET.Numerics.GotoBLAS2.dll";
#region BLAS
#region BLAS
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y);
@ -59,7 +59,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_scale(int n, float alpha, [Out] float[] x);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_dot_product(int n, float[] x, float[] y);
@ -83,22 +83,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out]float[] c);
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c);
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out]Complex32[] c);
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out]Complex[] c);
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c);
#endregion BLAS
#region LAPACK
#endregion BLAS
#region LAPACK
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a, [In, Out] float[] work);
@ -123,7 +123,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_cholesky_factor(int n, [In, Out] Complex[] a);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_factor(int n, [In, Out] float[] a, [In, Out] int[] ipiv);
@ -153,15 +153,15 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_inverse_factored(int n, [In, Out] double[] a, [In, Out] int[] ipiv, [In, Out] double[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int c_lu_inverse_factored(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out]int[] ipiv, [In, Out] float[] b);
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_solve_factored(int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b);
@ -170,7 +170,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
internal static extern int c_lu_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out]int[] ipiv, [In, Out] Complex[] b);
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -182,7 +182,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
internal static extern int c_lu_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_cholesky_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -256,7 +256,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.GotoBlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_svd_factor(bool computeVectors, int m, int n, [In, Out] Complex[] a, [In, Out] Complex[] s, [In, Out] Complex[] u, [In, Out] Complex[] v, [In, Out] Complex[] work, int len);
#endregion LAPACK
#endregion LAPACK
}
}

503
src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs

@ -28,17 +28,518 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Factorization;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
#endif
/// <summary>
/// How to transpose a matrix.
/// </summary>
public enum Transpose
{
/// <summary>
/// Don't transpose a matrix.
/// </summary>
DontTranspose = 111,
/// <summary>
/// Transpose a matrix.
/// </summary>
Transpose = 112,
/// <summary>
/// Conjugate transpose a complex matrix.
/// </summary>
/// <remarks>If a conjugate transpose is used with a real matrix, then the matrix is just transposed.</remarks>
ConjugateTranspose = 113
}
/// <summary>
/// Types of matrix norms.
/// </summary>
public enum Norm : byte
{
/// <summary>
/// The 1-norm.
/// </summary>
OneNorm = (byte) '1',
/// <summary>
/// The Frobenius norm.
/// </summary>
FrobeniusNorm = (byte) 'f',
/// <summary>
/// The infinity norm.
/// </summary>
InfinityNorm = (byte) 'i',
/// <summary>
/// The largest absolute value norm.
/// </summary>
LargestAbsoluteValue = (byte) 'm'
}
/// <summary>
/// Interface to linear algebra algorithms that work off 1-D arrays.
/// </summary>
public interface ILinearAlgebraProvider :
ILinearAlgebraProvider<double, double>,
ILinearAlgebraProvider<float, float>,
ILinearAlgebraProvider<Complex, double>,
ILinearAlgebraProvider<Complex32, float>
{
}
/// <summary>
/// Interface to linear algebra algorithms that work off 1-D arrays.
/// </summary>
public interface ILinearAlgebraProvider : ILinearAlgebraProvider<double, double>, ILinearAlgebraProvider<float, float>, ILinearAlgebraProvider<Complex, double>, ILinearAlgebraProvider<Complex32, float>
/// <typeparam name="T">Supported data types are double, single, Complex, and Complex32.</typeparam>
public interface ILinearAlgebraProvider<T, TNorm>
where T : struct
where TNorm : struct
{
/*/// <summary>
/// Queries the provider for the optimal, workspace block size
/// for the given routine.
/// </summary>
/// <param name="methodName">Name of the method to query.</param>
/// <returns>-1 if the provider cannot compute the workspace size; otherwise
/// the suggested block size.</returns>
int QueryWorkspaceBlockSize(string methodName);*/
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
/// <param name="y">The vector to update.</param>
/// <param name="alpha">The value to scale <paramref name="x"/> by.</param>
/// <param name="x">The vector to add to <paramref name="y"/>.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>This is similar to the AXPY BLAS routine.</remarks>
void AddVectorToScaledVector(T[] y, T alpha, T[] x, T[] result);
/// <summary>
/// Scales an array. Can be used to scale a vector and a matrix.
/// </summary>
/// <param name="alpha">The scalar.</param>
/// <param name="x">The values to scale.</param>
/// <param name="result">This result of the scaling.</param>
/// <remarks>This is similar to the SCAL BLAS routine.</remarks>
void ScaleArray(T alpha, T[] x, T[] result);
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
/// <param name="x">The vector x.</param>
/// <param name="y">The vector y.</param>
/// <returns>The dot product of x and y.</returns>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
T DotProduct(T[] x, T[] y);
/// <summary>
/// Does a point wise add of two arrays <c>z = x + y</c>. This can be used
/// to add vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void AddArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise subtraction of two arrays <c>z = x - y</c>. This can be used
/// to subtract vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the subtraction.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void SubtractArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise multiplication of two arrays <c>z = x * y</c>. This can be used
/// to multiply elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise multiplication.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void PointWiseMultiplyArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise division of two arrays <c>z = x / y</c>. This can be used
/// to divide elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise division.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void PointWiseDivideArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
T MatrixNorm(Norm norm, int rows, int columns, T[] matrix);
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/>
/// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
T MatrixNorm(Norm norm, int rows, int columns, T[] matrix, TNorm[] work);
/// <summary>
/// Multiples two matrices. <c>result = x * y</c>
/// </summary>
/// <param name="x">The x matrix.</param>
/// <param name="rowsX">The number of rows in the x matrix.</param>
/// <param name="columnsX">The number of columns in the x matrix.</param>
/// <param name="y">The y matrix.</param>
/// <param name="rowsY">The number of rows in the y matrix.</param>
/// <param name="columnsY">The number of columns in the y matrix.</param>
/// <param name="result">Where to store the result of the multiplication.</param>
/// <remarks>This is a simplified version of the BLAS GEMM routine with alpha
/// set to 1.0 and beta set to 0.0, and x and y are not transposed.</remarks>
void MatrixMultiply(T[] x, int rowsX, int columnsX, T[] y, int rowsY, int columnsY, T[] result);
/// <summary>
/// Multiplies two matrices and updates another with the result. <c>c = alpha*op(a)*op(b) + beta*c</c>
/// </summary>
/// <param name="transposeA">How to transpose the <paramref name="a"/> matrix.</param>
/// <param name="transposeB">How to transpose the <paramref name="b"/> matrix.</param>
/// <param name="alpha">The value to scale <paramref name="a"/> matrix.</param>
/// <param name="a">The a matrix.</param>
/// <param name="rowsA">The number of rows in the <paramref name="a"/> matrix.</param>
/// <param name="columnsA">The number of columns in the <paramref name="a"/> matrix.</param>
/// <param name="b">The b matrix</param>
/// <param name="rowsB">The number of rows in the <paramref name="b"/> matrix.</param>
/// <param name="columnsB">The number of columns in the <paramref name="b"/> matrix.</param>
/// <param name="beta">The value to scale the <paramref name="c"/> matrix.</param>
/// <param name="c">The c matrix.</param>
void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, T alpha, T[] a, int rowsA, int columnsA, T[] b, int rowsB, int columnsB, T beta, T[] c);
/// <summary>
/// Computes the LUP factorization of A. P*A = L*U.
/// </summary>
/// <param name="data">An <paramref name="order"/> by <paramref name="order"/> matrix. The matrix is overwritten with the
/// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of <paramref name="data"/> (the diagonal is always 1.0
/// for the L factor). The upper triangular factor U is stored on and above the diagonal of <paramref name="data"/>.</param>
/// <param name="order">The order of the square matrix <paramref name="data"/>.</param>
/// <param name="ipiv">On exit, it contains the pivot indices. The size of the array must be <paramref name="order"/>.</param>
/// <remarks>This is equivalent to the GETRF LAPACK routine.</remarks>
void LUFactor(T[] data, int order, int[] ipiv);
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
void LUInverse(T[] a, int order);
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
void LUInverseFactored(T[] a, int order, int[] ipiv);
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
void LUInverse(T[] a, int order, T[] work);
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
void LUInverseFactored(T[] a, int order, int[] ipiv, T[] work);
/// <summary>
/// Solves A*X=B for X using LU factorization.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The square matrix A.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRF and GETRS LAPACK routines.</remarks>
void LUSolve(int columnsOfB, T[] a, int order, T[] b);
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The factored A matrix.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRS LAPACK routine.</remarks>
void LUSolveFactored(int columnsOfB, T[] a, int order, int[] ipiv, T[] b);
/// <summary>
/// Computes the Cholesky factorization of A.
/// </summary>
/// <param name="a">On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the
/// the Cholesky factorization.</param>
/// <param name="order">The number of rows or columns in the matrix.</param>
/// <remarks>This is equivalent to the POTRF LAPACK routine.</remarks>
void CholeskyFactor(T[] a, int order);
/// <summary>
/// Solves A*X=B for X using Cholesky factorization.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRF add POTRS LAPACK routines.</remarks>
void CholeskySolve(T[] a, int orderA, T[] b, int columnsB);
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRS LAPACK routine.</remarks>
void CholeskySolveFactored(T[] a, int orderA, T[] b, int columnsB);
/// <summary>
/// Computes the full QR factorization of A.
/// </summary>
/// <param name="a">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="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(T[] a, int rowsA, int columnsA, T[] q, T[] tau);
/// <summary>
/// Computes the full QR factorization of A.
/// </summary>
/// <param name="a">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="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(T[] a, int rowsA, int columnsA, T[] q, T[] tau, T[] work);
/// <summary>
/// Computes the thin QR factorization of A where M &gt; N.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the Q matrix of the QR factorization.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="r">On exit, A N by N matrix that holds the R matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void ThinQRFactor(T[] a, int rowsA, int columnsA, T[] r, T[] tau);
/// <summary>
/// Computes the thin QR factorization of A where M &gt; N.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the Q matrix of the QR factorization.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="r">On exit, A N by N matrix that holds the R matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void ThinQRFactor(T[] a, int rowsA, int columnsA, T[] r, T[] tau, T[] work);
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
void QRSolve(T[] a, int rows, int columns, T[] b, int columnsB, T[] x, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
void QRSolve(T[] a, int rows, int columns, T[] b, int columnsB, T[] x, T[] work, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by QR factor. This is only used for the managed provider and can be
/// <c>null</c> for the native provider. The native provider uses the Q portion stored in the R matrix.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(T[],int,int,T[],T[])"/>. </param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
void QRSolveFactored(T[] q, T[] r, int rowsA, int columnsA, T[] tau, T[] b, int columnsB, T[] x, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by QR factor. This is only used for the managed provider and can be
/// <c>null</c> for the native provider. The native provider uses the Q portion stored in the R matrix.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(T[],int,int,T[],T[])"/>. </param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array - only used in the native provider. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
void QRSolveFactored(T[] q, T[] r, int rowsA, int columnsA, T[] tau, T[] b, int columnsB, T[] x, T[] work, QRMethod method = QRMethod.Full);
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value. </param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
void SingularValueDecomposition(bool computeVectors, T[] a, int rowsA, int columnsA, T[] s, T[] u, T[] vt);
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value. </param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <param name="work">The work array. On exit, work[0] contains the optimal work size value.
/// </param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
void SingularValueDecomposition(bool computeVectors, T[] a, int rowsA, int columnsA, T[] s, T[] u, T[] vt, T[] work);
/// <summary>
/// Solves A*X=B for X using the singular value decomposition of A.
/// </summary>
/// <param name="a">On entry, the M by N matrix to decompose.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
void SvdSolve(T[] a, int rowsA, int columnsA, T[] b, int columnsB, T[] x);
/// <summary>
/// Solves A*X=B for X using a previously SVD decomposed matrix.
/// </summary>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The s values returned by <see cref="SingularValueDecomposition(bool,T[],int,int,T[],T[],T[])"/>.</param>
/// <param name="u">The left singular vectors returned by <see cref="SingularValueDecomposition(bool,T[],int,int, T[],T[],T[])"/>.</param>
/// <param name="vt">The right singular vectors returned by <see cref="SingularValueDecomposition(bool,T[],int,int,T[],T[],T[],T[])"/>.</param>
/// <param name="b">The B matrix</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
void SvdSolveFactored(int rowsA, int columnsA, T[] s, T[] u, T[] vt, T[] b, int columnsB, T[] x);
/// <summary>
/// Computes the eigenvalues and eigenvectors of a matrix.
/// </summary>
/// <param name="isSymmetric">Wether the matrix is symmetric or not.</param>
/// <param name="order">The order of the matrix.</param>
/// <param name="matrix">The matrix to decompose. The lenth of the array must be order * order.</param>
/// <param name="matrixEv">On output, the matrix contains the eigen vectors. The lenth of the array must be order * order.</param>
/// <param name="vectorEv">On output, the eigen values (λ) of matrix in ascending value. The length of the arry must <paramref name="order"/>.</param>
/// <param name="matrixD">On output, the block diagonal eigenvalue matrix. The lenth of the array must be order * order.</param>
void EigenDecomp(bool isSymmetric, int order, T[] matrix, T[] matrixEv, Complex[] vectorEv, T[] matrixD);
}
}

533
src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProviderOfT.cs

@ -1,533 +0,0 @@
// <copyright file="ILinearAlgebraProviderOfT.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Factorization;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
#endif
/// <summary>
/// How to transpose a matrix.
/// </summary>
public enum Transpose
{
/// <summary>
/// Don't transpose a matrix.
/// </summary>
DontTranspose = 111,
/// <summary>
/// Transpose a matrix.
/// </summary>
Transpose = 112,
/// <summary>
/// Conjugate transpose a complex matrix.
/// </summary>
/// <remarks>If a conjugate transpose is used with a real matrix, then the matrix is just transposed.</remarks>
ConjugateTranspose = 113
}
/// <summary>
/// Types of matrix norms.
/// </summary>
public enum Norm : byte
{
/// <summary>
/// The 1-norm.
/// </summary>
OneNorm = (byte)'1',
/// <summary>
/// The Frobenius norm.
/// </summary>
FrobeniusNorm = (byte)'f',
/// <summary>
/// The infinity norm.
/// </summary>
InfinityNorm = (byte)'i',
/// <summary>
/// The largest absolute value norm.
/// </summary>
LargestAbsoluteValue = (byte)'m'
}
/// <summary>
/// Interface to linear algebra algorithms that work off 1-D arrays.
/// </summary>
/// <typeparam name="T">Supported data types are double, single, Complex, and Complex32.</typeparam>
public interface ILinearAlgebraProvider<T,TNorm>
where T : struct
where TNorm : struct
{
/*/// <summary>
/// Queries the provider for the optimal, workspace block size
/// for the given routine.
/// </summary>
/// <param name="methodName">Name of the method to query.</param>
/// <returns>-1 if the provider cannot compute the workspace size; otherwise
/// the suggested block size.</returns>
int QueryWorkspaceBlockSize(string methodName);*/
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
/// <param name="y">The vector to update.</param>
/// <param name="alpha">The value to scale <paramref name="x"/> by.</param>
/// <param name="x">The vector to add to <paramref name="y"/>.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>This is similar to the AXPY BLAS routine.</remarks>
void AddVectorToScaledVector(T[] y, T alpha, T[] x, T[] result);
/// <summary>
/// Scales an array. Can be used to scale a vector and a matrix.
/// </summary>
/// <param name="alpha">The scalar.</param>
/// <param name="x">The values to scale.</param>
/// <param name="result">This result of the scaling.</param>
/// <remarks>This is similar to the SCAL BLAS routine.</remarks>
void ScaleArray(T alpha, T[] x, T[] result);
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
/// <param name="x">The vector x.</param>
/// <param name="y">The vector y.</param>
/// <returns>The dot product of x and y.</returns>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
T DotProduct(T[] x, T[] y);
/// <summary>
/// Does a point wise add of two arrays <c>z = x + y</c>. This can be used
/// to add vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void AddArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise subtraction of two arrays <c>z = x - y</c>. This can be used
/// to subtract vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the subtraction.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void SubtractArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise multiplication of two arrays <c>z = x * y</c>. This can be used
/// to multiply elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise multiplication.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void PointWiseMultiplyArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Does a point wise division of two arrays <c>z = x / y</c>. This can be used
/// to divide elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise division.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
void PointWiseDivideArrays(T[] x, T[] y, T[] result);
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
T MatrixNorm(Norm norm, int rows, int columns, T[] matrix);
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/>
/// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
T MatrixNorm(Norm norm, int rows, int columns, T[] matrix, TNorm[] work);
/// <summary>
/// Multiples two matrices. <c>result = x * y</c>
/// </summary>
/// <param name="x">The x matrix.</param>
/// <param name="rowsX">The number of rows in the x matrix.</param>
/// <param name="columnsX">The number of columns in the x matrix.</param>
/// <param name="y">The y matrix.</param>
/// <param name="rowsY">The number of rows in the y matrix.</param>
/// <param name="columnsY">The number of columns in the y matrix.</param>
/// <param name="result">Where to store the result of the multiplication.</param>
/// <remarks>This is a simplified version of the BLAS GEMM routine with alpha
/// set to 1.0 and beta set to 0.0, and x and y are not transposed.</remarks>
void MatrixMultiply(T[] x, int rowsX, int columnsX, T[] y, int rowsY, int columnsY, T[] result);
/// <summary>
/// Multiplies two matrices and updates another with the result. <c>c = alpha*op(a)*op(b) + beta*c</c>
/// </summary>
/// <param name="transposeA">How to transpose the <paramref name="a"/> matrix.</param>
/// <param name="transposeB">How to transpose the <paramref name="b"/> matrix.</param>
/// <param name="alpha">The value to scale <paramref name="a"/> matrix.</param>
/// <param name="a">The a matrix.</param>
/// <param name="rowsA">The number of rows in the <paramref name="a"/> matrix.</param>
/// <param name="columnsA">The number of columns in the <paramref name="a"/> matrix.</param>
/// <param name="b">The b matrix</param>
/// <param name="rowsB">The number of rows in the <paramref name="b"/> matrix.</param>
/// <param name="columnsB">The number of columns in the <paramref name="b"/> matrix.</param>
/// <param name="beta">The value to scale the <paramref name="c"/> matrix.</param>
/// <param name="c">The c matrix.</param>
void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, T alpha, T[] a, int rowsA, int columnsA, T[] b, int rowsB, int columnsB, T beta, T[] c);
/// <summary>
/// Computes the LUP factorization of A. P*A = L*U.
/// </summary>
/// <param name="data">An <paramref name="order"/> by <paramref name="order"/> matrix. The matrix is overwritten with the
/// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of <paramref name="data"/> (the diagonal is always 1.0
/// for the L factor). The upper triangular factor U is stored on and above the diagonal of <paramref name="data"/>.</param>
/// <param name="order">The order of the square matrix <paramref name="data"/>.</param>
/// <param name="ipiv">On exit, it contains the pivot indices. The size of the array must be <paramref name="order"/>.</param>
/// <remarks>This is equivalent to the GETRF LAPACK routine.</remarks>
void LUFactor(T[] data, int order, int[] ipiv);
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
void LUInverse(T[] a, int order);
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
void LUInverseFactored(T[] a, int order, int[] ipiv);
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
void LUInverse(T[] a, int order, T[] work);
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
void LUInverseFactored(T[] a, int order, int[] ipiv, T[] work);
/// <summary>
/// Solves A*X=B for X using LU factorization.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The square matrix A.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRF and GETRS LAPACK routines.</remarks>
void LUSolve(int columnsOfB, T[] a, int order, T[] b);
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The factored A matrix.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRS LAPACK routine.</remarks>
void LUSolveFactored(int columnsOfB, T[] a, int order, int[] ipiv, T[] b);
/// <summary>
/// Computes the Cholesky factorization of A.
/// </summary>
/// <param name="a">On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the
/// the Cholesky factorization.</param>
/// <param name="order">The number of rows or columns in the matrix.</param>
/// <remarks>This is equivalent to the POTRF LAPACK routine.</remarks>
void CholeskyFactor(T[] a, int order);
/// <summary>
/// Solves A*X=B for X using Cholesky factorization.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRF add POTRS LAPACK routines.</remarks>
void CholeskySolve(T[] a, int orderA, T[] b, int columnsB);
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRS LAPACK routine.</remarks>
void CholeskySolveFactored(T[] a, int orderA, T[] b, int columnsB);
/// <summary>
/// Computes the full QR factorization of A.
/// </summary>
/// <param name="a">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="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(T[] a, int rowsA, int columnsA, T[] q, T[] tau);
/// <summary>
/// Computes the full QR factorization of A.
/// </summary>
/// <param name="a">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="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void QRFactor(T[] a, int rowsA, int columnsA, T[] q, T[] tau, T[] work);
/// <summary>
/// Computes the thin QR factorization of A where M &gt; N.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the Q matrix of the QR factorization.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="r">On exit, A N by N matrix that holds the R matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void ThinQRFactor(T[] a, int rowsA, int columnsA, T[] r, T[] tau);
/// <summary>
/// Computes the thin QR factorization of A where M &gt; N.
/// </summary>
/// <param name="a">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the Q matrix of the QR factorization.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="r">On exit, A N by N matrix that holds the R matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
void ThinQRFactor(T[] a, int rowsA, int columnsA, T[] r, T[] tau, T[] work);
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
void QRSolve(T[] a, int rows, int columns, T[] b, int columnsB, T[] x, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</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. On exit, work[0] contains the optimal
/// work size value.</param>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
void QRSolve(T[] a, int rows, int columns, T[] b, int columnsB, T[] x, T[] work, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by QR factor. This is only used for the managed provider and can be
/// <c>null</c> for the native provider. The native provider uses the Q portion stored in the R matrix.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(T[],int,int,T[],T[])"/>. </param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
void QRSolveFactored(T[] q, T[] r, int rowsA, int columnsA, T[] tau, T[] b, int columnsB, T[] x, QRMethod method = QRMethod.Full);
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by QR factor. This is only used for the managed provider and can be
/// <c>null</c> for the native provider. The native provider uses the Q portion stored in the R matrix.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(T[],int,int,T[],T[])"/>. </param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array - only used in the native provider. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
/// <param name="method">The type of QR factorization to perform. <seealso cref="QRMethod"/></param>
void QRSolveFactored(T[] q, T[] r, int rowsA, int columnsA, T[] tau, T[] b, int columnsB, T[] x, T[] work, QRMethod method = QRMethod.Full);
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value. </param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
void SingularValueDecomposition(bool computeVectors, T[] a, int rowsA, int columnsA, T[] s, T[] u, T[] vt);
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value. </param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <param name="work">The work array. On exit, work[0] contains the optimal work size value.
/// </param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
void SingularValueDecomposition(bool computeVectors, T[] a, int rowsA, int columnsA, T[] s, T[] u, T[] vt, T[] work);
/// <summary>
/// Solves A*X=B for X using the singular value decomposition of A.
/// </summary>
/// <param name="a">On entry, the M by N matrix to decompose.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
void SvdSolve(T[] a, int rowsA, int columnsA, T[] b, int columnsB, T[] x);
/// <summary>
/// Solves A*X=B for X using a previously SVD decomposed matrix.
/// </summary>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The s values returned by <see cref="SingularValueDecomposition(bool,T[],int,int,T[],T[],T[])"/>.</param>
/// <param name="u">The left singular vectors returned by <see cref="SingularValueDecomposition(bool,T[],int,int, T[],T[],T[])"/>.</param>
/// <param name="vt">The right singular vectors returned by <see cref="SingularValueDecomposition(bool,T[],int,int,T[],T[],T[],T[])"/>.</param>
/// <param name="b">The B matrix</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
void SvdSolveFactored(int rowsA, int columnsA, T[] s, T[] u, T[] vt, T[] b, int columnsB, T[] x);
/// <summary>
/// Computes the eigenvalues and eigenvectors of a matrix.
/// </summary>
/// <param name="isSymmetric">Wether the matrix is symmetric or not.</param>
/// <param name="order">The order of the matrix.</param>
/// <param name="matrix">The matrix to decompose. The lenth of the array must be order * order.</param>
/// <param name="matrixEv">On output, the matrix contains the eigen vectors. The lenth of the array must be order * order.</param>
/// <param name="vectorEv">On output, the eigen values (λ) of matrix in ascending value. The length of the arry must <paramref name="order"/>.</param>
/// <param name="matrixD">On output, the block diagonal eigenvalue matrix. The lenth of the array must be order * order.</param>
void EigenDecomp(bool isSymmetric, int order, T[] matrix, T[] matrixEv, Complex[] vectorEv, T[] matrixD);
}
}

20
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs

@ -1854,7 +1854,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
});
work[tmp] += 1.0;
var s = (1.0 / work[tmp]).SquareRoot();
var s = (1.0/work[tmp]).SquareRoot();
CommonParallel.For(0, rowCount - row, 4096, (u, v) =>
{
for (int i = u; i < v; i++)
@ -2110,7 +2110,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
// Fill result matrix
for (var col = 0; col < columnsB; col++)
{
Array.Copy(sol, col * rowsA, x, col * columnsA, columnsR);
Array.Copy(sol, col*rowsA, x, col*columnsA, columnsR);
}
}
@ -3013,9 +3013,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentNullException("matrix");
}
if (matrix.Length != order * order)
if (matrix.Length != order*order)
{
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order * order), "matrix");
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order*order), "matrix");
}
if (matrixEv == null)
@ -3023,9 +3023,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentNullException("matrixEv");
}
if (matrixEv.Length != order * order)
if (matrixEv.Length != order*order)
{
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order * order), "matrixEv");
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order*order), "matrixEv");
}
if (vectorEv == null)
@ -3043,9 +3043,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
throw new ArgumentNullException("matrixD");
}
if (matrixD.Length != order * order)
if (matrixD.Length != order*order)
{
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order * order), "matrixD");
throw new ArgumentException(String.Format(Resources.ArgumentArrayWrongLength, order*order), "matrixD");
}
var matrixCopy = new Complex[matrix.Length];
Array.Copy(matrix, matrixCopy, matrix.Length);
@ -3071,9 +3071,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
DenseEvd.NonsymmetricReduceHessenberToRealSchur(vectorEv, matrixEv, matrixCopy, order);
}
for (var i = 0; i < order; i ++)
for (var i = 0; i < order; i++)
{
matrixD[i * order + i] = vectorEv[i];
matrixD[i*order + i] = vectorEv[i];
}
}
}

520
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs

File diff suppressed because it is too large

509
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs

File diff suppressed because it is too large

496
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs

File diff suppressed because it is too large

40
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Common.cs

@ -70,9 +70,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new float[rows];
@ -109,9 +109,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -119,7 +119,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.s_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.s_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -150,9 +150,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new double[rows];
@ -189,9 +189,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -199,7 +199,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.d_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.d_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -230,9 +230,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new float[rows];
@ -269,9 +269,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -279,7 +279,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.c_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.c_matrix_norm((byte) norm, rows, columns, matrix, work);
}
/// <summary>
@ -310,9 +310,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
var work = new double[rows];
@ -349,9 +349,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "columns");
}
if (matrix.Length < rows * columns)
if (matrix.Length < rows*columns)
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows * columns), "matrix");
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows*columns), "matrix");
}
if (work.Length < rows)
@ -359,7 +359,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, rows), "work");
}
return SafeNativeMethods.z_matrix_norm((byte)norm, rows, columns, matrix, work);
return SafeNativeMethods.z_matrix_norm((byte) norm, rows, columns, matrix, work);
}
}
}

136
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
return SafeNativeMethods.z_dot_product(x.Length, x, y);
}
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
@ -123,8 +123,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
if (x == null)
{
throw new ArgumentNullException("x");
}
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
@ -192,9 +192,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
if (c.Length != m*n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
@ -227,7 +227,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
if (data.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
@ -236,7 +236,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.z_lu_factor(order, data, ipiv);
}
@ -254,13 +254,13 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new Complex[order];
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -283,7 +283,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -294,7 +294,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
}
var work = new Complex[order];
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -314,7 +314,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -329,7 +329,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
SafeNativeMethods.z_lu_inverse(order, a, work, work.Length);
}
/// <summary>
@ -355,7 +355,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -375,7 +375,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
SafeNativeMethods.z_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
@ -394,22 +394,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_lu_solve(order, columnsOfB, a, b);
SafeNativeMethods.z_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
@ -434,7 +434,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -444,7 +444,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
if (b.Length != columnsOfB*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -454,7 +454,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_lu_solve_factored(order, columnsOfB, a, ipiv, b);
SafeNativeMethods.z_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
@ -477,7 +477,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
if (a.Length != order*order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
@ -512,7 +512,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -522,7 +522,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_cholesky_solve(orderA, columnsB, a, b);
SafeNativeMethods.z_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
@ -546,7 +546,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
if (b.Length != orderA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
@ -556,7 +556,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.z_cholesky_solve_factored(orderA, columnsB, a, b);
SafeNativeMethods.z_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
@ -584,7 +584,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -594,12 +594,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
SafeNativeMethods.z_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
@ -636,7 +636,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
@ -646,14 +646,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
if (q.Length != rowsR*rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
if (work.Length < columnsR*Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
work[0] = columnsR*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -674,7 +674,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[SecuritySafeCritical]
public override void QRSolve(Complex[] a, int rows, int columns, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
var work = new Complex[columns * Control.BlockSize];
var work = new Complex[columns*Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work, method);
}
@ -715,17 +715,17 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
if (a.Length != rows*columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
if (b.Length != rows*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
if (x.Length != columns*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
@ -737,7 +737,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
work[0] = rows*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -761,7 +761,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[SecuritySafeCritical]
public override void QRSolveFactored(Complex[] q, Complex[] r, int rowsR, int columnsR, Complex[] tau, Complex[] b, int columnsB, Complex[] x, QRMethod method = QRMethod.Full)
{
var work = new Complex[columnsR * Control.BlockSize];
var work = new Complex[columnsR*Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work, method);
}
@ -823,29 +823,29 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
columnsQ = rowsR = columnsR = columnsA;
}
if (r.Length != rowsR * columnsR)
if (r.Length != rowsR*columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsR * columnsR), "r");
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsR*columnsR), "r");
}
if (q.Length != rowsQ * columnsQ)
if (q.Length != rowsQ*columnsQ)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsQ * columnsQ), "q");
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsQ*columnsQ), "q");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsA * columnsB), "b");
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, rowsA*columnsB), "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, columnsA * columnsB), "x");
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, columnsA*columnsB), "x");
}
if (work.Length < 1)
{
work[0] = rowsA * Control.BlockSize;
work[0] = rowsA*Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -897,12 +897,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -912,7 +912,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
@ -942,20 +942,20 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
if (b.Length != rowsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
if (x.Length != columnsA*columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new Complex[(2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var work = new Complex[(2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)];
var s = new Complex[Math.Min(rowsA, columnsA)];
var u = new Complex[rowsA * rowsA];
var vt = new Complex[columnsA * columnsA];
var u = new Complex[rowsA*rowsA];
var vt = new Complex[columnsA*columnsA];
var clone = new Complex[a.Length];
a.Copy(clone);
@ -1007,12 +1007,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
if (u.Length != rowsA*rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
if (vt.Length != columnsA*columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
@ -1027,9 +1027,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
if (work.Length < (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA))
{
work[0] = (2 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
work[0] = (2*Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA);
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
@ -1062,7 +1062,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
@ -1097,12 +1097,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.z_vector_subtract(x.Length, x, y, result);
}
@ -1132,12 +1132,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.z_vector_multiply(x.Length, x, y, result);
}
@ -1167,12 +1167,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.z_vector_divide(x.Length, x, y, result);
}
}

58
src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs

@ -44,10 +44,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// <summary>
/// Name of the native DLL.
/// </summary>
private const string DllName = "MathNet.Numerics.MKL.dll";
const string DllName = "MathNet.Numerics.MKL.dll";
#region BLAS
#region BLAS
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_axpy(int n, float alpha, float[] x, [In, Out] float[] y);
@ -59,7 +59,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_axpy(int n, Complex alpha, Complex[] x, [In, Out] Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_scale(int n, float alpha, [Out] float[] x);
@ -71,7 +71,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, Complex alpha, [In, Out] Complex[] x);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_dot_product(int n, float[] x, float[] y);
@ -83,22 +83,22 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out]float[] c);
internal static extern void s_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, float alpha, float[] x, float[] y, float beta, [In, Out] float[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out]double[] c);
internal static extern void d_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, double alpha, double[] x, double[] y, double beta, [In, Out] double[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out]Complex32[] c);
internal static extern void c_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex32 alpha, Complex32[] x, Complex32[] y, Complex32 beta, [In, Out] Complex32[] c);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out]Complex[] c);
internal static extern void z_matrix_multiply(Transpose transA, Transpose transB, int m, int n, int k, Complex alpha, Complex[] x, Complex[] y, Complex beta, [In, Out] Complex[] c);
#endregion BLAS
#endregion BLAS
#region LAPACK
#region LAPACK
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a, [In, Out] float[] work);
@ -123,7 +123,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_cholesky_factor(int n, [In, Out] Complex[] a);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_factor(int n, [In, Out] float[] a, [In, Out] int[] ipiv);
@ -153,15 +153,15 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_inverse_factored(int n, [In, Out] double[] a, [In, Out] int[] ipiv, [In, Out] double[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int c_lu_inverse_factored(int n, [In, Out] Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_inverse_factored(int n, [In, Out] Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] work, int lwork);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out]int[] ipiv, [In, Out] float[] b);
internal static extern int s_lu_solve_factored(int n, int nrhs, float[] a, [In, Out] int[] ipiv, [In, Out] float[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_lu_solve_factored(int n, int nrhs, double[] a, [In, Out] int[] ipiv, [In, Out] double[] b);
@ -170,7 +170,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
internal static extern int c_lu_solve_factored(int n, int nrhs, Complex32[] a, [In, Out] int[] ipiv, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out]int[] ipiv, [In, Out] Complex[] b);
internal static extern int z_lu_solve_factored(int n, int nrhs, Complex[] a, [In, Out] int[] ipiv, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_lu_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -182,7 +182,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
internal static extern int c_lu_solve(int n, int nrhs, Complex32[] a, [In, Out] Complex32[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
internal static extern int z_lu_solve(int n, int nrhs, Complex[] a, [In, Out] Complex[] b);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int s_cholesky_solve(int n, int nrhs, float[] a, [In, Out] float[] b);
@ -272,18 +272,18 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
internal static extern int s_eigen(bool isSymmetric, int n, [In] float[] a, [In, Out] float[] vectors, [In, Out] Complex[] values, [In, Out] float[] d);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int d_eigen(bool isSymmetric, int n, [In] double[] a, [In, Out] double[] vectors, [In, Out] Complex[] values, [In, Out] double[] d);
internal static extern int d_eigen(bool isSymmetric, int n, [In] double[] a, [In, Out] double[] vectors, [In, Out] Complex[] values, [In, Out] double[] d);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int c_eigen(bool isSymmetric, int n, [In] Complex32[] a, [In, Out] Complex32[] vectors, [In, Out] Complex[] values, [In, Out] Complex32[] d);
internal static extern int c_eigen(bool isSymmetric, int n, [In] Complex32[] a, [In, Out] Complex32[] vectors, [In, Out] Complex[] values, [In, Out] Complex32[] d);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern int z_eigen(bool isSymmetric, int n, [In] Complex[] a, [In, Out] Complex[] vectors, [In, Out] Complex[] values, [In, Out] Complex[] d);
#endregion LAPACK
internal static extern int z_eigen(bool isSymmetric, int n, [In] Complex[] a, [In, Out] Complex[] vectors, [In, Out] Complex[] values, [In, Out] Complex[] d);
#endregion LAPACK
#region Vector Functions
#region Vector Functions
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void s_vector_add(int n, float[] x, float[] y, [In, Out] float[] result);
@ -331,8 +331,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_vector_divide(int n, Complex[] x, Complex[] y, [In, Out] Complex[] result);
#endregion Vector Functions
#endregion Vector Functions
}
}

Loading…
Cancel
Save