Browse Source

BREAKING: Providers: providers now own the active instance, support for hint path

spatial
Christoph Ruegg 9 years ago
parent
commit
66df283892
  1. 79
      src/Numerics/Control.cs
  2. 149
      src/Numerics/Distance.cs
  3. 3
      src/Numerics/Fit.cs
  4. 108
      src/Numerics/IntegralTransforms/Fourier.cs
  5. 40
      src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
  6. 26
      src/Numerics/LinearAlgebra/Complex/DenseVector.cs
  7. 35
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  8. 12
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs
  9. 3
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
  10. 5
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs
  11. 9
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
  12. 9
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseQR.cs
  13. 7
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseSvd.cs
  14. 5
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  15. 12
      src/Numerics/LinearAlgebra/Complex/SparseVector.cs
  16. 40
      src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
  17. 26
      src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
  18. 35
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  19. 9
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs
  20. 3
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs
  21. 5
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs
  22. 9
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
  23. 9
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseQR.cs
  24. 7
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseSvd.cs
  25. 5
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  26. 12
      src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
  27. 32
      src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
  28. 26
      src/Numerics/LinearAlgebra/Double/DenseVector.cs
  29. 21
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  30. 9
      src/Numerics/LinearAlgebra/Double/Factorization/DenseCholesky.cs
  31. 3
      src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs
  32. 5
      src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs
  33. 9
      src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs
  34. 9
      src/Numerics/LinearAlgebra/Double/Factorization/DenseQR.cs
  35. 7
      src/Numerics/LinearAlgebra/Double/Factorization/DenseSvd.cs
  36. 5
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  37. 10
      src/Numerics/LinearAlgebra/Double/SparseVector.cs
  38. 32
      src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
  39. 25
      src/Numerics/LinearAlgebra/Single/DenseVector.cs
  40. 21
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  41. 9
      src/Numerics/LinearAlgebra/Single/Factorization/DenseCholesky.cs
  42. 3
      src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs
  43. 5
      src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs
  44. 9
      src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs
  45. 9
      src/Numerics/LinearAlgebra/Single/Factorization/DenseQR.cs
  46. 9
      src/Numerics/LinearAlgebra/Single/Factorization/DenseSvd.cs
  47. 6
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
  48. 9
      src/Numerics/LinearAlgebra/Single/SparseVector.cs
  49. 10
      src/Numerics/Providers/Common/Cuda/CudaProvider.cs
  50. 24
      src/Numerics/Providers/Common/Mkl/MklProvider.cs
  51. 23
      src/Numerics/Providers/Common/NativeProviderLoader.cs
  52. 10
      src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs
  53. 77
      src/Numerics/Providers/FourierTransform/FourierTransformControl.cs
  54. 11
      src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs
  55. 11
      src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs
  56. 100
      src/Numerics/Providers/LinearAlgebra/LinearAlgebraControl.cs
  57. 20
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
  58. 12
      src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs
  59. 8
      src/Numerics/Settings.StyleCop
  60. 16
      src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
  61. 4
      src/UnitTests/Providers/FourierTransform/FourierTransformProviderTests.cs
  62. 108
      src/UnitTests/Providers/LinearAlgebra/Complex/LinearAlgebraProviderTests.cs
  63. 112
      src/UnitTests/Providers/LinearAlgebra/Complex32/LinearAlgebraProviderTests.cs
  64. 112
      src/UnitTests/Providers/LinearAlgebra/Double/LinearAlgebraProviderTests.cs
  65. 112
      src/UnitTests/Providers/LinearAlgebra/Single/LinearAlgebraProviderTests.cs
  66. 8
      src/UnitTests/UseLinearAlgebraProvider.cs

79
src/Numerics/Control.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2016 Math.NET
// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -43,9 +43,7 @@ namespace MathNet.Numerics
static int _blockSize;
static int _parallelizeOrder;
static int _parallelizeElements;
static ILinearAlgebraProvider _linearAlgebraProvider;
static IFourierTransformProvider _fourierTransformProvider;
static readonly object _staticLock = new object();
static string _nativeProviderHintPath;
static Control()
{
@ -195,8 +193,8 @@ namespace MathNet.Numerics
_maxDegreeOfParallelism = 1;
ThreadSafeRandomNumberGenerators = false;
LinearAlgebraProvider.InitializeVerify();
FourierTransformProvider.InitializeVerify();
LinearAlgebraControl.Provider.InitializeVerify();
FourierTransformControl.Provider.InitializeVerify();
}
public static void UseMultiThreading()
@ -204,8 +202,8 @@ namespace MathNet.Numerics
_maxDegreeOfParallelism = Environment.ProcessorCount;
ThreadSafeRandomNumberGenerators = true;
LinearAlgebraProvider.InitializeVerify();
FourierTransformProvider.InitializeVerify();
LinearAlgebraControl.Provider.InitializeVerify();
FourierTransformControl.Provider.InitializeVerify();
}
/// <summary>
@ -227,65 +225,14 @@ namespace MathNet.Numerics
/// <summary>
/// Optional path to try to load native provider binaries from.
/// </summary>
public static string NativeProviderPath { get; set; }
/// <summary>
/// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead.
/// </summary>
/// <value>The linear algebra provider.</value>
public static ILinearAlgebraProvider LinearAlgebraProvider
public static string NativeProviderPath
{
get
{
if (_linearAlgebraProvider == null)
{
lock (_staticLock)
{
if (_linearAlgebraProvider == null)
{
LinearAlgebraControl.UseDefault();
}
}
}
return _linearAlgebraProvider;
}
get { return _nativeProviderHintPath; }
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_linearAlgebraProvider = value;
}
}
/// <summary>
/// Gets or sets the Fourier transform provider. Consider to use UseNativeMKL or UseManaged instead.
/// </summary>
/// <value>The linear algebra provider.</value>
public static IFourierTransformProvider FourierTransformProvider
{
get
{
if (_fourierTransformProvider == null)
{
lock (_staticLock)
{
if (_fourierTransformProvider == null)
{
FourierTransformControl.UseDefault();
}
}
}
return _fourierTransformProvider;
}
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_fourierTransformProvider = value;
_nativeProviderHintPath = value;
LinearAlgebraControl.HintPath = value;
FourierTransformControl.HintPath = value;
}
}
@ -302,8 +249,8 @@ namespace MathNet.Numerics
_maxDegreeOfParallelism = Math.Max(1, Math.Min(1024, value));
// Reinitialize providers:
LinearAlgebraProvider.InitializeVerify();
FourierTransformProvider.InitializeVerify();
LinearAlgebraControl.Provider.InitializeVerify();
FourierTransformControl.Provider.InitializeVerify();
}
}

149
src/Numerics/Distance.cs

