diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
index 248c3ffe..47c43d44 100644
--- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
+++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
@@ -8,6 +8,7 @@
<# string prefix = "z";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<#@ include file="..\native.header.include" #>
+<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>
diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
index 8eea9ba0..5a090ced 100644
--- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
+++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
@@ -8,6 +8,7 @@
<# string prefix = "c";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<#@ include file="..\native.header.include" #>
+<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>
diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
index 494672f2..c56166e4 100644
--- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
+++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
@@ -8,6 +8,7 @@
<# string prefix = "d";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))";#>
<#@ include file="..\native.header.include" #>
+<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>
diff --git a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
index f1fa9ace..c240be3e 100644
--- a/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
+++ b/src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
@@ -8,6 +8,7 @@
<# string prefix = "s";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))";#>
<#@ include file="..\native.header.include" #>
+<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>
diff --git a/src/Numerics/Algorithms/LinearAlgebra/native.dotproduct.include b/src/Numerics/Algorithms/LinearAlgebra/native.dotproduct.include
new file mode 100644
index 00000000..ea6462bf
--- /dev/null
+++ b/src/Numerics/Algorithms/LinearAlgebra/native.dotproduct.include
@@ -0,0 +1,27 @@
+ ///
+ /// Computes the dot product of x and y.
+ ///
+ /// The vector x.
+ /// The vector y.
+ /// The dot product of x and y.
+ /// This is equivalent to the DOT BLAS routine.
+ [SecuritySafeCritical]
+ public override <#=dataType#> DotProduct(<#=dataType#>[] x, <#=dataType#>[] y)
+ {
+ if (y == null)
+ {
+ throw new ArgumentNullException("y");
+ }
+
+ if (x == null)
+ {
+ throw new ArgumentNullException("x");
+ }
+
+ if (x.Length != y.Length)
+ {
+ throw new ArgumentException(Resources.ArgumentArraysSameLength);
+ }
+
+ return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y);
+ }
\ No newline at end of file
diff --git a/src/Numerics/Algorithms/LinearAlgebra/native.generic.include b/src/Numerics/Algorithms/LinearAlgebra/native.generic.include
index 8c7ad13b..1ee54ed2 100644
--- a/src/Numerics/Algorithms/LinearAlgebra/native.generic.include
+++ b/src/Numerics/Algorithms/LinearAlgebra/native.generic.include
@@ -65,34 +65,6 @@
SafeNativeMethods.<#=prefix#>_scale(x.Length, alpha, result);
}
- ///
- /// Computes the dot product of x and y.
- ///
- /// The vector x.
- /// The vector y.
- /// The dot product of x and y.
- /// This is equivalent to the DOT BLAS routine.
- [SecuritySafeCritical]
- public override <#=dataType#> DotProduct(<#=dataType#>[] x, <#=dataType#>[] y)
- {
- if (y == null)
- {
- throw new ArgumentNullException("y");
- }
-
- if (x == null)
- {
- throw new ArgumentNullException("x");
- }
-
- if (x.Length != y.Length)
- {
- throw new ArgumentException(Resources.ArgumentArraysSameLength);
- }
-
- return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y);
- }
-
///
/// Multiples two matrices. result = x * y
///
@@ -215,7 +187,18 @@
}
var work = new <#=dataType#>[order];
- SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, order);
+<# if (dataType == "float") { #>
+ if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
+ {
+ new ManagedLinearAlgebraProvider().LUInverse(a, order, work);
+ }
+ else
+ {
+ SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
+ }
+<# } else{#>
+ SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, work.Length);
+<# } #>
}
///
@@ -249,7 +232,18 @@
}
var work = new <#=dataType#>[order];
+<# if (dataType == "float") { #>
+ if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
+ {
+ new ManagedLinearAlgebraProvider().LUInverseFactored(a, order, ipiv, work);
+ }
+ else
+ {
+ SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
+ }
+<# }else{ #>
SafeNativeMethods.<#=prefix#>_lu_inverse_factored(order, a, ipiv, work, order);
+<# } #>
}
///
@@ -284,7 +278,18 @@
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
+<# if (dataType == "float") { #>
+ if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
+ {
+ new ManagedLinearAlgebraProvider().LUInverse(a, order, work);
+ }
+ else
+ {
+ SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
+ }
+<# } else{#>
SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, work.Length);
+<# } #>
}
///
@@ -330,7 +335,18 @@
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
+<# if (dataType == "float") { #>
+ if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
+ {
+ new ManagedLinearAlgebraProvider().LUInverseFactored(a, order, ipiv, work);
+ }
+ else
+ {
+ SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
+ }
+<# }else{ #>
SafeNativeMethods.<#=prefix#>_lu_inverse_factored(order, a, ipiv, work, order);
+<# } #>
}
///
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index 31420faa..df734792 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -70,6 +70,7 @@
+
TextTemplatingFileGenerator
GotoBlasLinearAlgebraProvider.Common.cs