@ -28,9 +28,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
using System ;
using System.Collections.Generic ;
using Algorithms.LinearAlgebra ;
using LinearAlgebra.Double ;
using LinearAlgebra.Generic ;
using NUnit.Framework ;
@ -41,23 +41,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
[TestFixture]
public class LinearAlgebraProviderTests
{
/// <summary>
/// Initializes a new instance of the <see cref="LinearAlgebraProviderTests"/> class.
/// </summary>
public LinearAlgebraProviderTests ( )
{
Provider = new ManagedLinearAlgebraProvider ( ) ;
}
/// <summary>
/// Gets or sets linear algebra provider to test.
/// </summary>
protected ILinearAlgebraProvider Provider
{
get ;
set ;
}
/// <summary>
/// The Y double test vector.
/// </summary>
@ -89,21 +72,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var result = new double [ _ y . Length ] ;
Provider . AddVectorToScaledVector ( _ y , 0 , _ x , result ) ;
Control . LinearAlgebra 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 ) ;
Provider . AddVectorToScaledVector ( result , 1 , _ x , result ) ;
Control . LinearAlgebra 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 ) ;
Provider . AddVectorToScaledVector ( result , Math . PI , _ x , result ) ;
Control . LinearAlgebra 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 ] ) ;
@ -118,14 +101,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var result = new double [ _ y . Length ] ;
Provider . ScaleArray ( 1 , _ y , result ) ;
Control . LinearAlgebra 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 ) ;
Provider . ScaleArray ( Math . PI , result , result ) ;
Control . LinearAlgebra Provider. ScaleArray ( Math . PI , result , result ) ;
for ( var i = 0 ; i < _ y . Length ; i + + )
{
Assert . AreEqual ( _ y [ i ] * Math . PI , result [ i ] ) ;
@ -138,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
[Test]
public void CanComputeDotProduct ( )
{
var result = Provider . DotProduct ( _ x , _ y ) ;
var result = Control . LinearAlgebra Provider. DotProduct ( _ x , _ y ) ;
AssertHelpers . AlmostEqual ( 1 5 2.35 , result , 1 5 ) ;
}
@ -149,7 +132,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanAddArrays ( )
{
var result = new double [ _ y . Length ] ;
Provider . AddArrays ( _ x , _ y , result ) ;
Control . LinearAlgebra Provider. AddArrays ( _ x , _ y , result ) ;
for ( var i = 0 ; i < result . Length ; i + + )
{
Assert . AreEqual ( _ x [ i ] + _ y [ i ] , result [ i ] ) ;
@ -163,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanSubtractArrays ( )
{
var result = new double [ _ y . Length ] ;
Provider . SubtractArrays ( _ x , _ y , result ) ;
Control . LinearAlgebra Provider. SubtractArrays ( _ x , _ y , result ) ;
for ( var i = 0 ; i < result . Length ; i + + )
{
Assert . AreEqual ( _ x [ i ] - _ y [ i ] , result [ i ] ) ;
@ -177,7 +160,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanPointWiseMultiplyArrays ( )
{
var result = new double [ _ y . Length ] ;
Provider . PointWiseMultiplyArrays ( _ x , _ y , result ) ;
Control . LinearAlgebra Provider. PointWiseMultiplyArrays ( _ x , _ y , result ) ;
for ( var i = 0 ; i < result . Length ; i + + )
{
Assert . AreEqual ( _ x [ i ] * _ y [ i ] , result [ i ] ) ;
@ -191,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanPointWiseDivideArrays ( )
{
var result = new double [ _ y . Length ] ;
Provider . PointWiseDivideArrays ( _ x , _ y , result ) ;
Control . LinearAlgebra Provider. PointWiseDivideArrays ( _ x , _ y , result ) ;
for ( var i = 0 ; i < result . Length ; i + + )
{
Assert . AreEqual ( _ x [ i ] / _ y [ i ] , result [ i ] ) ;
@ -206,7 +189,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _ matrices [ "Square3x3" ] ;
var work = new double [ matrix . RowCount ] ;
var norm = Provider . MatrixNorm ( Norm . OneNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . OneNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
AssertHelpers . AlmostEqual ( 1 2.1 , norm , 6 ) ;
}
@ -218,7 +201,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _ matrices [ "Square3x3" ] ;
var work = new double [ matrix . RowCount ] ;
var norm = Provider . MatrixNorm ( Norm . FrobeniusNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . FrobeniusNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
AssertHelpers . AlmostEqual ( 1 0.777754868246 , norm , 8 ) ;
}
@ -230,7 +213,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var matrix = _ matrices [ "Square3x3" ] ;
var work = new double [ matrix . RowCount ] ;
var norm = Provider . MatrixNorm ( Norm . InfinityNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . InfinityNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data , work ) ;
Assert . AreEqual ( 1 6.5 , norm ) ;
}
@ -241,7 +224,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixL1NormWithWorkArray ( )
{
var matrix = _ matrices [ "Square3x3" ] ;
var norm = Provider . MatrixNorm ( Norm . OneNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . OneNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
AssertHelpers . AlmostEqual ( 1 2.1 , norm , 6 ) ;
}
@ -252,7 +235,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixFrobeniusNormWithWorkArray ( )
{
var matrix = _ matrices [ "Square3x3" ] ;
var norm = Provider . MatrixNorm ( Norm . FrobeniusNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . FrobeniusNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
AssertHelpers . AlmostEqual ( 1 0.777754868246 , norm , 8 ) ;
}
@ -263,7 +246,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeMatrixInfinityNormWithWorkArray ( )
{
var matrix = _ matrices [ "Square3x3" ] ;
var norm = Provider . MatrixNorm ( Norm . InfinityNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
var norm = Control . LinearAlgebra Provider. MatrixNorm ( Norm . InfinityNorm , matrix . RowCount , matrix . ColumnCount , matrix . Data ) ;
Assert . AreEqual ( 1 6.5 , norm ) ;
}
@ -277,7 +260,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Square3x3" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -298,7 +281,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Tall3x2" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -319,7 +302,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Wide2x3" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiply ( x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -340,7 +323,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Square3x3" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -361,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Tall3x2" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -382,7 +365,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var y = _ matrices [ "Wide2x3" ] ;
var c = new DenseMatrix ( x . RowCount , y . ColumnCount ) ;
Provider . MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
Control . LinearAlgebra Provider. MatrixMultiplyWithUpdate ( Transpose . DontTranspose , Transpose . DontTranspose , 2.2 , x . Data , x . RowCount , x . ColumnCount , y . Data , y . RowCount , y . ColumnCount , 1.0 , c . Data ) ;
for ( var i = 0 ; i < c . RowCount ; i + + )
{
@ -405,7 +388,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int [ matrix . RowCount ] ;
Provider . LUFactor ( a , matrix . RowCount , ipiv ) ;
Control . LinearAlgebra Provider. LUFactor ( a , matrix . RowCount , ipiv ) ;
AssertHelpers . AlmostEqual ( a [ 0 ] , - 4.4 , 1 5 ) ;
AssertHelpers . AlmostEqual ( a [ 1 ] , 0.25 , 1 5 ) ;
@ -431,7 +414,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var a = new double [ matrix . RowCount * matrix . RowCount ] ;
Array . Copy ( matrix . Data , a , a . Length ) ;
Provider . LUInverse ( a , matrix . RowCount ) ;
Control . LinearAlgebra Provider. LUInverse ( a , matrix . RowCount ) ;
AssertHelpers . AlmostEqual ( a [ 0 ] , - 0.454545454545454 , 1 4 ) ;
AssertHelpers . AlmostEqual ( a [ 1 ] , - 0.909090909090908 , 1 4 ) ;
@ -457,8 +440,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int [ matrix . RowCount ] ;
Provider . LUFactor ( a , matrix . RowCount , ipiv ) ;
Provider . LUInverseFactored ( a , matrix . RowCount , ipiv ) ;
Control . LinearAlgebra Provider. LUFactor ( a , matrix . RowCount , ipiv ) ;
Control . LinearAlgebra Provider. LUInverseFactored ( a , matrix . RowCount , ipiv ) ;
AssertHelpers . AlmostEqual ( a [ 0 ] , - 0.454545454545454 , 1 4 ) ;
AssertHelpers . AlmostEqual ( a [ 1 ] , - 0.909090909090908 , 1 4 ) ;
@ -483,7 +466,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array . Copy ( matrix . Data , a , a . Length ) ;
var work = new double [ matrix . RowCount ] ;
Provider . LUInverse ( a , matrix . RowCount , work ) ;
Control . LinearAlgebra Provider. LUInverse ( a , matrix . RowCount , work ) ;
AssertHelpers . AlmostEqual ( a [ 0 ] , - 0.454545454545454 , 1 4 ) ;
AssertHelpers . AlmostEqual ( a [ 1 ] , - 0.909090909090908 , 1 4 ) ;
@ -509,10 +492,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var ipiv = new int [ matrix . RowCount ] ;
Provider . LUFactor ( a , matrix . RowCount , ipiv ) ;
Control . LinearAlgebra Provider. LUFactor ( a , matrix . RowCount , ipiv ) ;
var work = new double [ matrix . RowCount ] ;
Provider . LUInverseFactored ( a , matrix . RowCount , ipiv , work ) ;
Control . LinearAlgebra Provider. LUInverseFactored ( a , matrix . RowCount , ipiv , work ) ;
AssertHelpers . AlmostEqual ( a [ 0 ] , - 0.454545454545454 , 1 4 ) ;
AssertHelpers . AlmostEqual ( a [ 1 ] , - 0.909090909090908 , 1 4 ) ;
@ -536,7 +519,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array . Copy ( matrix . Data , a , a . Length ) ;
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
Provider . LUSolve ( 2 , a , matrix . RowCount , b ) ;
Control . LinearAlgebra Provider. LUSolve ( 2 , a , matrix . RowCount , b ) ;
AssertHelpers . AlmostEqual ( b [ 0 ] , - 1.477272727272726 , 1 4 ) ;
AssertHelpers . AlmostEqual ( b [ 1 ] , - 4.318181818181815 , 1 4 ) ;
@ -559,10 +542,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
Array . Copy ( matrix . Data , a , a . Length ) ;
var ipiv = new int [ matrix . RowCount ] ;
Provider . LUFactor ( a , matrix . RowCount , ipiv ) ;
Control . LinearAlgebra Provider. LUFactor ( a , matrix . RowCount , ipiv ) ;
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
Provider . LUSolveFactored ( 2 , a , matrix . RowCount , ipiv , b ) ;
Control . LinearAlgebra Provider. LUSolveFactored ( 2 , a , matrix . RowCount , ipiv , b ) ;
AssertHelpers . AlmostEqual ( b [ 0 ] , - 1.477272727272726 , 1 4 ) ;
AssertHelpers . AlmostEqual ( b [ 1 ] , - 4.318181818181815 , 1 4 ) ;
@ -579,7 +562,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
public void CanComputeCholeskyFactor ( )
{
var matrix = new double [ ] { 1 , 1 , 1 , 1 , 1 , 5 , 5 , 5 , 1 , 5 , 1 4 , 1 4 , 1 , 5 , 1 4 , 1 5 } ;
Provider . CholeskyFactor ( matrix , 4 ) ;
Control . LinearAlgebra Provider. CholeskyFactor ( matrix , 4 ) ;
Assert . AreEqual ( matrix [ 0 ] , 1 ) ;
Assert . AreEqual ( matrix [ 1 ] , 1 ) ;
Assert . AreEqual ( matrix [ 2 ] , 1 ) ;
@ -608,7 +591,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.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 } ;
Provider . CholeskySolve ( a , 3 , b , 2 ) ;
Control . LinearAlgebra Provider. CholeskySolve ( a , 3 , b , 2 ) ;
AssertHelpers . AlmostEqual ( b [ 0 ] , 0 , 1 4 ) ;
AssertHelpers . AlmostEqual ( b [ 1 ] , 1 , 1 4 ) ;
@ -628,10 +611,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{
var a = new double [ ] { 1 , 1 , 1 , 1 , 2 , 3 , 1 , 3 , 6 } ;
Provider . CholeskyFactor ( a , 3 ) ;
Control . LinearAlgebra Provider. CholeskyFactor ( a , 3 ) ;
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
Provider . CholeskySolveFactored ( a , 3 , b , 2 ) ;
Control . LinearAlgebra Provider. CholeskySolveFactored ( a , 3 , b , 2 ) ;
AssertHelpers . AlmostEqual ( b [ 0 ] , 0 , 1 4 ) ;
AssertHelpers . AlmostEqual ( b [ 1 ] , 1 , 1 4 ) ;
@ -653,7 +636,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau ) ;
Control . LinearAlgebra 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 ( ) ;
@ -680,7 +663,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau ) ;
Control . LinearAlgebra 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 ) ;
@ -707,7 +690,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau ) ;
Control . LinearAlgebra 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 ) ;
@ -735,7 +718,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
var work = new double [ matrix . ColumnCount * Control . BlockSize ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
Control . LinearAlgebra Provider. QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
var mq = new DenseMatrix ( matrix . RowCount , matrix . RowCount , q ) ;
var mr = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount , r ) . UpperTriangle ( ) ;
@ -763,7 +746,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
var work = new double [ matrix . ColumnCount * Control . BlockSize ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
Control . LinearAlgebra Provider. QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
var mr = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount , r ) . UpperTriangle ( ) ;
var mq = new DenseMatrix ( matrix . RowCount , matrix . RowCount , q ) ;
@ -791,7 +774,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ 3 ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
var work = new double [ matrix . ColumnCount * Control . BlockSize ] ;
Provider . QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
Control . LinearAlgebra Provider. QRFactor ( r , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
var mr = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount , r ) . UpperTriangle ( ) ;
var mq = new DenseMatrix ( matrix . RowCount , matrix . RowCount , q ) ;
@ -818,7 +801,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
Control . LinearAlgebra Provider. QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
NotModified ( 3 , 3 , a , matrix ) ;
@ -845,7 +828,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
Control . LinearAlgebra Provider. QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
NotModified ( 3 , 2 , a , matrix ) ;
@ -872,7 +855,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
var work = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x , work ) ;
Control . LinearAlgebra Provider. QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x , work ) ;
NotModified ( 3 , 3 , a , matrix ) ;
@ -901,7 +884,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
var work = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x , work ) ;
Control . LinearAlgebra Provider. QRSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x , work ) ;
NotModified ( 3 , 2 , a , matrix ) ;
@ -927,11 +910,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ matrix . ColumnCount ] ;
var q = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau ) ;
Control . LinearAlgebra 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 ] ;
Provider . QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x ) ;
Control . LinearAlgebra Provider. QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x ) ;
var mx = new DenseMatrix ( matrix . ColumnCount , 2 , x ) ;
var mb = matrix * mx ;
@ -957,11 +940,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ matrix . ColumnCount ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
Provider . QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau ) ;
Control . LinearAlgebra 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 ] ;
Provider . QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x ) ;
Control . LinearAlgebra 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 ;
@ -986,11 +969,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ matrix . ColumnCount ] ;
var q = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
var work = new double [ 2 0 4 8 ] ;
Provider . QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
Control . LinearAlgebra Provider. QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x , work ) ;
Control . LinearAlgebra Provider. QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x , work ) ;
var mx = new DenseMatrix ( matrix . ColumnCount , 2 , x ) ;
var mb = matrix * mx ;
@ -1017,11 +1000,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var tau = new double [ matrix . ColumnCount ] ;
var q = new double [ matrix . RowCount * matrix . RowCount ] ;
var work = new double [ 2 0 4 8 ] ;
Provider . QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
Control . LinearAlgebra Provider. QRFactor ( a , matrix . RowCount , matrix . ColumnCount , q , tau , work ) ;
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x , work ) ;
Control . LinearAlgebra Provider. QRSolveFactored ( q , a , matrix . RowCount , matrix . ColumnCount , tau , b , 2 , x , work ) ;
var mb = new DenseMatrix ( matrix . RowCount , 2 , b ) ;
var test = ( matrix . Transpose ( ) * matrix ) . Inverse ( ) * matrix . Transpose ( ) * mb ;
@ -1046,7 +1029,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double [ matrix . RowCount * matrix . RowCount ] ;
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt ) ;
Control . LinearAlgebra 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 + + )
@ -1083,7 +1066,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double [ matrix . RowCount * matrix . RowCount ] ;
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt ) ;
Control . LinearAlgebra 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 + + )
@ -1117,7 +1100,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double [ matrix . RowCount * matrix . RowCount ] ;
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt ) ;
Control . LinearAlgebra 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 + + )
@ -1153,7 +1136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
var work = new double [ 1 0 0 ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
Control . LinearAlgebra Provider. SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
var w = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount ) ;
for ( var index = 0 ; index < s . Length ; index + + )
@ -1192,7 +1175,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
var work = new double [ 1 0 0 ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
Control . LinearAlgebra Provider. SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
var w = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount ) ;
for ( var index = 0 ; index < s . Length ; index + + )
@ -1228,7 +1211,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
var work = new double [ 1 0 0 ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
Control . LinearAlgebra Provider. SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt , work ) ;
var w = new DenseMatrix ( matrix . RowCount , matrix . ColumnCount ) ;
for ( var index = 0 ; index < s . Length ; index + + )
@ -1260,7 +1243,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . SvdSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
Control . LinearAlgebra Provider. SvdSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
NotModified ( 3 , 3 , a , matrix ) ;
@ -1287,7 +1270,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var b = new [ ] { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 } ;
var x = new double [ matrix . ColumnCount * 2 ] ;
Provider . SvdSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
Control . LinearAlgebra Provider. SvdSolve ( a , matrix . RowCount , matrix . ColumnCount , b , 2 , x ) ;
NotModified ( 3 , 2 , a , matrix ) ;
@ -1315,11 +1298,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double [ matrix . RowCount * matrix . RowCount ] ;
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt ) ;
Control . LinearAlgebra 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 ] ;
Provider . SvdSolveFactored ( matrix . RowCount , matrix . ColumnCount , s , u , vt , b , 2 , x ) ;
Control . LinearAlgebra Provider. SvdSolveFactored ( matrix . RowCount , matrix . ColumnCount , s , u , vt , b , 2 , x ) ;
var mx = new DenseMatrix ( matrix . ColumnCount , 2 , x ) ;
var mb = matrix * mx ;
@ -1347,11 +1330,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
var u = new double [ matrix . RowCount * matrix . RowCount ] ;
var vt = new double [ matrix . ColumnCount * matrix . ColumnCount ] ;
Provider . SingularValueDecomposition ( true , a , matrix . RowCount , matrix . ColumnCount , s , u , vt ) ;
Control . LinearAlgebra 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 ] ;
Provider . SvdSolveFactored ( matrix . RowCount , matrix . ColumnCount , s , u , vt , b , 2 , x ) ;
Control . LinearAlgebra 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 ;