@ -31,6 +31,7 @@ using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Statistics;
namespace MathNet.Numerics
@ -53,7 +54,10 @@ namespace MathNet.Numerics
/// </summary>
public static double SAD(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
double sum = 0d;
for (var i = 0; i < a.Length; i++)
@ -68,7 +72,10 @@ namespace MathNet.Numerics
/// </summary>
public static float SAD(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
float sum = 0f;
for (var i = 0; i < a.Length; i++)
@ -116,11 +123,14 @@ namespace MathNet.Numerics
/// </summary>
public static double SSD(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
var diff = new double[a.Length];
Control.LinearAlgebraProvider.SubtractArrays(a, b, diff);
return Control.LinearAlgebraProvider.DotProduct(diff, diff);
LinearAlgebraControl.Provider.SubtractArrays(a, b, diff);
return LinearAlgebraControl.Provider.DotProduct(diff, diff);
}
/// <summary>
@ -128,11 +138,14 @@ namespace MathNet.Numerics
/// </summary>
public static float SSD(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
var diff = new float[a.Length];
Control.LinearAlgebraProvider.SubtractArrays(a, b, diff);
return Control.LinearAlgebraProvider.DotProduct(diff, diff);
LinearAlgebraControl.Provider.SubtractArrays(a, b, diff);
return LinearAlgebraControl.Provider.DotProduct(diff, diff);
}
/// <summary>
@ -221,7 +234,10 @@ namespace MathNet.Numerics
/// </summary>
public static double Chebyshev(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
double max = Math.Abs(a[0] - b[0]);
for (int i = 1; i < a.Length; i++)
@ -240,7 +256,10 @@ namespace MathNet.Numerics
/// </summary>
public static float Chebyshev(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
float max = Math.Abs(a[0] - b[0]);
for (int i = 1; i < a.Length; i++)
@ -267,12 +286,30 @@ namespace MathNet.Numerics
/// </summary>
public static double Minkowski(double p, double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (p < 0d) throw new ArgumentOutOfRangeException("p");
if (p == 1d) return Manhattan(a, b);
if (p == 2d) return Euclidean(a, b);
if (double.IsPositiveInfinity(p)) return Chebyshev(a, b);
if (p < 0d)
{
throw new ArgumentOutOfRangeException("p");
}
if (p == 1d)
{
return Manhattan(a, b);
}
if (p == 2d)
{
return Euclidean(a, b);
}
if (double.IsPositiveInfinity(p))
{
return Chebyshev(a, b);
}
double sum = 0d;
for (var i = 0; i < a.Length; i++)
@ -287,12 +324,30 @@ namespace MathNet.Numerics
/// </summary>
public static float Minkowski(double p, float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (p < 0d)
{
throw new ArgumentOutOfRangeException("p");
}
if (p == 1d)
{
return Manhattan(a, b);
}
if (p < 0d) throw new ArgumentOutOfRangeException("p");
if (p == 1d) return Manhattan(a, b);
if (p == 2d) return Euclidean(a, b);
if (double.IsPositiveInfinity(p)) return Chebyshev(a, b);
if (p == 2d)
{
return Euclidean(a, b);
}
if (double.IsPositiveInfinity(p))
{
return Chebyshev(a, b);
}
double sum = 0d;
for (var i = 0; i < a.Length; i++)
@ -307,7 +362,10 @@ namespace MathNet.Numerics
/// </summary>
public static double Canberra(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
double sum = 0d;
for (var i = 0; i < a.Length; i++)
@ -322,7 +380,10 @@ namespace MathNet.Numerics
/// </summary>
public static float Canberra(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
float sum = 0f;
for (var i = 0; i < a.Length; i++)
@ -337,12 +398,15 @@ namespace MathNet.Numerics
/// </summary>
public static double Cosine(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
var ab = Control.LinearAlgebraProvider.DotProduct(a, b);
var a2 = Control.LinearAlgebraProvider.DotProduct(a, a);
var b2 = Control.LinearAlgebraProvider.DotProduct(b, b);
return 1d - ab/(Math.Sqrt(a2*b2));
var ab = LinearAlgebraControl.Provider.DotProduct(a, b);
var a2 = LinearAlgebraControl.Provider.DotProduct(a, a);
var b2 = LinearAlgebraControl.Provider.DotProduct(b, b);
return 1d - ab/Math.Sqrt(a2*b2);
}
/// <summary>
@ -350,12 +414,15 @@ namespace MathNet.Numerics
/// </summary>
public static float Cosine(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
var ab = Control.LinearAlgebraProvider.DotProduct(a, b);
var a2 = Control.LinearAlgebraProvider.DotProduct(a, a);
var b2 = Control.LinearAlgebraProvider.DotProduct(b, b);
return (float)(1d - ab/(Math.Sqrt(a2*b2)));
var ab = LinearAlgebraControl.Provider.DotProduct(a, b);
var a2 = LinearAlgebraControl.Provider.DotProduct(a, a);
var b2 = LinearAlgebraControl.Provider.DotProduct(b, b);
return (float)(1d - ab/Math.Sqrt(a2*b2));
}
/// <summary>
@ -363,7 +430,10 @@ namespace MathNet.Numerics
/// </summary>
public static double Hamming(double[] a, double[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
int count = 0;
for (int i = 0; i < a.Length; i++)
@ -381,7 +451,10 @@ namespace MathNet.Numerics
/// </summary>
public static float Hamming(float[] a, float[] b)
{
if (a.Length != b.Length) throw new ArgumentException(Resources.ArgumentVectorsSameLength);
if (a.Length != b.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
int count = 0;
for (int i = 0; i < a.Length; i++)
@ -410,7 +483,7 @@ namespace MathNet.Numerics
/// <returns>Jaccard distance.</returns>
public static double Jaccard(double[] a, double[] b)
{
Int32 intersection = 0, union = 0;
int intersection = 0, union = 0;
if (a == null)
{
@ -432,7 +505,7 @@ namespace MathNet.Numerics
return 0;
}
for (Int32 x = 0, len = a.Length; x < len; x++)
for (int x = 0, len = a.Length; x < len; x++)
{
if (a[x] != 0 && b[x] != 0)
{
@ -456,7 +529,7 @@ namespace MathNet.Numerics
/// <returns>Jaccard distance.</returns>
public static double Jaccard(float[] a, float[] b)
{
Int32 intersection = 0, union = 0;
int intersection = 0, union = 0;
if (a == null)
{
@ -478,7 +551,7 @@ namespace MathNet.Numerics
return 0;
}
for (Int32 x = 0, len = a.Length; x < len; x++)
for (int x = 0, len = a.Length; x < len; x++)
{
if (a[x] != 0 && b[x] != 0)
{

3
src/Numerics/Fit.cs

@ -31,6 +31,7 @@ using System;
using System.Linq;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearRegression;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics
{
@ -78,7 +79,7 @@ namespace MathNet.Numerics
public static Func<double[], double> MultiDimFunc(double[][] x, double[] y, bool intercept = false, DirectRegressionMethod method = DirectRegressionMethod.NormalEquations)
{
var parameters = MultipleRegression.DirectMethod(x, y, intercept, method);
return z => Control.LinearAlgebraProvider.DotProduct(parameters, z);
return z => LinearAlgebraControl.Provider.DotProduct(parameters, z);
}
/// <summary>

108
src/Numerics/IntegralTransforms/Fourier.cs

@ -47,7 +47,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// <param name="samples">Sample vector, where the FFT is evaluated in place.</param>
public static void Forward(Complex32[] samples)
{
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.SymmetricScaling);
}
/// <summary>
@ -56,7 +56,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// <param name="samples">Sample vector, where the FFT is evaluated in place.</param>
public static void Forward(Complex[] samples)
{
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.SymmetricScaling);
}
/// <summary>
@ -70,17 +70,17 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.Backward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(samples, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Backward(samples, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Backward(samples, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -96,17 +96,17 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.Backward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(samples, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Backward(samples, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Backward(samples, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -199,10 +199,10 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardReal(data, n, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardReal(data, n, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.ForwardReal(data, n, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardReal(data, n, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -233,10 +233,10 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardReal(data, n, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardReal(data, n, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.ForwardReal(data, n, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardReal(data, n, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -256,17 +256,17 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.BackwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.ForwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -286,17 +286,17 @@ namespace MathNet.Numerics.IntegralTransforms
{
case FourierOptions.NoScaling:
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.BackwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardMultidim(samples, dimensions, FourierTransformScaling.NoScaling);
break;
default:
Control.FourierTransformProvider.ForwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardMultidim(samples, dimensions, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -389,7 +389,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// <param name="spectrum">Spectrum data, where the iFFT is evaluated in place.</param>
public static void Inverse(Complex32[] spectrum)
{
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
}
/// <summary>
@ -398,7 +398,7 @@ namespace MathNet.Numerics.IntegralTransforms
/// <param name="spectrum">Spectrum data, where the iFFT is evaluated in place.</param>
public static void Inverse(Complex[] spectrum)
{
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
}
/// <summary>
@ -411,22 +411,22 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.BackwardScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.ForwardScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.ForwardScaling);
break;
default:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -441,22 +441,22 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.BackwardScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.ForwardScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.ForwardScaling);
break;
default:
Control.FourierTransformProvider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Backward(spectrum, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -548,13 +548,13 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.BackwardScaling);
break;
default:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -584,13 +584,13 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.BackwardScaling);
break;
default:
Control.FourierTransformProvider.BackwardReal(data, n, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardReal(data, n, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -609,22 +609,22 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.BackwardScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.ForwardScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.ForwardScaling);
break;
default:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
break;
}
}
@ -643,22 +643,22 @@ namespace MathNet.Numerics.IntegralTransforms
switch (options)
{
case FourierOptions.NoScaling:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.BackwardScaling);
break;
case FourierOptions.InverseExponent:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.NoScaling:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.NoScaling);
break;
case FourierOptions.InverseExponent | FourierOptions.AsymmetricScaling:
Control.FourierTransformProvider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.ForwardScaling);
FourierTransformControl.Provider.ForwardMultidim(spectrum, dimensions, FourierTransformScaling.ForwardScaling);
break;
default:
Control.FourierTransformProvider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.BackwardMultidim(spectrum, dimensions, FourierTransformScaling.SymmetricScaling);
break;
}
}

40
src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs

@ -404,21 +404,21 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <returns>The maximum absolute column sum of the matrix.</returns>
public override double L1Norm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the induced infinity norm of this matrix.</summary>
/// <returns>The maximum absolute row sum of the matrix.</returns>
public override double InfinityNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the entry-wise Frobenius norm of this matrix.</summary>
/// <returns>The square root of the sum of the squared values.</returns>
public override double FrobeniusNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
}
/// <summary>
@ -430,7 +430,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(-1, _values, denseResult._values);
return;
}
@ -446,7 +446,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ConjugateArray(_values, denseResult._values);
LinearAlgebraControl.Provider.ConjugateArray(_values, denseResult._values);
return;
}
@ -491,7 +491,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<Complex>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.AddArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -547,7 +547,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<Complex>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -581,7 +581,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult._values);
}
}
@ -601,7 +601,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -623,7 +623,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -669,7 +669,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.Transpose,
1.0,
@ -719,7 +719,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
1.0,
@ -775,7 +775,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseVector;
if (denseRight != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -804,7 +804,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseVector;
if (denseRight != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -833,7 +833,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -884,7 +884,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -938,7 +938,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0/divisor, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(1.0/divisor, _values, denseResult._values);
}
}
@ -958,7 +958,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -978,7 +978,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
}
}
@ -998,7 +998,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

26
src/Numerics/LinearAlgebra/Complex/DenseVector.cs

@ -27,14 +27,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex
{
using Complex = System.Numerics.Complex;
@ -241,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.AddArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.AddArrays(_values, otherDense._values, resultDense._values);
}
}
@ -303,7 +305,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
@ -354,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return;
}
Control.LinearAlgebraProvider.ScaleArray(-Complex.One, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(-Complex.One, _values, denseResult.Values);
}
/// <summary>
@ -370,7 +372,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return;
}
Control.LinearAlgebraProvider.ConjugateArray(_values, resultDense._values);
LinearAlgebraControl.Provider.ConjugateArray(_values, resultDense._values);
}
/// <summary>
@ -388,7 +390,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return;
}
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult.Values);
}
/// <summary>
@ -401,7 +403,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseVector = other as DenseVector;
return denseVector == null
? base.DoDotProduct(other)
: Control.LinearAlgebraProvider.DotProduct(_values, denseVector.Values);
: LinearAlgebraControl.Provider.DotProduct(_values, denseVector.Values);
}
/// <summary>
@ -618,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -639,7 +641,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
}
}
@ -659,7 +661,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

35
src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs

@ -34,6 +34,7 @@ using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex
@ -194,7 +195,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(-1, _data, diagResult._data);
return;
}
@ -214,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ConjugateArray(_data, diagResult._data);
LinearAlgebraControl.Provider.ConjugateArray(_data, diagResult._data);
return;
}
@ -238,7 +239,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.AddArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -262,7 +263,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.SubtractArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -300,7 +301,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(scalar, _data, diagResult._data);
}
}
@ -323,7 +324,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result.Storage as DenseVectorStorage<Complex>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -349,7 +350,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -402,7 +403,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -447,8 +448,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.ConjugateArray(otherDataCopy, otherDataCopy);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -492,7 +493,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var otherDataCopy = new Complex[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -546,8 +547,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.ConjugateArray(thisDataCopy, thisDataCopy);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -601,7 +602,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var denseResult = result.Storage as DenseVectorStorage<Complex>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -632,8 +633,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (denseOther != null && denseResult != null)
{
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(_data, denseResult.Data);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(denseResult.Data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.ConjugateArray(_data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(denseResult.Data, denseOther.Data, denseResult.Data);
return;
}
}
@ -660,7 +661,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(1.0/divisor, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(1.0/divisor, _data, diagResult._data);
return;
}

12
src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs

@ -27,9 +27,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Properties;
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
using Complex = System.Numerics.Complex;
@ -62,7 +64,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Create a new matrix for the Cholesky factor, then perform factorization (while overwriting).
var factor = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.CholeskyFactor(factor.Values, factor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(factor.Values, factor.RowCount);
return new DenseCholesky(factor);
}
@ -110,7 +112,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
}
/// <summary>
@ -147,7 +149,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
}
/// <summary>
@ -182,7 +184,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
Array.Copy(dmatrix.Values, 0, dfactor.Values, 0, dmatrix.Values.Length);
// Perform factorization (while overwriting).
Control.LinearAlgebraProvider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
}
}
}

3
src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
@ -87,7 +88,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
break;
}
Control.LinearAlgebraProvider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
LinearAlgebraControl.Provider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
return new DenseEvd(eigenVectors, eigenValues, blockDiagonal, isSymmetric);
}

5
src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
@ -158,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
}
/// <summary>
@ -193,7 +194,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
}
}
}

9
src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
@ -68,7 +69,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Create a new matrix for the LU factors, then perform factorization (while overwriting).
var factors = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.LUFactor(factors.Values, factors.RowCount, pivots);
LinearAlgebraControl.Provider.LUFactor(factors.Values, factors.RowCount, pivots);
return new DenseLU(factors, pivots);
}
@ -129,7 +130,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -178,7 +179,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -188,7 +189,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
public override Matrix<Complex> Inverse()
{
var result = (DenseMatrix) Factors.Clone();
Control.LinearAlgebraProvider.LUInverseFactored(result.Values, result.RowCount, Pivots);
LinearAlgebraControl.Provider.LUInverseFactored(result.Values, result.RowCount, Pivots);
return result;
}
}

9
src/Numerics/LinearAlgebra/Complex/Factorization/DenseQR.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
@ -74,13 +75,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
r = matrix.Clone();
q = new DenseMatrix(matrix.RowCount);
Control.LinearAlgebraProvider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
LinearAlgebraControl.Provider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
}
else
{
q = matrix.Clone();
r = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
LinearAlgebraControl.Provider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
}
return new DenseQR(q, r, method, tau);
@ -129,7 +130,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do QR factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
}
/// <summary>
@ -164,7 +165,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do QR factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
}
}
}

7
src/Numerics/LinearAlgebra/Complex/Factorization/DenseSvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{
@ -64,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
var s = new DenseVector(nm);
var u = new DenseMatrix(matrix.RowCount);
var vt = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
LinearAlgebraControl.Provider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
return new DenseSvd(s, u, vt, computeVectors);
}
@ -116,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
}
/// <summary>
@ -156,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
}
}
}

5
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex
{
@ -720,7 +721,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
CopyTo(result);
}
Control.LinearAlgebraProvider.ScaleArray(2.0, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(2.0, sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -870,7 +871,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
CopyTo(sparseResult);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

12
src/Numerics/LinearAlgebra/Complex/SparseVector.cs

@ -27,12 +27,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex
{
using Complex = System.Numerics.Complex;
@ -394,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(-Complex.One, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(-Complex.One, sparseResult._storage.Values, sparseResult._storage.Values);
}
/// <summary>
@ -415,7 +417,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -457,7 +459,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

40
src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs

@ -404,21 +404,21 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <returns>The maximum absolute column sum of the matrix.</returns>
public override double L1Norm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the induced infinity norm of this matrix.</summary>
/// <returns>The maximum absolute row sum of the matrix.</returns>
public override double InfinityNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the entry-wise Frobenius norm of this matrix.</summary>
/// <returns>The square root of the sum of the squared values.</returns>
public override double FrobeniusNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
}
/// <summary>
@ -430,7 +430,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(-1, _values, denseResult._values);
return;
}
@ -446,7 +446,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ConjugateArray(_values, denseResult._values);
LinearAlgebraControl.Provider.ConjugateArray(_values, denseResult._values);
return;
}
@ -491,7 +491,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<Complex32>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.AddArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -547,7 +547,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<Complex32>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -581,7 +581,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult._values);
}
}
@ -601,7 +601,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -623,7 +623,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -669,7 +669,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.Transpose,
1.0f,
@ -719,7 +719,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
1.0f,
@ -780,7 +780,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -806,7 +806,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseVector;
if (denseRight != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -835,7 +835,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -886,7 +886,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.ConjugateTranspose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -940,7 +940,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/divisor, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(1.0f/divisor, _values, denseResult._values);
}
}
@ -960,7 +960,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -980,7 +980,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
}
}
@ -1000,7 +1000,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

