Browse Source

adding dot product

la-knuth
Marcus Cuda 17 years ago
parent
commit
b540acb3fe
  1. 156
      src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs
  2. 14
      src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs
  3. 16
      src/Numerics/Algorithms/LinearAlgebra/ILinearAlgebraProviderOfT.cs
  4. 156
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
  5. 14
      src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs
  6. 152
      src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include
  7. 12
      src/Numerics/Algorithms/LinearAlgebra/SafeNativeMethods.include
  8. 11
      src/Numerics/Properties/Resources.Designer.cs

156
src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs

@ -24,7 +24,11 @@
/* This file is automatically generated - do not modify it.
Change NativeLinearAlgebraProvider.include instead.
<<<<<<< HEAD:src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs
Last generated on: 14/11/2009 20:09:22
=======
Last generated on: 11/13/2009 9:49:35 AM
>>>>>>> c1c4de3... adding dot product:src/Numerics/Algorithms/LinearAlgebra/Atlas/AtlasLinearAlgebraProvider.cs
*/
namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
{
@ -36,7 +40,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// </summary>
public class AtlasLinearAlgebraProvider : ILinearAlgebraProvider
{
#region ILinearAlgebraProvider<double> Members
#region ILinearAlgebraProvider<double> Members
/// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
@ -78,6 +82,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(double alpha, double[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -86,20 +95,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
SafeNativeMethods.d_scale(x.Length, alpha, x);
}
/// <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>
public int QueryWorkspaceBlockSize(string methodName)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
@ -109,7 +104,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public double DotProduct(double[] x, double[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.d_dot_product(x.Length, x, y);
}
/// <summary>
@ -261,8 +271,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(double[] a, double[] work)
@ -276,8 +285,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(double[] a, int[] ipiv, double[] work)
@ -393,8 +401,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(double[] r, double[] q, double[] work)
{
@ -427,8 +434,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, double[] r, double[] q, double[] b, double[] x, double[] work)
{
@ -572,6 +578,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(float alpha, float[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -589,7 +600,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public float DotProduct(float[] x, float[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.s_dot_product(x.Length, x, y);
}
/// <summary>
@ -741,8 +767,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(float[] a, float[] work)
@ -756,8 +781,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(float[] a, int[] ipiv, float[] work)
@ -873,8 +897,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(float[] r, float[] q, float[] work)
{
@ -907,8 +930,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, float[] r, float[] q, float[] b, float[] x, float[] work)
{
@ -1052,6 +1074,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex alpha, Complex[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1069,7 +1096,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex DotProduct(Complex[] x, Complex[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.z_dot_product(x.Length, x, y);
}
/// <summary>
@ -1221,8 +1263,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex[] a, Complex[] work)
@ -1236,8 +1277,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex[] a, int[] ipiv, Complex[] work)
@ -1353,8 +1393,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex[] r, Complex[] q, Complex[] work)
{
@ -1387,8 +1426,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex[] r, Complex[] q, Complex[] b, Complex[] x, Complex[] work)
{
@ -1532,6 +1570,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex32 alpha, Complex32[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1549,7 +1592,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex32 DotProduct(Complex32[] x, Complex32[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.c_dot_product(x.Length, x, y);
}
/// <summary>
@ -1701,8 +1759,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex32[] a, Complex32[] work)
@ -1716,8 +1773,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex32[] a, int[] ipiv, Complex32[] work)
@ -1833,8 +1889,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex32[] r, Complex32[] q, Complex32[] work)
{
@ -1867,8 +1922,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex32[] r, Complex32[] q, Complex32[] b, Complex32[] x, Complex32[] work)
{

14
src/Numerics/Algorithms/LinearAlgebra/Atlas/SafeNativeMethods.cs

@ -28,7 +28,7 @@
/* This file is automatically generated - do not modify it.
Change SafeNativeMethods.include instead.
Last generated on: 11/6/2009 2:44:00 PM
Last generated on: 11/13/2009 9:49:42 AM
*/
using System.Runtime.InteropServices;
@ -73,6 +73,18 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Atlas
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, ref 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);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern double d_dot_product(int n, double[] x, double[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
#endregion BLAS
}
}

16
src/Numerics/Algorithms/LinearAlgebra/ILinearAlgebraProviderOfT.cs

@ -79,14 +79,14 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <typeparam name="T">Supported data types are double, single, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
public interface ILinearAlgebraProvider<T> where T : struct
{
/// <summary>
/*/// <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);
int QueryWorkspaceBlockSize(string methodName);*/
/// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
@ -233,8 +233,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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, T[] work);
@ -245,8 +244,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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[] ipiv, T[] work);
@ -335,8 +333,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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[] r, T[] q, T[] work);
@ -364,8 +361,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
void QRSolve(int columnsOfB, T[] r, T[] q, T[] b, T[] x, T[] work);

156
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs

@ -24,7 +24,11 @@
/* This file is automatically generated - do not modify it.
Change NativeLinearAlgebraProvider.include instead.
<<<<<<< HEAD:src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
Last generated on: 14/11/2009 20:09:20
=======
Last generated on: 11/6/2009 3:03:50 PM
>>>>>>> c1c4de3... adding dot product:src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
*/
namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
{
@ -36,7 +40,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// </summary>
public class MklLinearAlgebraProvider : ILinearAlgebraProvider
{
#region ILinearAlgebraProvider<double> Members
#region ILinearAlgebraProvider<double> Members
/// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
@ -78,6 +82,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(double alpha, double[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -86,20 +95,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
SafeNativeMethods.d_scale(x.Length, alpha, x);
}
/// <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>
public int QueryWorkspaceBlockSize(string methodName)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
@ -109,7 +104,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public double DotProduct(double[] x, double[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.d_dot_product(x.Length, x, y);
}
/// <summary>
@ -261,8 +271,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(double[] a, double[] work)
@ -276,8 +285,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(double[] a, int[] ipiv, double[] work)
@ -393,8 +401,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(double[] r, double[] q, double[] work)
{
@ -427,8 +434,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, double[] r, double[] q, double[] b, double[] x, double[] work)
{
@ -572,6 +578,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(float alpha, float[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -589,7 +600,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public float DotProduct(float[] x, float[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.s_dot_product(x.Length, x, y);
}
/// <summary>
@ -741,8 +767,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(float[] a, float[] work)
@ -756,8 +781,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(float[] a, int[] ipiv, float[] work)
@ -873,8 +897,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(float[] r, float[] q, float[] work)
{
@ -907,8 +930,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, float[] r, float[] q, float[] b, float[] x, float[] work)
{
@ -1052,6 +1074,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex alpha, Complex[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1069,7 +1096,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex DotProduct(Complex[] x, Complex[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.z_dot_product(x.Length, x, y);
}
/// <summary>
@ -1221,8 +1263,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex[] a, Complex[] work)
@ -1236,8 +1277,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex[] a, int[] ipiv, Complex[] work)
@ -1353,8 +1393,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex[] r, Complex[] q, Complex[] work)
{
@ -1387,8 +1426,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex[] r, Complex[] q, Complex[] b, Complex[] x, Complex[] work)
{
@ -1532,6 +1570,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex32 alpha, Complex32[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1549,7 +1592,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex32 DotProduct(Complex32[] x, Complex32[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.c_dot_product(x.Length, x, y);
}
/// <summary>
@ -1701,8 +1759,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex32[] a, Complex32[] work)
@ -1716,8 +1773,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex32[] a, int[] ipiv, Complex32[] work)
@ -1833,8 +1889,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex32[] r, Complex32[] q, Complex32[] work)
{
@ -1867,8 +1922,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex32[] r, Complex32[] q, Complex32[] b, Complex32[] x, Complex32[] work)
{

14
src/Numerics/Algorithms/LinearAlgebra/Mkl/SafeNativeMethods.cs

@ -28,7 +28,7 @@
/* This file is automatically generated - do not modify it.
Change SafeNativeMethods.include instead.
Last generated on: 11/6/2009 2:44:03 PM
Last generated on: 11/13/2009 9:49:46 AM
*/
using System.Runtime.InteropServices;
@ -73,6 +73,18 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.Mkl
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, ref 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);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern double d_dot_product(int n, double[] x, double[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
#endregion BLAS
}
}

152
src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include

@ -36,7 +36,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// </summary>
public class <#=library#>LinearAlgebraProvider : ILinearAlgebraProvider
{
#region ILinearAlgebraProvider<double> Members
#region ILinearAlgebraProvider<double> Members
/// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
@ -78,6 +78,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(double alpha, double[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -86,20 +91,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
SafeNativeMethods.d_scale(x.Length, alpha, x);
}
/// <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>
public int QueryWorkspaceBlockSize(string methodName)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
@ -109,7 +100,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public double DotProduct(double[] x, double[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.d_dot_product(x.Length, x, y);
}
/// <summary>
@ -261,8 +267,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(double[] a, double[] work)
@ -276,8 +281,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(double[] a, int[] ipiv, double[] work)
@ -393,8 +397,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(double[] r, double[] q, double[] work)
{
@ -427,8 +430,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, double[] r, double[] q, double[] b, double[] x, double[] work)
{
@ -572,6 +574,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(float alpha, float[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha == 1.0)
{
return;
@ -589,7 +596,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public float DotProduct(float[] x, float[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.s_dot_product(x.Length, x, y);
}
/// <summary>
@ -741,8 +763,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(float[] a, float[] work)
@ -756,8 +777,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(float[] a, int[] ipiv, float[] work)
@ -873,8 +893,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(float[] r, float[] q, float[] work)
{
@ -907,8 +926,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, float[] r, float[] q, float[] b, float[] x, float[] work)
{
@ -1052,6 +1070,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex alpha, Complex[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1069,7 +1092,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex DotProduct(Complex[] x, Complex[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.z_dot_product(x.Length, x, y);
}
/// <summary>
@ -1221,8 +1259,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex[] a, Complex[] work)
@ -1236,8 +1273,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex[] a, int[] ipiv, Complex[] work)
@ -1353,8 +1389,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex[] r, Complex[] q, Complex[] work)
{
@ -1387,8 +1422,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex[] r, Complex[] q, Complex[] b, Complex[] x, Complex[] work)
{
@ -1532,6 +1566,11 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the SCAL BLAS routine.</remarks>
public void ScaleArray(Complex32 alpha, Complex32[] x)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (alpha.IsOne)
{
return;
@ -1549,7 +1588,22 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
public Complex32 DotProduct(Complex32[] x, Complex32[] y)
{
throw new NotImplementedException();
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.c_dot_product(x.Length, x, y);
}
/// <summary>
@ -1701,8 +1755,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverse(Complex32[] a, Complex32[] work)
@ -1716,8 +1769,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</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. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// 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>
public void LUInverseFactored(Complex32[] a, int[] ipiv, Complex32[] work)
@ -1833,8 +1885,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRFactor(Complex32[] r, Complex32[] q, Complex32[] work)
{
@ -1867,8 +1918,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
/// <param name="b">The B matrix.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. Use <see cref="QueryWorkspaceBlockSize"/>
/// to determine the optimal size of the work array. On exit, work[0] contains the optimal
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
public void QRSolve(int columnsOfB, Complex32[] r, Complex32[] q, Complex32[] b, Complex32[] x, Complex32[] work)
{

12
src/Numerics/Algorithms/LinearAlgebra/SafeNativeMethods.include

@ -73,6 +73,18 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#= namespaceSuffix #>
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void z_scale(int n, ref 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);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern double d_dot_product(int n, double[] x, double[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex32 c_dot_product(int n, Complex32[] x, Complex32[] y);
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern Complex z_dot_product(int n, Complex[] x, Complex[] y);
#endregion BLAS
}
}

11
src/Numerics/Properties/Resources.Designer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -60,6 +60,15 @@ namespace MathNet.Numerics.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to All arrays must have the same length..
/// </summary>
internal static string ArgumentArraysSameLength {
get {
return ResourceManager.GetString("ArgumentArraysSameLength", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The argument must be between 0 and 1..
/// </summary>

Loading…
Cancel
Save