26
src/Numerics/LinearAlgebra/Complex32/DenseVector.cs

@ -27,14 +27,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex32
{
using Numerics;
@ -241,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.AddArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.AddArrays(_values, otherDense._values, resultDense._values);
}
}
@ -303,7 +305,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
@ -354,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return;
}
Control.LinearAlgebraProvider.ScaleArray(-Complex32.One, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(-Complex32.One, _values, denseResult.Values);
}
/// <summary>
@ -370,7 +372,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return;
}
Control.LinearAlgebraProvider.ConjugateArray(_values, resultDense._values);
LinearAlgebraControl.Provider.ConjugateArray(_values, resultDense._values);
}
/// <summary>
@ -388,7 +390,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return;
}
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult.Values);
}
/// <summary>
@ -401,7 +403,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseVector = other as DenseVector;
return denseVector == null
? base.DoDotProduct(other)
: Control.LinearAlgebraProvider.DotProduct(_values, denseVector.Values);
: LinearAlgebraControl.Provider.DotProduct(_values, denseVector.Values);
}
/// <summary>
@ -618,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -639,7 +641,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
}
}
@ -659,7 +661,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

35
src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs

@ -34,6 +34,7 @@ using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex32
@ -194,7 +195,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(-1, _data, diagResult._data);
return;
}
@ -214,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ConjugateArray(_data, diagResult._data);
LinearAlgebraControl.Provider.ConjugateArray(_data, diagResult._data);
return;
}
@ -238,7 +239,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.AddArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -262,7 +263,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.SubtractArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -299,7 +300,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(scalar, _data, diagResult._data);
}
}
@ -322,7 +323,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result.Storage as DenseVectorStorage<Complex32>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -348,7 +349,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -401,7 +402,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -446,8 +447,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(otherDataCopy, otherDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.ConjugateArray(otherDataCopy, otherDataCopy);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -491,7 +492,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var otherDataCopy = new Complex32[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -545,8 +546,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(thisDataCopy, thisDataCopy);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.ConjugateArray(thisDataCopy, thisDataCopy);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -600,7 +601,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var denseResult = result.Storage as DenseVectorStorage<Complex32>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -631,8 +632,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (denseOther != null && denseResult != null)
{
// TODO: merge/MulByConj
Control.LinearAlgebraProvider.ConjugateArray(_data, denseResult.Data);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(denseResult.Data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.ConjugateArray(_data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(denseResult.Data, denseOther.Data, denseResult.Data);
return;
}
}
@ -659,7 +660,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/divisor, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(1.0f/divisor, _data, diagResult._data);
return;
}

9
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -62,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Create a new matrix for the Cholesky factor, then perform factorization (while overwriting).
var factor = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.CholeskyFactor(factor.Values, factor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(factor.Values, factor.RowCount);
return new DenseCholesky(factor);
}
@ -110,7 +111,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
}
/// <summary>
@ -147,7 +148,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
}
/// <summary>
@ -182,7 +183,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
Array.Copy(dmatrix.Values, 0, dfactor.Values, 0, dmatrix.Values.Length);
// Perform factorization (while overwriting).
Control.LinearAlgebraProvider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
}
}
}

3
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -88,7 +89,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
break;
}
Control.LinearAlgebraProvider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
LinearAlgebraControl.Provider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
return new DenseEvd(eigenVectors, eigenValues, blockDiagonal, isSymmetric);
}

5
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -158,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
}
/// <summary>
@ -193,7 +194,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
}
}
}

9
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -68,7 +69,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Create a new matrix for the LU factors, then perform factorization (while overwriting).
var factors = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.LUFactor(factors.Values, factors.RowCount, pivots);
LinearAlgebraControl.Provider.LUFactor(factors.Values, factors.RowCount, pivots);
return new DenseLU(factors, pivots);
}
@ -129,7 +130,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -178,7 +179,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -188,7 +189,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
public override Matrix<Complex32> Inverse()
{
var result = (DenseMatrix) Factors.Clone();
Control.LinearAlgebraProvider.LUInverseFactored(result.Values, result.RowCount, Pivots);
LinearAlgebraControl.Provider.LUInverseFactored(result.Values, result.RowCount, Pivots);
return result;
}
}

9
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseQR.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -74,13 +75,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
r = matrix.Clone();
q = new DenseMatrix(matrix.RowCount);
Control.LinearAlgebraProvider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
LinearAlgebraControl.Provider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
}
else
{
q = matrix.Clone();
r = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
LinearAlgebraControl.Provider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
}
return new DenseQR(q, r, method, tau);
@ -129,7 +130,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do QR factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
}
/// <summary>
@ -164,7 +165,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do QR factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
}
}
}

7
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseSvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{
@ -64,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
var s = new DenseVector(nm);
var u = new DenseMatrix(matrix.RowCount);
var vt = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
LinearAlgebraControl.Provider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
return new DenseSvd(s, u, vt, computeVectors);
}
@ -116,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
}
/// <summary>
@ -156,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
}
}
}

5
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Complex32
{
@ -720,7 +721,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
CopyTo(result);
}
Control.LinearAlgebraProvider.ScaleArray(2.0f, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(2.0f, sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -869,7 +870,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
CopyTo(sparseResult);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

12
src/Numerics/LinearAlgebra/Complex32/SparseVector.cs

@ -27,12 +27,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Complex32
{
using Numerics;
@ -394,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(-Complex32.One, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(-Complex32.One, sparseResult._storage.Values, sparseResult._storage.Values);
}
/// <summary>
@ -415,7 +417,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ConjugateArray(sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -457,7 +459,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

32
src/Numerics/LinearAlgebra/Double/DenseMatrix.cs

@ -402,21 +402,21 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <returns>The maximum absolute column sum of the matrix.</returns>
public override double L1Norm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the induced infinity norm of this matrix.</summary>
/// <returns>The maximum absolute row sum of the matrix.</returns>
public override double InfinityNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the entry-wise Frobenius norm of this matrix.</summary>
/// <returns>The square root of the sum of the squared values.</returns>
public override double FrobeniusNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
}
/// <summary>
@ -428,7 +428,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(-1, _values, denseResult._values);
return;
}
@ -473,7 +473,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<double>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.AddArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -529,7 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<double>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -563,7 +563,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult._values);
}
}
@ -583,7 +583,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -605,7 +605,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -651,7 +651,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.Transpose,
1.0,
@ -706,7 +706,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -732,7 +732,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0,
@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0/divisor, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(1.0/divisor, _values, denseResult._values);
}
}
@ -806,7 +806,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -826,7 +826,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
}
}
@ -846,7 +846,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

26
src/Numerics/LinearAlgebra/Double/DenseVector.cs

@ -27,16 +27,18 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Double
{
/// <summary>
@ -241,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.AddArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.AddArrays(_values, otherDense._values, resultDense._values);
}
}
@ -313,7 +315,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
@ -364,7 +366,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return;
}
Control.LinearAlgebraProvider.ScaleArray(-1.0d, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(-1.0d, _values, denseResult.Values);
}
/// <summary>
@ -382,7 +384,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return;
}
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult.Values);
}
/// <summary>
@ -395,7 +397,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseVector = other as DenseVector;
return denseVector == null
? base.DoDotProduct(other)
: Control.LinearAlgebraProvider.DotProduct(_values, denseVector.Values);
: LinearAlgebraControl.Provider.DotProduct(_values, denseVector.Values);
}
/// <summary>
@ -700,7 +702,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -721,7 +723,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
}
}
@ -741,7 +743,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

21
src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs

@ -34,6 +34,7 @@ using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Double
@ -192,7 +193,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(-1, _data, diagResult._data);
return;
}
@ -216,7 +217,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.AddArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -240,7 +241,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.SubtractArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -278,7 +279,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(scalar, _data, diagResult._data);
}
}
@ -301,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result.Storage as DenseVectorStorage<double>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -327,7 +328,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -380,7 +381,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -424,7 +425,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var otherDataCopy = new double[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -481,7 +482,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var denseResult = result.Storage as DenseVectorStorage<double>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -508,7 +509,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(1.0/divisor, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(1.0/divisor, _data, diagResult._data);
return;
}

9
src/Numerics/LinearAlgebra/Double/Factorization/DenseCholesky.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -60,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Create a new matrix for the Cholesky factor, then perform factorization (while overwriting).
var factor = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.CholeskyFactor(factor.Values, factor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(factor.Values, factor.RowCount);
return new DenseCholesky(factor);
}
@ -108,7 +109,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
}
/// <summary>
@ -145,7 +146,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
}
/// <summary>
@ -180,7 +181,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
Buffer.BlockCopy(dmatrix.Values, 0, dfactor.Values, 0, dmatrix.Values.Length * Constants.SizeOfDouble);
// Perform factorization (while overwriting).
Control.LinearAlgebraProvider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
}
}
}

3
src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -88,7 +89,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
break;
}
Control.LinearAlgebraProvider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
LinearAlgebraControl.Provider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
return new DenseEvd(eigenVectors, eigenValues, blockDiagonal, isSymmetric);
}

5
src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -156,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
}
/// <summary>
@ -191,7 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
}
}
}

9
src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -66,7 +67,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Create a new matrix for the LU factors, then perform factorization (while overwriting).
var factors = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.LUFactor(factors.Values, factors.RowCount, pivots);
LinearAlgebraControl.Provider.LUFactor(factors.Values, factors.RowCount, pivots);
return new DenseLU(factors, pivots);
}
@ -127,7 +128,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -176,7 +177,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -186,7 +187,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
public override Matrix<double> Inverse()
{
var result = (DenseMatrix) Factors.Clone();
Control.LinearAlgebraProvider.LUInverseFactored(result.Values, result.RowCount, Pivots);
LinearAlgebraControl.Provider.LUInverseFactored(result.Values, result.RowCount, Pivots);
return result;
}
}

9
src/Numerics/LinearAlgebra/Double/Factorization/DenseQR.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -72,13 +73,13 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
r = matrix.Clone();
q = new DenseMatrix(matrix.RowCount);
Control.LinearAlgebraProvider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
LinearAlgebraControl.Provider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
}
else
{
q = matrix.Clone();
r = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
LinearAlgebraControl.Provider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
}
return new DenseQR(q, r, method, tau);
@ -127,7 +128,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do QR factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
}
/// <summary>
@ -162,7 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do QR factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
}
}
}

7
src/Numerics/LinearAlgebra/Double/Factorization/DenseSvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{
@ -62,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
var s = new DenseVector(nm);
var u = new DenseMatrix(matrix.RowCount);
var vt = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
LinearAlgebraControl.Provider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
return new DenseSvd(s, u, vt, computeVectors);
}
@ -114,7 +115,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
}
/// <summary>
@ -154,7 +155,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
}
}
}

5
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Double
{
@ -720,7 +721,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
CopyTo(result);
}
Control.LinearAlgebraProvider.ScaleArray(2.0, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(2.0, sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -870,7 +871,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
CopyTo(sparseResult);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

10
src/Numerics/LinearAlgebra/Double/SparseVector.cs

@ -27,14 +27,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Double
{
/// <summary>
@ -394,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(-1.0d, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(-1.0d, sparseResult._storage.Values, sparseResult._storage.Values);
}
/// <summary>
@ -428,7 +430,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

32
src/Numerics/LinearAlgebra/Single/DenseMatrix.cs

@ -402,21 +402,21 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <returns>The maximum absolute column sum of the matrix.</returns>
public override double L1Norm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the induced infinity norm of this matrix.</summary>
/// <returns>The maximum absolute row sum of the matrix.</returns>
public override double InfinityNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, _rowCount, _columnCount, _values);
}
/// <summary>Calculates the entry-wise Frobenius norm of this matrix.</summary>
/// <returns>The square root of the sum of the squared values.</returns>
public override double FrobeniusNorm()
{
return Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
return LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, _rowCount, _columnCount, _values);
}
/// <summary>
@ -428,7 +428,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result as DenseMatrix;
if (denseResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(-1, _values, denseResult._values);
return;
}
@ -473,7 +473,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<float>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.AddArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -529,7 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result.Storage as DenseColumnMajorMatrixStorage<float>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
return;
}
@ -563,7 +563,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult._values);
}
}
@ -583,7 +583,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -605,7 +605,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiply(
LinearAlgebraControl.Provider.MatrixMultiply(
_values,
_rowCount,
_columnCount,
@ -651,7 +651,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.DontTranspose,
Providers.LinearAlgebra.Transpose.Transpose,
1.0f,
@ -706,7 +706,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -732,7 +732,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result as DenseMatrix;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(
Providers.LinearAlgebra.Transpose.Transpose,
Providers.LinearAlgebra.Transpose.DontTranspose,
1.0f,
@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/divisor, _values, denseResult._values);
LinearAlgebraControl.Provider.ScaleArray(1.0f/divisor, _values, denseResult._values);
}
}
@ -806,7 +806,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -826,7 +826,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
}
}
@ -846,7 +846,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

25
src/Numerics/LinearAlgebra/Single/DenseVector.cs

@ -27,17 +27,20 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Single
{
using MathNet.Numerics.Providers.LinearAlgebra;
/// <summary>
/// A vector using dense storage.
/// </summary>
@ -240,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.AddArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.AddArrays(_values, otherDense._values, resultDense._values);
}
}
@ -302,7 +305,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
LinearAlgebraControl.Provider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
@ -353,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return;
}
Control.LinearAlgebraProvider.ScaleArray(-1.0f, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(-1.0f, _values, denseResult.Values);
}
/// <summary>
@ -371,7 +374,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return;
}
Control.LinearAlgebraProvider.ScaleArray(scalar, _values, denseResult.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, _values, denseResult.Values);
}
/// <summary>
@ -384,7 +387,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseVector = other as DenseVector;
return denseVector == null
? base.DoDotProduct(other)
: Control.LinearAlgebraProvider.DotProduct(_values, denseVector.Values);
: LinearAlgebraControl.Provider.DotProduct(_values, denseVector.Values);
}
/// <summary>
@ -690,7 +693,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_values, denseOther._values, denseResult._values);
}
}
@ -711,7 +714,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
}
}
@ -731,7 +734,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
LinearAlgebraControl.Provider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

21
src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs

@ -34,6 +34,7 @@ using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Single
@ -192,7 +193,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(-1, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(-1, _data, diagResult._data);
return;
}
@ -216,7 +217,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.AddArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -240,7 +241,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var diagResult = result as DiagonalMatrix;
if (diagOther != null && diagResult != null)
{
Control.LinearAlgebraProvider.SubtractArrays(_data, diagOther._data, diagResult._data);
LinearAlgebraControl.Provider.SubtractArrays(_data, diagOther._data, diagResult._data);
return;
}
@ -278,7 +279,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
else
{
Control.LinearAlgebraProvider.ScaleArray(scalar, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(scalar, _data, diagResult._data);
}
}
@ -301,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result.Storage as DenseVectorStorage<float>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -327,7 +328,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -380,7 +381,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -424,7 +425,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var otherDataCopy = new float[diagonalResult._data.Length];
Array.Copy(_data, 0, thisDataCopy, 0, (diagonalResult._data.Length > _data.Length) ? _data.Length : diagonalResult._data.Length);
Array.Copy(diagonalOther._data, 0, otherDataCopy, 0, (diagonalResult._data.Length > diagonalOther._data.Length) ? diagonalOther._data.Length : diagonalResult._data.Length);
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(thisDataCopy, otherDataCopy, diagonalResult._data);
return;
}
@ -481,7 +482,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var denseResult = result.Storage as DenseVectorStorage<float>;
if (denseOther != null && denseResult != null)
{
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_data, denseOther.Data, denseResult.Data);
return;
}
}
@ -508,7 +509,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var diagResult = result as DiagonalMatrix;
if (diagResult != null)
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/divisor, _data, diagResult._data);
LinearAlgebraControl.Provider.ScaleArray(1.0f/divisor, _data, diagResult._data);
return;
}

9
src/Numerics/LinearAlgebra/Single/Factorization/DenseCholesky.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
@ -60,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Create a new matrix for the Cholesky factor, then perform factorization (while overwriting).
var factor = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.CholeskyFactor(factor.Values, factor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(factor.Values, factor.RowCount);
return new DenseCholesky(factor);
}
@ -108,7 +109,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, dresult.ColumnCount);
}
/// <summary>
@ -145,7 +146,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Cholesky solve by overwriting result.
var dfactor = (DenseMatrix) Factor;
Control.LinearAlgebraProvider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
LinearAlgebraControl.Provider.CholeskySolveFactored(dfactor.Values, dfactor.RowCount, dresult.Values, 1);
}
/// <summary>
@ -180,7 +181,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
Buffer.BlockCopy(dmatrix.Values, 0, dfactor.Values, 0, dmatrix.Values.Length * Constants.SizeOfFloat);
// Perform factorization (while overwriting).
Control.LinearAlgebraProvider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
LinearAlgebraControl.Provider.CholeskyFactor(dfactor.Values, dfactor.RowCount);
}
}
}

3
src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
@ -88,7 +89,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
break;
}
Control.LinearAlgebraProvider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
LinearAlgebraControl.Provider.EigenDecomp(isSymmetric, order, matrix.Values, eigenVectors.Values, eigenValues.Values, blockDiagonal.Values);
return new DenseEvd(eigenVectors, eigenValues, blockDiagonal, isSymmetric);
}

5
src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
@ -156,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, input.ColumnCount, dresult.Values, QRMethod.Thin);
}
/// <summary>
@ -191,7 +192,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do GramSchmidt factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix)Q).Values, ((DenseMatrix)FullR).Values, Q.RowCount, FullR.ColumnCount, null, dinput.Values, 1, dresult.Values, QRMethod.Thin);
}
}
}

9
src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs

@ -29,6 +29,7 @@
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
@ -66,7 +67,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Create a new matrix for the LU factors, then perform factorization (while overwriting).
var factors = (DenseMatrix) matrix.Clone();
Control.LinearAlgebraProvider.LUFactor(factors.Values, factors.RowCount, pivots);
LinearAlgebraControl.Provider.LUFactor(factors.Values, factors.RowCount, pivots);
return new DenseLU(factors, pivots);
}
@ -127,7 +128,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(input.ColumnCount, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -176,7 +177,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// LU solve by overwriting result.
var dfactors = (DenseMatrix) Factors;
Control.LinearAlgebraProvider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
LinearAlgebraControl.Provider.LUSolveFactored(1, dfactors.Values, dfactors.RowCount, Pivots, dresult.Values);
}
/// <summary>
@ -186,7 +187,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
public override Matrix<float> Inverse()
{
var result = (DenseMatrix) Factors.Clone();
Control.LinearAlgebraProvider.LUInverseFactored(result.Values, result.RowCount, Pivots);
LinearAlgebraControl.Provider.LUInverseFactored(result.Values, result.RowCount, Pivots);
return result;
}
}

9
src/Numerics/LinearAlgebra/Single/Factorization/DenseQR.cs

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
@ -72,13 +73,13 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
r = matrix.Clone();
q = new DenseMatrix(matrix.RowCount);
Control.LinearAlgebraProvider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
LinearAlgebraControl.Provider.QRFactor(((DenseMatrix) r).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) q).Values, tau);
}
else
{
q = matrix.Clone();
r = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
LinearAlgebraControl.Provider.ThinQRFactor(((DenseMatrix) q).Values, matrix.RowCount, matrix.ColumnCount, ((DenseMatrix) r).Values, tau);
}
return new DenseQR(q, r, method, tau);
@ -127,7 +128,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do QR factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, input.ColumnCount, dresult.Values, Method);
}
/// <summary>
@ -162,7 +163,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do QR factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
LinearAlgebraControl.Provider.QRSolveFactored(((DenseMatrix) Q).Values, ((DenseMatrix) FullR).Values, Q.RowCount, FullR.ColumnCount, Tau, dinput.Values, 1, dresult.Values, Method);
}
}
}

9
src/Numerics/LinearAlgebra/Single/Factorization/DenseSvd.cs

@ -28,10 +28,13 @@
// </copyright>
using System;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.LinearAlgebra;
namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{
/// <summary>
/// <para>A class which encapsulates the functionality of the singular value decomposition (SVD) for <see cref="DenseMatrix"/>.</para>
/// <para>Suppose M is an m-by-n matrix whose entries are real numbers.
@ -62,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
var s = new DenseVector(nm);
var u = new DenseMatrix(matrix.RowCount);
var vt = new DenseMatrix(matrix.ColumnCount);
Control.LinearAlgebraProvider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
LinearAlgebraControl.Provider.SingularValueDecomposition(computeVectors, ((DenseMatrix) matrix.Clone()).Values, matrix.RowCount, matrix.ColumnCount, s.Values, u.Values, vt.Values);
return new DenseSvd(s, u, vt, computeVectors);
}
@ -114,7 +117,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense matrices at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, input.ColumnCount, dresult.Values);
}
/// <summary>
@ -154,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
throw new NotSupportedException("Can only do SVD factorization for dense vectors at the moment.");
}
Control.LinearAlgebraProvider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
LinearAlgebraControl.Provider.SvdSolveFactored(U.RowCount, VT.ColumnCount, ((DenseVector) S).Values, ((DenseMatrix) U).Values, ((DenseMatrix) VT).Values, dinput.Values, 1, dresult.Values);
}
}
}

6
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

@ -35,6 +35,8 @@ using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.LinearAlgebra.Single
{
using MathNet.Numerics.Providers.LinearAlgebra;
/// <summary>
/// A Matrix with sparse storage, intended for very large matrices where most of the cells are zero.
/// The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format.
@ -724,7 +726,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
CopyTo(result);
}
Control.LinearAlgebraProvider.ScaleArray(2.0f, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(2.0f, sparseResult._storage.Values, sparseResult._storage.Values);
return;
}
@ -873,7 +875,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
CopyTo(sparseResult);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

9
src/Numerics/LinearAlgebra/Single/SparseVector.cs

@ -27,13 +27,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Providers.LinearAlgebra;
using MathNet.Numerics.Threading;
namespace MathNet.Numerics.LinearAlgebra.Single
{
@ -395,7 +396,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(-1.0f, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(-1.0f, sparseResult._storage.Values, sparseResult._storage.Values);
}
/// <summary>
@ -429,7 +430,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
Array.Copy(_storage.Values, 0, sparseResult._storage.Values, 0, _storage.ValueCount);
}
Control.LinearAlgebraProvider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
LinearAlgebraControl.Provider.ScaleArray(scalar, sparseResult._storage.Values, sparseResult._storage.Values);
}
}

10
src/Numerics/Providers/Common/Cuda/CudaProvider.cs

@ -41,11 +41,11 @@ namespace MathNet.Numerics.Providers.Common.Cuda
static bool _nativeX64;
static bool _nativeIA64;
public static bool IsAvailable(int minRevision)
internal static bool IsAvailable(int minRevision, string hintPath)
{
try
{
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName))
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath))
{
return false;
}
@ -61,12 +61,12 @@ namespace MathNet.Numerics.Providers.Common.Cuda
}
}
public static void Load(int minRevision)
internal static void Load(int minRevision, string hintPath)
{
int a, b;
try
{
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName);
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath);
a = SafeNativeMethods.query_capability(0);
b = SafeNativeMethods.query_capability(1);
@ -95,7 +95,7 @@ namespace MathNet.Numerics.Providers.Common.Cuda
}
}
public static string Describe()
internal static string Describe()
{
var parts = new List<string>();
if (_nativeX86) parts.Add("x86");

24
src/Numerics/Providers/Common/Mkl/MklProvider.cs

@ -43,11 +43,11 @@ namespace MathNet.Numerics.Providers.Common.Mkl
static bool _nativeX64;
static bool _nativeIA64;
public static bool IsAvailable(int minRevision)
internal static bool IsAvailable(int minRevision, string hintPath)
{
try
{
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName))
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath))
{
return false;
}
@ -63,12 +63,12 @@ namespace MathNet.Numerics.Providers.Common.Mkl
}
}
public static void Load(int minRevision)
internal static void Load(int minRevision, string hintPath)
{
int a, b;
try
{
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName);
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath);
a = SafeNativeMethods.query_capability(0);
b = SafeNativeMethods.query_capability(1);
@ -126,7 +126,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// <summary>
/// Frees the memory allocated to the MKL memory pool.
/// </summary>
public static void FreeBuffers()
internal static void FreeBuffers()
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -139,7 +139,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// <summary>
/// Frees the memory allocated to the MKL memory pool on the current thread.
/// </summary>
public static void ThreadFreeBuffers()
internal static void ThreadFreeBuffers()
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -152,7 +152,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// <summary>
/// Disable the MKL memory pool. May impact performance.
/// </summary>
public static void DisableMemoryPool()
internal static void DisableMemoryPool()
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -167,7 +167,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// </summary>
/// <param name="allocatedBuffers">On output, returns the number of memory buffers allocated.</param>
/// <returns>Returns the number of bytes allocated to all memory buffers.</returns>
public static long MemoryStatistics(out int allocatedBuffers)
internal static long MemoryStatistics(out int allocatedBuffers)
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -180,7 +180,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// <summary>
/// Enable gathering of peak memory statistics of the MKL memory pool.
/// </summary>
public static void EnablePeakMemoryStatistics()
internal static void EnablePeakMemoryStatistics()
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -193,7 +193,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// <summary>
/// Disable gathering of peak memory statistics of the MKL memory pool.
/// </summary>
public static void DisablePeakMemoryStatistics()
internal static void DisablePeakMemoryStatistics()
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -208,7 +208,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
/// </summary>
/// <param name="reset">Whether the usage counter should be reset.</param>
/// <returns>The peak number of bytes allocated to all memory buffers.</returns>
public static long PeakMemoryStatistics(bool reset = true)
internal static long PeakMemoryStatistics(bool reset = true)
{
if (SafeNativeMethods.query_capability((int)ProviderConfig.Memory) < 1)
{
@ -218,7 +218,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
return SafeNativeMethods.peak_mem_usage((int)(reset ? MklMemoryRequestMode.PeakMemoryReset : MklMemoryRequestMode.PeakMemory));
}
public static string Describe()
internal static string Describe()
{
var parts = new List<string>();
if (_nativeX86) parts.Add("x86");

23
src/Numerics/Providers/Common/NativeProviderLoader.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Providers.Common
/// If the last native library failed to load then gets the corresponding exception
/// which occurred or null if the library was successfully loaded.
/// </summary>
public static Exception LastException { get; private set; }
internal static Exception LastException { get; private set; }
static bool IsUnix
{
@ -119,28 +119,35 @@ namespace MathNet.Numerics.Providers.Common
/// Load the native library with the given filename.
/// </summary>
/// <param name="fileName">The file name of the library to load.</param>
/// <param name="hintPath">Hint path where to look for the native binaries. Can be null.</param>
/// <returns>True if the library was successfully loaded or if it has already been loaded.</returns>
public static bool TryLoad(string fileName)
internal static bool TryLoad(string fileName, string hintPath)
{
if (string.IsNullOrEmpty(fileName))
{
throw new ArgumentNullException("fileName");
}
// If we have an extra path provided by the user, look there first
if (TryLoad(fileName, Control.NativeProviderPath))
// If we have hint path provided by the user, look there first
if (TryLoadFromDirectory(fileName, hintPath))
{
return true;
}
// If we have an overall hint path provided by the user, look there next
if (Control.NativeProviderPath != hintPath && TryLoadFromDirectory(fileName, Control.NativeProviderPath))
{
return true;
}
// Look under the current AppDomain's base directory
if (TryLoad(fileName, AppDomain.CurrentDomain.BaseDirectory))
if (TryLoadFromDirectory(fileName, AppDomain.CurrentDomain.BaseDirectory))
{
return true;
}
// Look at this assembly's directory
if (TryLoad(fileName, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)))
if (TryLoadFromDirectory(fileName, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)))
{
return true;
}
@ -154,7 +161,7 @@ namespace MathNet.Numerics.Providers.Common
/// and process mode if there is a matching subfolder.
/// </summary>
/// <returns>True if the library was successfully loaded or if it has already been loaded.</returns>
public static bool TryLoad(string fileName, string directory)
static bool TryLoadFromDirectory(string fileName, string directory)
{
if (!Directory.Exists(directory))
{
@ -178,7 +185,7 @@ namespace MathNet.Numerics.Providers.Common
/// Try to load a native library by providing the full path including the file name of the library.
/// </summary>
/// <returns>True if the library was successfully loaded or if it has already been loaded.</returns>
public static bool TryLoadFile(FileInfo file)
static bool TryLoadFile(FileInfo file)
{
lock (StaticLock)
{

10
src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs

@ -42,11 +42,11 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
static bool _nativeIA64;
static bool _nativeARM;
public static bool IsAvailable(int minRevision)
internal static bool IsAvailable(int minRevision, string hintPath)
{
try
{
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName))
if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath))
{
return false;
}
@ -62,12 +62,12 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
}
}
public static void Load(int minRevision)
internal static void Load(int minRevision, string hintPath)
{
int a, b;
try
{
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName);
NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath);
a = SafeNativeMethods.query_capability(0);
b = SafeNativeMethods.query_capability(1);
@ -108,7 +108,7 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
}
}
public static string Describe()
internal static string Describe()
{
var parts = new List<string>();
if (_nativeX86) parts.Add("x86");

77
src/Numerics/Providers/FourierTransform/FourierTransformControl.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2016 Math.NET
// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -34,21 +34,72 @@ namespace MathNet.Numerics.Providers.FourierTransform
public static class FourierTransformControl
{
const string EnvVarFFTProvider = "MathNetNumericsFFTProvider";
const string EnvVarFFTProviderPath = "MathNetNumericsFFTProviderPath";
static IFourierTransformProvider _fourierTransformProvider;
static readonly object StaticLock = new object();
/// <summary>
/// Gets or sets the Fourier transform provider. Consider to use UseNativeMKL or UseManaged instead.
/// </summary>
/// <value>The linear algebra provider.</value>
public static IFourierTransformProvider Provider
{
get
{
if (_fourierTransformProvider == null)
{
lock (StaticLock)
{
if (_fourierTransformProvider == null)
{
UseDefault();
}
}
}
return _fourierTransformProvider;
}
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_fourierTransformProvider = value;
}
}
/// <summary>
/// Optional path to try to load native provider binaries from.
/// If not set, Numerics will fall back to the environment variable
/// `MathNetNumericsFFTProviderPath` or the default probing paths.
/// </summary>
public static string HintPath { get; set; }
public static IFourierTransformProvider CreateManaged()
{
return new ManagedFourierTransformProvider();
}
public static void UseManaged()
{
Control.FourierTransformProvider = new ManagedFourierTransformProvider();
Provider = CreateManaged();
}
#if NATIVE
public static IFourierTransformProvider CreateNativeMKL()
{
return new Mkl.MklFourierTransformProvider(GetCombinedHintPath());
}
public static void UseNativeMKL()
{
Control.FourierTransformProvider = new Mkl.MklFourierTransformProvider();
Provider = CreateNativeMKL();
}
public static bool TryUseNativeMKL()
{
return TryUse(new Mkl.MklFourierTransformProvider());
return TryUse(CreateNativeMKL());
}
/// <summary>
@ -69,7 +120,7 @@ namespace MathNet.Numerics.Providers.FourierTransform
return false;
}
Control.FourierTransformProvider = provider;
Provider = provider;
return true;
}
catch
@ -118,5 +169,21 @@ namespace MathNet.Numerics.Providers.FourierTransform
UseBest();
#endif
}
static string GetCombinedHintPath()
{
if (!String.IsNullOrEmpty(HintPath))
{
return HintPath;
}
var value = Environment.GetEnvironmentVariable(EnvVarFFTProviderPath);
if (!String.IsNullOrEmpty(value))
{
return value;
}
return null;
}
}
}

11
src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs

@ -46,15 +46,22 @@ namespace MathNet.Numerics.Providers.FourierTransform.Mkl
public bool Single;
}
readonly string _hintPath;
Kernel _kernel;
/// <param name="hintPath">Hint path where to look for the native binaries</param>
internal MklFourierTransformProvider(string hintPath)
{
_hintPath = hintPath;
}
/// <summary>
/// Try to find out whether the provider is available, at least in principle.
/// Verification may still fail if available, but it will certainly fail if unavailable.
/// </summary>
public bool IsAvailable()
{
return MklProvider.IsAvailable(minRevision: 11);
return MklProvider.IsAvailable(minRevision: 11, hintPath: _hintPath);
}
/// <summary>
@ -62,7 +69,7 @@ namespace MathNet.Numerics.Providers.FourierTransform.Mkl
/// </summary>
public void InitializeVerify()
{
MklProvider.Load(minRevision: 11);
MklProvider.Load(minRevision: 11, hintPath: _hintPath);
// we only support exactly one major version, since major version changes imply a breaking change.
int fftMajor = SafeNativeMethods.query_capability((int) ProviderCapability.FourierTransformMajor);

11
src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs

@ -39,16 +39,23 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
/// </summary>
internal partial class CudaLinearAlgebraProvider : ManagedLinearAlgebraProvider, IDisposable
{
readonly string _hintPath;
IntPtr _blasHandle;
IntPtr _solverHandle;
/// <param name="hintPath">Hint path where to look for the native binaries</param>
internal CudaLinearAlgebraProvider(string hintPath)
{
_hintPath = hintPath;
}
/// <summary>
/// Try to find out whether the provider is available, at least in principle.
/// Verification may still fail if available, but it will certainly fail if unavailable.
/// </summary>
public override bool IsAvailable()
{
return CudaProvider.IsAvailable(minRevision: 1);
return CudaProvider.IsAvailable(minRevision: 1, hintPath: _hintPath);
}
/// <summary>
@ -57,7 +64,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
/// </summary>
public override void InitializeVerify()
{
CudaProvider.Load(minRevision: 1);
CudaProvider.Load(minRevision: 1, hintPath: _hintPath);
int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);

100
src/Numerics/Providers/LinearAlgebra/LinearAlgebraControl.cs

@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
// Copyright (c) 2009-2016 Math.NET
// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -34,20 +34,76 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
public static class LinearAlgebraControl
{
const string EnvVarLAProvider = "MathNetNumericsLAProvider";
const string EnvVarLAProviderPath = "MathNetNumericsLAProviderPath";
static ILinearAlgebraProvider _linearAlgebraProvider;
static readonly object StaticLock = new object();
/// <summary>
/// Gets or sets the linear algebra provider.
/// Consider to use UseNativeMKL or UseManaged instead.
/// </summary>
/// <value>The linear algebra provider.</value>
public static ILinearAlgebraProvider Provider
{
get
{
if (_linearAlgebraProvider == null)
{
lock (StaticLock)
{
if (_linearAlgebraProvider == null)
{
UseDefault();
}
}
}
return _linearAlgebraProvider;
}
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_linearAlgebraProvider = value;
}
}
/// <summary>
/// Optional path to try to load native provider binaries from.
/// If not set, Numerics will fall back to the environment variable
/// `MathNetNumericsLAProviderPath` or the default probing paths.
/// </summary>
public static string HintPath { get; set; }
public static ILinearAlgebraProvider CreateManaged()
{
return new ManagedLinearAlgebraProvider();
}
public static void UseManaged()
{
Control.LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
Provider = CreateManaged();
}
#if NATIVE
[CLSCompliant(false)]
public static ILinearAlgebraProvider CreateNativeMKL(
Common.Mkl.MklConsistency consistency = Common.Mkl.MklConsistency.Auto,
Common.Mkl.MklPrecision precision = Common.Mkl.MklPrecision.Double,
Common.Mkl.MklAccuracy accuracy = Common.Mkl.MklAccuracy.High)
{
return new Mkl.MklLinearAlgebraProvider(GetCombinedHintPath(), consistency, precision, accuracy);
}
[CLSCompliant(false)]
public static void UseNativeMKL(
Common.Mkl.MklConsistency consistency = Common.Mkl.MklConsistency.Auto,
Common.Mkl.MklPrecision precision = Common.Mkl.MklPrecision.Double,
Common.Mkl.MklAccuracy accuracy = Common.Mkl.MklAccuracy.High)
{
Control.LinearAlgebraProvider = new Mkl.MklLinearAlgebraProvider(consistency, precision, accuracy);
Provider = CreateNativeMKL(consistency, precision, accuracy);
}
[CLSCompliant(false)]
@ -56,27 +112,37 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
Common.Mkl.MklPrecision precision = Common.Mkl.MklPrecision.Double,
Common.Mkl.MklAccuracy accuracy = Common.Mkl.MklAccuracy.High)
{
return TryUse(new Mkl.MklLinearAlgebraProvider(consistency, precision, accuracy));
return TryUse(CreateNativeMKL(consistency, precision, accuracy));
}
public static ILinearAlgebraProvider CreateNativeCUDA()
{
return new Cuda.CudaLinearAlgebraProvider(GetCombinedHintPath());
}
public static void UseNativeCUDA()
{
Control.LinearAlgebraProvider = new Cuda.CudaLinearAlgebraProvider();
Provider = CreateNativeCUDA();
}
public static bool TryUseNativeCUDA()
{
return TryUse(new Cuda.CudaLinearAlgebraProvider());
return TryUse(CreateNativeCUDA());
}
public static ILinearAlgebraProvider CreateNativeOpenBLAS()
{
return new OpenBlas.OpenBlasLinearAlgebraProvider(GetCombinedHintPath());
}
public static void UseNativeOpenBLAS()
{
Control.LinearAlgebraProvider = new OpenBlas.OpenBlasLinearAlgebraProvider();
Provider = CreateNativeOpenBLAS();
}
public static bool TryUseNativeOpenBLAS()
{
return TryUse(new OpenBlas.OpenBlasLinearAlgebraProvider());
return TryUse(CreateNativeOpenBLAS());
}
/// <summary>
@ -97,7 +163,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
return false;
}
Control.LinearAlgebraProvider = provider;
Provider = provider;
return true;
}
catch
@ -153,5 +219,21 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
UseBest();
#endif
}
static string GetCombinedHintPath()
{
if (!String.IsNullOrEmpty(HintPath))
{
return HintPath;
}
var value = Environment.GetEnvironmentVariable(EnvVarLAProviderPath);
if (!String.IsNullOrEmpty(value))
{
return value;
}
return null;
}
}
}

20
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs

@ -50,6 +50,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// </summary>
internal partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
readonly string _hintPath;
readonly MklConsistency _consistency;
readonly MklPrecision _precision;
readonly MklAccuracy _accuracy;
@ -59,37 +60,28 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
int _vectorFunctionsMajor;
int _vectorFunctionsMinor;
/// <param name="hintPath">Hint path where to look for the native binaries</param>
/// <param name="consistency">
/// Sets the desired bit consistency on repeated identical computations on varying CPU architectures,
/// as a trade-off with performance.
/// </param>
/// <param name="precision">VML optimal precision and rounding.</param>
/// <param name="accuracy">VML accuracy mode.</param>
[CLSCompliant(false)]
internal MklLinearAlgebraProvider(
MklConsistency consistency = MklConsistency.Auto,
MklPrecision precision = MklPrecision.Double,
MklAccuracy accuracy = MklAccuracy.High)
internal MklLinearAlgebraProvider(string hintPath, MklConsistency consistency, MklPrecision precision, MklAccuracy accuracy)
{
_hintPath = hintPath;
_consistency = consistency;
_precision = precision;
_accuracy = accuracy;
}
internal MklLinearAlgebraProvider()
{
_consistency = MklConsistency.Auto;
_precision = MklPrecision.Double;
_accuracy = MklAccuracy.High;
}
/// <summary>
/// Try to find out whether the provider is available, at least in principle.
/// Verification may still fail if available, but it will certainly fail if unavailable.
/// </summary>
public override bool IsAvailable()
{
return MklProvider.IsAvailable(minRevision: 4);
return MklProvider.IsAvailable(minRevision: 4, hintPath: _hintPath);
}
/// <summary>
@ -98,7 +90,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// </summary>
public override void InitializeVerify()
{
MklProvider.Load(minRevision: 4);
MklProvider.Load(minRevision: 4, hintPath: _hintPath);
MklProvider.ConfigurePrecision(_consistency, _precision, _accuracy);
_linearAlgebraMajor = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);

12
src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs

@ -57,13 +57,21 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.OpenBlas
/// </summary>
internal partial class OpenBlasLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
readonly string _hintPath;
/// <param name="hintPath">Hint path where to look for the native binaries</param>
internal OpenBlasLinearAlgebraProvider(string hintPath)
{
_hintPath = hintPath;
}
/// <summary>
/// Try to find out whether the provider is available, at least in principle.
/// Verification may still fail if available, but it will certainly fail if unavailable.
/// </summary>
public override bool IsAvailable()
{
return OpenBlasProvider.IsAvailable(minRevision: 1);
return OpenBlasProvider.IsAvailable(minRevision: 1, hintPath: _hintPath);
}
/// <summary>
@ -72,7 +80,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.OpenBlas
/// </summary>
public override void InitializeVerify()
{
OpenBlasProvider.Load(minRevision: 1);
OpenBlasProvider.Load(minRevision: 1, hintPath: _hintPath);
int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);

8
src/Numerics/Settings.StyleCop

@ -335,17 +335,17 @@
</Rule>
<Rule Name="SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustAppearInTheCorrectOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeOrderedByAccess">
@ -402,4 +402,4 @@
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
</StyleCopSettings>

16
src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs

@ -364,8 +364,8 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
// 65536 = 2^16
var samples = Generate.RandomComplex32(65536, GetUniform(1));
VerifyInplace(samples, 5, FourierOptions.NoScaling, (s, o) => Control.FourierTransformProvider.Forward(s, FourierTransformScaling.NoScaling), Fourier.Radix2Forward);
VerifyInplace(samples, 5, FourierOptions.NoScaling, (s, o) => Control.FourierTransformProvider.Forward(s, FourierTransformScaling.NoScaling), Fourier.BluesteinForward);
VerifyInplace(samples, 5, FourierOptions.NoScaling, (s, o) => FourierTransformControl.Provider.Forward(s, FourierTransformScaling.NoScaling), Fourier.Radix2Forward);
VerifyInplace(samples, 5, FourierOptions.NoScaling, (s, o) => FourierTransformControl.Provider.Forward(s, FourierTransformScaling.NoScaling), Fourier.BluesteinForward);
}
[Test]
@ -374,8 +374,8 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
// 65536 = 2^16
var samples = Generate.RandomComplex(65536, GetUniform(1));
VerifyInplace(samples, 10, FourierOptions.NoScaling, (s,o) => Control.FourierTransformProvider.Forward(s, FourierTransformScaling.NoScaling), Fourier.Radix2Forward);
VerifyInplace(samples, 10, FourierOptions.NoScaling, (s, o) => Control.FourierTransformProvider.Forward(s, FourierTransformScaling.NoScaling), Fourier.BluesteinForward);
VerifyInplace(samples, 10, FourierOptions.NoScaling, (s,o) => FourierTransformControl.Provider.Forward(s, FourierTransformScaling.NoScaling), Fourier.Radix2Forward);
VerifyInplace(samples, 10, FourierOptions.NoScaling, (s, o) => FourierTransformControl.Provider.Forward(s, FourierTransformScaling.NoScaling), Fourier.BluesteinForward);
}
[Test]
@ -387,7 +387,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var provider = new Complex32[samples.Length];
samples.Copy(provider);
Control.FourierTransformProvider.Forward(provider, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(provider, FourierTransformScaling.NoScaling);
Verify(samples, 5, options, (a, b) => provider, Fourier.BluesteinForward);
}
@ -401,7 +401,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var provider = new Complex[samples.Length];
samples.Copy(provider);
Control.FourierTransformProvider.Forward(provider, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(provider, FourierTransformScaling.NoScaling);
Verify(samples, 10, options, (a, b) => provider, Fourier.BluesteinForward);
}
@ -414,7 +414,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var provider = new Complex32[samples.Length];
samples.Copy(provider);
Control.FourierTransformProvider.Forward(provider, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(provider, FourierTransformScaling.NoScaling);
Verify(samples, 5, options, (a, b) => provider, Fourier.BluesteinForward);
}
@ -427,7 +427,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var provider = new Complex[samples.Length];
samples.Copy(provider);
Control.FourierTransformProvider.Forward(provider, FourierTransformScaling.NoScaling);
FourierTransformControl.Provider.Forward(provider, FourierTransformScaling.NoScaling);
Verify(samples, 10, options, (a, b) => provider, Fourier.BluesteinForward);
}

4
src/UnitTests/Providers/FourierTransform/FourierTransformProviderTests.cs

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.Providers.FourierTransform
// real-odd transforms to imaginary odd
samples.Copy(spectrum);
Control.FourierTransformProvider.Forward(spectrum, FourierTransformScaling.BackwardScaling);
FourierTransformControl.Provider.Forward(spectrum, FourierTransformScaling.BackwardScaling);
// all real components must be zero
foreach (var c in spectrum)
@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.Providers.FourierTransform
var samples = Generate.RandomComplex(count, GetUniform(1));
var timeSpaceEnergy = Generate.Map(samples, s => s.MagnitudeSquared()).Mean();
Control.FourierTransformProvider.Forward(samples, FourierTransformScaling.SymmetricScaling);
FourierTransformControl.Provider.Forward(samples, FourierTransformScaling.SymmetricScaling);
var frequencySpaceEnergy = Generate.Map(samples, s => s.MagnitudeSquared()).Mean();
Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);

108
src/UnitTests/Providers/LinearAlgebra/Complex/LinearAlgebraProviderTests.cs

@ -82,21 +82,21 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.AddVectorToScaledVector(_y, 0, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(_y, 0, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, 1, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, 1, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + _x[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, Math.PI, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, Math.PI, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + (Math.PI*_x[i]), result[i]);
@ -111,14 +111,14 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.ScaleArray(1, _y, result);
LinearAlgebraControl.Provider.ScaleArray(1, _y, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.ScaleArray(Math.PI, result, result);
LinearAlgebraControl.Provider.ScaleArray(Math.PI, result, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i]*Math.PI, result[i]);
@ -131,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
[Test]
public void CanComputeDotProduct()
{
var result = Control.LinearAlgebraProvider.DotProduct(_x, _y);
var result = LinearAlgebraControl.Provider.DotProduct(_x, _y);
AssertHelpers.AlmostEqualRelative(152.35, result, 15);
}
@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanAddArrays()
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.AddArrays(_x, _y, result);
LinearAlgebraControl.Provider.AddArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] + _y[i], result[i]);
@ -156,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanSubtractArrays()
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.SubtractArrays(_x, _y, result);
LinearAlgebraControl.Provider.SubtractArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] - _y[i], result[i]);
@ -170,7 +170,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanPointWiseMultiplyArrays()
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]*_y[i], result[i]);
@ -184,7 +184,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanPointWiseDivideArrays()
{
var result = new Complex[_y.Length];
Control.LinearAlgebraProvider.PointWiseDivideArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]/_y[i], result[i]);
@ -198,7 +198,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanComputeMatrixL1Norm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(12.1, norm, 6);
}
@ -209,7 +209,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanComputeMatrixFrobeniusNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(10.777754868246, norm, 8);
}
@ -220,7 +220,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanComputeMatrixInfinityNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
Assert.AreEqual(16.5, norm);
}
@ -234,7 +234,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -255,7 +255,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -276,7 +276,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -318,7 +318,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -339,7 +339,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -362,7 +362,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -4.4, 15);
AssertHelpers.AlmostEqualRelative(a[1], 0.25, 15);
@ -388,7 +388,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var a = new Complex[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount);
LinearAlgebraControl.Provider.LUInverse(a, matrix.RowCount);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908, 13);
@ -414,8 +414,8 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUInverseFactored(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908, 13);
@ -439,7 +439,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
Array.Copy(matrix.Values, a, a.Length);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.LUSolve(2, a, matrix.RowCount, b);
LinearAlgebraControl.Provider.LUSolve(2, a, matrix.RowCount, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 13);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 13);
@ -462,10 +462,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
Array.Copy(matrix.Values, a, a.Length);
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
LinearAlgebraControl.Provider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 13);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 13);
@ -482,7 +482,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
public void CanComputeCholeskyFactor()
{
var matrix = new Complex[] {1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15};
Control.LinearAlgebraProvider.CholeskyFactor(matrix, 4);
LinearAlgebraControl.Provider.CholeskyFactor(matrix, 4);
Assert.AreEqual(matrix[0].Real, 1);
Assert.AreEqual(matrix[1].Real, 1);
Assert.AreEqual(matrix[2].Real, 1);
@ -511,7 +511,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var a = new Complex[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.CholeskySolve(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolve(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 14);
AssertHelpers.AlmostEqualRelative(b[1], 1, 14);
@ -531,10 +531,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
{
var a = new Complex[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
Control.LinearAlgebraProvider.CholeskyFactor(a, 3);
LinearAlgebraControl.Provider.CholeskyFactor(a, 3);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.CholeskySolveFactored(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolveFactored(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 14);
AssertHelpers.AlmostEqualRelative(b[1], 1, 14);
@ -556,7 +556,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[3];
var q = new Complex[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -583,7 +583,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[3];
var q = new Complex[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -610,7 +610,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[3];
var q = new Complex[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -637,7 +637,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var q = new Complex[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -664,7 +664,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var q = new Complex[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -691,7 +691,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -717,7 +717,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -743,11 +743,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[matrix.ColumnCount];
var q = new Complex[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -770,7 +770,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 3, a, matrix);
@ -797,7 +797,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 2, a, matrix);
@ -823,11 +823,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[matrix.ColumnCount];
var r = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -853,11 +853,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var tau = new Complex[matrix.ColumnCount];
var r = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -882,7 +882,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -919,7 +919,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -953,7 +953,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -985,7 +985,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -1012,7 +1012,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -1040,11 +1040,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -1072,11 +1072,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex
var u = new Complex[matrix.RowCount*matrix.RowCount];
var vt = new Complex[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new Complex[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;

112
src/UnitTests/Providers/LinearAlgebra/Complex32/LinearAlgebraProviderTests.cs

@ -82,21 +82,21 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.AddVectorToScaledVector(_y, 0, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(_y, 0, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, 1, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, 1, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + _x[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, (Complex32) Math.PI, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, (Complex32) Math.PI, _x, result);
for (var i = 0; i < _y.Length; i++)
{
AssertHelpers.AlmostEqualRelative(_y[i] + ((Complex32) Math.PI*_x[i]), result[i], 5);
@ -111,14 +111,14 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.ScaleArray(1, _y, result);
LinearAlgebraControl.Provider.ScaleArray(1, _y, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.ScaleArray((Complex32) Math.PI, result, result);
LinearAlgebraControl.Provider.ScaleArray((Complex32) Math.PI, result, result);
for (var i = 0; i < _y.Length; i++)
{
AssertHelpers.AlmostEqualRelative(_y[i]*(Complex32) Math.PI, result[i], 5);
@ -131,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
[Test]
public void CanComputeDotProduct()
{
var result = Control.LinearAlgebraProvider.DotProduct(_x, _y);
var result = LinearAlgebraControl.Provider.DotProduct(_x, _y);
AssertHelpers.AlmostEqualRelative(152.35f, result, 5);
}
@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanAddArrays()
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.AddArrays(_x, _y, result);
LinearAlgebraControl.Provider.AddArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] + _y[i], result[i]);
@ -156,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanSubtractArrays()
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.SubtractArrays(_x, _y, result);
LinearAlgebraControl.Provider.SubtractArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] - _y[i], result[i]);
@ -170,7 +170,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanPointWiseMultiplyArrays()
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]*_y[i], result[i]);
@ -184,7 +184,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanPointWiseDivideArrays()
{
var result = new Complex32[_y.Length];
Control.LinearAlgebraProvider.PointWiseDivideArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]/_y[i], result[i]);
@ -198,7 +198,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanComputeMatrixL1Norm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(12.1f, norm, 5);
}
@ -209,7 +209,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanComputeMatrixFrobeniusNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(10.777754868246f, norm, 5);
}
@ -220,7 +220,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanComputeMatrixInfinityNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
Assert.AreEqual(16.5, norm);
}
@ -234,7 +234,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -255,7 +255,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -276,7 +276,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -318,7 +318,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -339,7 +339,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -370,7 +370,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -4.4f, 5);
AssertHelpers.AlmostEqualRelative(a[1], 0.25f, 5);
@ -396,7 +396,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var a = new Complex32[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount);
LinearAlgebraControl.Provider.LUInverse(a, matrix.RowCount);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454f, 5);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908f, 5);
@ -422,8 +422,8 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUInverseFactored(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454f, 5);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908f, 5);
@ -447,7 +447,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
Array.Copy(matrix.Values, a, a.Length);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.LUSolve(2, a, matrix.RowCount, b);
LinearAlgebraControl.Provider.LUSolve(2, a, matrix.RowCount, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726f, 5);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815f, 5);
@ -470,10 +470,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
Array.Copy(matrix.Values, a, a.Length);
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
LinearAlgebraControl.Provider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726f, 5);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815f, 5);
@ -490,7 +490,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
public void CanComputeCholeskyFactor()
{
var matrix = new Complex32[] {1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15};
Control.LinearAlgebraProvider.CholeskyFactor(matrix, 4);
LinearAlgebraControl.Provider.CholeskyFactor(matrix, 4);
Assert.AreEqual(matrix[0].Real, 1);
Assert.AreEqual(matrix[1].Real, 1);
Assert.AreEqual(matrix[2].Real, 1);
@ -519,7 +519,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var a = new Complex32[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.CholeskySolve(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolve(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 5);
AssertHelpers.AlmostEqualRelative(b[1], 1, 5);
@ -539,10 +539,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
{
var a = new Complex32[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
Control.LinearAlgebraProvider.CholeskyFactor(a, 3);
LinearAlgebraControl.Provider.CholeskyFactor(a, 3);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.CholeskySolveFactored(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolveFactored(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 5);
AssertHelpers.AlmostEqualRelative(b[1], 1, 5);
@ -564,7 +564,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[3];
var q = new Complex32[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -591,7 +591,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[3];
var q = new Complex32[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -618,7 +618,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[3];
var q = new Complex32[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -645,7 +645,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var q = new Complex32[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -672,7 +672,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var q = new Complex32[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -699,7 +699,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -726,7 +726,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -752,11 +752,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[matrix.ColumnCount];
var q = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -782,11 +782,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[matrix.ColumnCount];
var q = new Complex32[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -809,7 +809,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 3, a, matrix);
@ -836,7 +836,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 2, a, matrix);
@ -862,11 +862,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[matrix.ColumnCount];
var r = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -892,11 +892,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var tau = new Complex32[matrix.ColumnCount];
var r = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -921,7 +921,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -958,7 +958,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -992,7 +992,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1024,7 +1024,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -1051,7 +1051,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -1079,11 +1079,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -1111,11 +1111,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Complex32
var u = new Complex32[matrix.RowCount*matrix.RowCount];
var vt = new Complex32[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new Complex32[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;

112
src/UnitTests/Providers/LinearAlgebra/Double/LinearAlgebraProviderTests.cs

@ -80,21 +80,21 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.AddVectorToScaledVector(_y, 0, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(_y, 0, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, 1, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, 1, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + _x[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, Math.PI, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, Math.PI, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + (Math.PI*_x[i]), result[i]);
@ -109,14 +109,14 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.ScaleArray(1, _y, result);
LinearAlgebraControl.Provider.ScaleArray(1, _y, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.ScaleArray(Math.PI, result, result);
LinearAlgebraControl.Provider.ScaleArray(Math.PI, result, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i]*Math.PI, result[i]);
@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
[Test]
public void CanComputeDotProduct()
{
var result = Control.LinearAlgebraProvider.DotProduct(_x, _y);
var result = LinearAlgebraControl.Provider.DotProduct(_x, _y);
AssertHelpers.AlmostEqualRelative(152.35, result, 14);
}
@ -140,7 +140,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanAddArrays()
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.AddArrays(_x, _y, result);
LinearAlgebraControl.Provider.AddArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] + _y[i], result[i]);
@ -154,7 +154,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanSubtractArrays()
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.SubtractArrays(_x, _y, result);
LinearAlgebraControl.Provider.SubtractArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] - _y[i], result[i]);
@ -168,7 +168,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanPointWiseMultiplyArrays()
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]*_y[i], result[i]);
@ -182,7 +182,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanPointWiseDivideArrays()
{
var result = new double[_y.Length];
Control.LinearAlgebraProvider.PointWiseDivideArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]/_y[i], result[i]);
@ -196,7 +196,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanComputeMatrixL1Norm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(12.1, norm, 6);
}
@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanComputeMatrixFrobeniusNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(10.777754868246, norm, 8);
}
@ -218,7 +218,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanComputeMatrixInfinityNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
Assert.AreEqual(16.5, norm);
}
@ -232,7 +232,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -274,7 +274,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -295,7 +295,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -316,7 +316,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -360,7 +360,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -4.4, 14);
AssertHelpers.AlmostEqualRelative(a[1], 0.25, 14);
@ -386,7 +386,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var a = new double[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount);
LinearAlgebraControl.Provider.LUInverse(a, matrix.RowCount);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908, 13);
@ -412,8 +412,8 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUInverseFactored(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqualRelative(a[0], -0.454545454545454, 13);
AssertHelpers.AlmostEqualRelative(a[1], -0.909090909090908, 13);
@ -437,7 +437,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
Array.Copy(matrix.Values, a, a.Length);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.LUSolve(2, a, matrix.RowCount, b);
LinearAlgebraControl.Provider.LUSolve(2, a, matrix.RowCount, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 13);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 13);
@ -460,10 +460,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
Array.Copy(matrix.Values, a, a.Length);
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
LinearAlgebraControl.Provider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 13);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 13);
@ -480,7 +480,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
public void CanComputeCholeskyFactor()
{
var matrix = new double[] {1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15};
Control.LinearAlgebraProvider.CholeskyFactor(matrix, 4);
LinearAlgebraControl.Provider.CholeskyFactor(matrix, 4);
Assert.AreEqual(matrix[0], 1);
Assert.AreEqual(matrix[1], 1);
Assert.AreEqual(matrix[2], 1);
@ -509,7 +509,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var a = new double[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.CholeskySolve(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolve(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 14);
AssertHelpers.AlmostEqualRelative(b[1], 1, 14);
@ -529,10 +529,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
{
var a = new double[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
Control.LinearAlgebraProvider.CholeskyFactor(a, 3);
LinearAlgebraControl.Provider.CholeskyFactor(a, 3);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
Control.LinearAlgebraProvider.CholeskySolveFactored(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolveFactored(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 14);
AssertHelpers.AlmostEqualRelative(b[1], 1, 14);
@ -554,7 +554,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[3];
var q = new double[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mq = Matrix<double>.Build.Dense(matrix.RowCount, matrix.RowCount, q);
var mr = Matrix<double>.Build.Dense(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -581,7 +581,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[3];
var q = new double[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = Matrix<double>.Build.Dense(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = Matrix<double>.Build.Dense(matrix.RowCount, matrix.RowCount, q);
@ -608,7 +608,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[3];
var q = new double[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = Matrix<double>.Build.Dense(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = Matrix<double>.Build.Dense(matrix.RowCount, matrix.RowCount, q);
@ -635,7 +635,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var q = new double[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = Matrix<double>.Build.Dense(matrix.RowCount, matrix.ColumnCount, q);
var mr = Matrix<double>.Build.Dense(matrix.ColumnCount, matrix.ColumnCount, r);
@ -662,7 +662,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var q = new double[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = Matrix<double>.Build.Dense(matrix.RowCount, matrix.ColumnCount, q);
var mr = Matrix<double>.Build.Dense(matrix.ColumnCount, matrix.ColumnCount, r);
@ -689,7 +689,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -716,7 +716,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -742,11 +742,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mx = Matrix<double>.Build.Dense(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -772,11 +772,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[matrix.ColumnCount];
var q = new double[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mb = Matrix<double>.Build.Dense(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -799,7 +799,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 3, a, matrix);
@ -826,7 +826,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 2, a, matrix);
@ -852,11 +852,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[matrix.ColumnCount];
var r = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mx = Matrix<double>.Build.Dense(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -882,11 +882,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var tau = new double[matrix.ColumnCount];
var r = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mb = Matrix<double>.Build.Dense(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -911,7 +911,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -948,7 +948,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -982,7 +982,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1014,7 +1014,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -1041,7 +1041,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -1069,11 +1069,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mx = Matrix<double>.Build.Dense(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -1101,11 +1101,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Double
var u = new double[matrix.RowCount*matrix.RowCount];
var vt = new double[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
var x = new double[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mb = Matrix<double>.Build.Dense(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;

112
src/UnitTests/Providers/LinearAlgebra/Single/LinearAlgebraProviderTests.cs

@ -80,21 +80,21 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.AddVectorToScaledVector(_y, 0, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(_y, 0, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, 1, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, 1, _x, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i] + _x[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.AddVectorToScaledVector(result, (float) Math.PI, _x, result);
LinearAlgebraControl.Provider.AddVectorToScaledVector(result, (float) Math.PI, _x, result);
for (var i = 0; i < _y.Length; i++)
{
AssertHelpers.AlmostEqualRelative(_y[i] + ((float) Math.PI*_x[i]), result[i], 5);
@ -109,14 +109,14 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.ScaleArray(1, _y, result);
LinearAlgebraControl.Provider.ScaleArray(1, _y, result);
for (var i = 0; i < _y.Length; i++)
{
Assert.AreEqual(_y[i], result[i]);
}
Array.Copy(_y, result, _y.Length);
Control.LinearAlgebraProvider.ScaleArray((float) Math.PI, result, result);
LinearAlgebraControl.Provider.ScaleArray((float) Math.PI, result, result);
for (var i = 0; i < _y.Length; i++)
{
AssertHelpers.AlmostEqualRelative(_y[i]*(float) Math.PI, result[i], 5);
@ -129,7 +129,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
[Test]
public void CanComputeDotProduct()
{
var result = Control.LinearAlgebraProvider.DotProduct(_x, _y);
var result = LinearAlgebraControl.Provider.DotProduct(_x, _y);
AssertHelpers.AlmostEqualRelative(152.35, result, 5);
}
@ -140,7 +140,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanAddArrays()
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.AddArrays(_x, _y, result);
LinearAlgebraControl.Provider.AddArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] + _y[i], result[i]);
@ -154,7 +154,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanSubtractArrays()
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.SubtractArrays(_x, _y, result);
LinearAlgebraControl.Provider.SubtractArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] - _y[i], result[i]);
@ -168,7 +168,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanPointWiseMultiplyArrays()
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.PointWiseMultiplyArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseMultiplyArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]*_y[i], result[i]);
@ -182,7 +182,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanPointWiseDivideArrays()
{
var result = new float[_y.Length];
Control.LinearAlgebraProvider.PointWiseDivideArrays(_x, _y, result);
LinearAlgebraControl.Provider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i]/_y[i], result[i]);
@ -196,7 +196,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanComputeMatrixL1Norm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.OneNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqualRelative(12.1, norm, 5);
}
@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanComputeMatrixFrobeniusNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.FrobeniusNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
AssertHelpers.AlmostEqual(10.777754868246, norm, 5);
}
@ -218,7 +218,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanComputeMatrixInfinityNorm()
{
var matrix = _matrices["Square3x3"];
var norm = Control.LinearAlgebraProvider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
var norm = LinearAlgebraControl.Provider.MatrixNorm(Norm.InfinityNorm, matrix.RowCount, matrix.ColumnCount, matrix.Values);
Assert.AreEqual(16.5, norm);
}
@ -232,7 +232,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -274,7 +274,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
LinearAlgebraControl.Provider.MatrixMultiply(x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -295,7 +295,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Square3x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -316,7 +316,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Tall3x2"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var y = _matrices["Wide2x3"];
var c = new DenseMatrix(x.RowCount, y.ColumnCount);
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
LinearAlgebraControl.Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2f, x.Values, x.RowCount, x.ColumnCount, y.Values, y.RowCount, y.ColumnCount, 1.0f, c.Values);
for (var i = 0; i < c.RowCount; i++)
{
@ -368,7 +368,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqual(a[0], -4.4, 5);
AssertHelpers.AlmostEqual(a[1], 0.25, 5);
@ -394,7 +394,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var a = new float[matrix.RowCount*matrix.RowCount];
Array.Copy(matrix.Values, a, a.Length);
Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount);
LinearAlgebraControl.Provider.LUInverse(a, matrix.RowCount);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 5);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 5);
@ -420,8 +420,8 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
Control.LinearAlgebraProvider.LUInverseFactored(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUInverseFactored(a, matrix.RowCount, ipiv);
AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 5);
AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 5);
@ -445,7 +445,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
Array.Copy(matrix.Values, a, a.Length);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.LUSolve(2, a, matrix.RowCount, b);
LinearAlgebraControl.Provider.LUSolve(2, a, matrix.RowCount, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 5);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 5);
@ -468,10 +468,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
Array.Copy(matrix.Values, a, a.Length);
var ipiv = new int[matrix.RowCount];
Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv);
LinearAlgebraControl.Provider.LUFactor(a, matrix.RowCount, ipiv);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
LinearAlgebraControl.Provider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b);
AssertHelpers.AlmostEqualRelative(b[0], -1.477272727272726, 5);
AssertHelpers.AlmostEqualRelative(b[1], -4.318181818181815, 5);
@ -488,7 +488,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
public void CanComputeCholeskyFactor()
{
var matrix = new float[] {1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15};
Control.LinearAlgebraProvider.CholeskyFactor(matrix, 4);
LinearAlgebraControl.Provider.CholeskyFactor(matrix, 4);
Assert.AreEqual(matrix[0], 1);
Assert.AreEqual(matrix[1], 1);
Assert.AreEqual(matrix[2], 1);
@ -517,7 +517,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var a = new float[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.CholeskySolve(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolve(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 5);
AssertHelpers.AlmostEqualRelative(b[1], 1, 5);
@ -537,10 +537,10 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
{
var a = new float[] {1, 1, 1, 1, 2, 3, 1, 3, 6};
Control.LinearAlgebraProvider.CholeskyFactor(a, 3);
LinearAlgebraControl.Provider.CholeskyFactor(a, 3);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
Control.LinearAlgebraProvider.CholeskySolveFactored(a, 3, b, 2);
LinearAlgebraControl.Provider.CholeskySolveFactored(a, 3, b, 2);
AssertHelpers.AlmostEqualRelative(b[0], 0, 5);
AssertHelpers.AlmostEqualRelative(b[1], 1, 5);
@ -562,7 +562,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[3];
var q = new float[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
@ -589,7 +589,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[3];
var q = new float[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -616,7 +616,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[3];
var q = new float[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(r, matrix.RowCount, matrix.ColumnCount, q, tau);
var mr = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, r).UpperTriangle();
var mq = new DenseMatrix(matrix.RowCount, matrix.RowCount, q);
@ -643,7 +643,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var q = new float[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -670,7 +670,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var q = new float[matrix.RowCount*matrix.ColumnCount];
Array.Copy(matrix.Values, q, q.Length);
Control.LinearAlgebraProvider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(q, matrix.RowCount, matrix.ColumnCount, r, tau);
var mq = new DenseMatrix(matrix.RowCount, matrix.ColumnCount, q);
var mr = new DenseMatrix(matrix.ColumnCount, matrix.ColumnCount, r);
@ -697,7 +697,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -724,7 +724,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -750,11 +750,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[matrix.ColumnCount];
var q = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -780,11 +780,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[matrix.ColumnCount];
var q = new float[matrix.RowCount*matrix.RowCount];
Control.LinearAlgebraProvider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
LinearAlgebraControl.Provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
LinearAlgebraControl.Provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -807,7 +807,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 3, a, matrix);
@ -834,7 +834,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x, QRMethod.Thin);
NotModified(3, 2, a, matrix);
@ -860,11 +860,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[matrix.ColumnCount];
var r = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -890,11 +890,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var tau = new float[matrix.ColumnCount];
var r = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
LinearAlgebraControl.Provider.ThinQRFactor(a, matrix.RowCount, matrix.ColumnCount, r, tau);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
LinearAlgebraControl.Provider.QRSolveFactored(a, r, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x, QRMethod.Thin);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;
@ -919,7 +919,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var u = new float[matrix.RowCount*matrix.RowCount];
var vt = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -956,7 +956,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var u = new float[matrix.RowCount*matrix.RowCount];
var vt = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -990,7 +990,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var u = new float[matrix.RowCount*matrix.RowCount];
var vt = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var w = new DenseMatrix(matrix.RowCount, matrix.ColumnCount);
for (var index = 0; index < s.Length; index++)
@ -1022,7 +1022,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 3, a, matrix);
@ -1049,7 +1049,7 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
LinearAlgebraControl.Provider.SvdSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x);
NotModified(3, 2, a, matrix);
@ -1077,11 +1077,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var u = new float[matrix.RowCount*matrix.RowCount];
var vt = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mx = new DenseMatrix(matrix.ColumnCount, 2, x);
var mb = matrix*mx;
@ -1109,11 +1109,11 @@ namespace MathNet.Numerics.UnitTests.Providers.LinearAlgebra.Single
var u = new float[matrix.RowCount*matrix.RowCount];
var vt = new float[matrix.ColumnCount*matrix.ColumnCount];
Control.LinearAlgebraProvider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
LinearAlgebraControl.Provider.SingularValueDecomposition(true, a, matrix.RowCount, matrix.ColumnCount, s, u, vt);
var b = new[] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
var x = new float[matrix.ColumnCount*2];
Control.LinearAlgebraProvider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
LinearAlgebraControl.Provider.SvdSolveFactored(matrix.RowCount, matrix.ColumnCount, s, u, vt, b, 2, x);
var mb = new DenseMatrix(matrix.RowCount, 2, b);
var test = (matrix.Transpose()*matrix).Inverse()*matrix.Transpose()*mb;

8
src/UnitTests/UseLinearAlgebraProvider.cs

@ -29,6 +29,10 @@
using System;
using System.Runtime.InteropServices;
using MathNet.Numerics.Providers.FourierTransform;
using MathNet.Numerics.Providers.LinearAlgebra;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
@ -63,8 +67,8 @@ namespace MathNet.Numerics.UnitTests
Console.WriteLine($"CLR Version: {Environment.Version}");
Console.WriteLine($"OS Version: {Environment.OSVersion}");
#endif
Console.WriteLine($"Linear Algebra Provider: {Control.LinearAlgebraProvider}");
Console.WriteLine($"Fourier Transform Provider: {Control.FourierTransformProvider}");
Console.WriteLine($"Linear Algebra Provider: {LinearAlgebraControl.Provider}");
Console.WriteLine($"Fourier Transform Provider: {FourierTransformControl.Provider}");
Console.WriteLine();
// ReSharper restore LocalizableElement
}

Loading…
Cancel
Save