Browse Source

native: seperated out the code into seperate include files instead of using 'if' statements.

la-knuth
Marcus Cuda 16 years ago
parent
commit
252d8d5a8e
  1. 3
      .gitignore
  2. 7
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
  3. 7
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
  4. 7
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
  5. 7
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
  6. 225
      src/Numerics/Algorithms/LinearAlgebra/native.common.include
  7. 2
      src/Numerics/Algorithms/LinearAlgebra/native.footer.include
  8. 45
      src/Numerics/Algorithms/LinearAlgebra/native.header.include
  9. 104
      src/Numerics/Algorithms/LinearAlgebra/native.vector.include
  10. 5
      src/Numerics/Numerics.csproj

3
.gitignore

@ -10,4 +10,5 @@ _ReSharper*
bin
*.vsdoc
*.XML
Version1.cs
Version1.cs
src/Numerics/Algorithms/LinearAlgebra/Mkl/*.cs

7
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt

@ -1,10 +1,13 @@
<#@ template language="C#" debug="true" #>
<#@ output extenstion="cs" #>
<# string library = "Mkl";#>
<# string title = "Intel's Math Kernel Library (MKL)";#>
<# string dataType = "Complex";#>
<# string zero = "Complex.Zero";#>
<# string one = "Complex.One";#>
<# string prefix = "z";#>
<# string reff = "ref ";#>
<#@ include file="..\NativeAlgebraProvider.include" #>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.common.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

7
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt

@ -1,10 +1,13 @@
<#@ template language="C#" debug="true" #>
<#@ output extenstion="cs" #>
<# string library = "Mkl";#>
<# string title = "Intel's Math Kernel Library (MKL)";#>
<# string dataType = "Complex32";#>
<# string zero = "Complex32.Zero";#>
<# string one = "Complex32.One";#>
<# string prefix = "c";#>
<# string reff = "ref ";#>
<#@ include file="..\NativeAlgebraProvider.include" #>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.common.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

7
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt

@ -1,10 +1,13 @@
<#@ template language="C#" debug="true" #>
<#@ output extenstion="cs" #>
<# string library = "Mkl";#>
<# string title = "Intel's Math Kernel Library (MKL)";#>
<# string dataType = "double";#>
<# string zero = "0.0";#>
<# string one = "1.0";#>
<# string prefix = "d";#>
<# string reff = "";#>
<#@ include file="..\NativeAlgebraProvider.include" #>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.common.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

7
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt

@ -1,10 +1,13 @@
<#@ template language="C#" debug="true" #>
<#@ output extenstion="cs" #>
<# string library = "Mkl";#>
<# string title = "Intel's Math Kernel Library (MKL)";#>
<# string dataType = "float";#>
<# string zero = "0.0f";#>
<# string one = "1.0f";#>
<# string prefix = "s";#>
<# string reff = "";#>
<#@ include file="..\NativeAlgebraProvider.include" #>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.common.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

225
src/Numerics/Algorithms/LinearAlgebra/NativeAlgebraProvider.include → src/Numerics/Algorithms/LinearAlgebra/native.common.include

@ -1,48 +1,4 @@
// <copyright file="<#=library#>LinearAlgebraProvider.<#=dataType#>.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KINDC:\source\mathnet-marcus\src\Numerics\Algorithms\LinearAlgebra\NewFolder1\,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
/* This file is automatically generated - do not modify it.
Change NativeLinearAlgebraProvider.include instead.
Last generated on UTC <#=DateTime.UtcNow.ToString("u")#>
*/
namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
{
using System;
using System.Numerics;
using Properties;
/// <summary>
/// The managed linear algebra provider.
/// </summary>
public partial class <#=library#>LinearAlgebraProvider : ManagedLinearAlgebraProvider
{
/// <summary>
 /// <summary>
/// Adds a scaled vector to another: <c>y += alpha*x</c>.
/// </summary>
/// <param name="y">The vector to update.</param>
@ -122,149 +78,6 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y);
}
<# if( library.Equals("Mkl") ){ #>
/// <summary>
/// Does a point wise add of two arrays <c>z = x + y</c>. This can be used
/// to add vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void AddArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_add( x.Length, x, y, result );
}
<#} #>
<# if( library.Equals("Mkl") ){ #>
/// <summary>
/// Does a point wise subtraction of two arrays <c>z = x - y</c>. This can be used
/// to subtract vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the subtraction.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void SubtractArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_subtract( x.Length, x, y, result );
}
<#} #>
<# if( library.Equals("Mkl") ){ #>
/// <summary>
/// Does a point wise multiplication of two arrays <c>z = x * y</c>. This can be used
/// to multiple elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise multiplication.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void PointWiseMultiplyArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_multiply( x.Length, x, y, result );
}
<#} #>
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows in the matrix.</param>
/// <param name="columns">The number of columns in the matrix.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows in the matrix.</param>
/// <param name="columns">The number of columns in the matrix.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/>
/// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix, <#=dataType#>[] work)
{
throw new NotImplementedException();
}
/// <summary>
/// Multiples two matrices. <c>result = x * y</c>
/// </summary>
@ -330,6 +143,40 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
SafeNativeMethods.<#=prefix#>_matrix_multiply(transposeA, transposeB, m, n, k, <#=reff#>alpha, a, b, <#=reff#>beta, c);
}
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows in the matrix.</param>
/// <param name="columns">The number of columns in the matrix.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>
/// <param name="norm">The type of norm to compute.</param>
/// <param name="rows">The number of rows in the matrix.</param>
/// <param name="columns">The number of columns in the matrix.</param>
/// <param name="matrix">The matrix to compute the norm from.</param>
/// <param name="work">The work array. Only used when <see cref="Norm.InfinityNorm"/>
/// and needs to be have a length of at least M (number of rows of <paramref name="matrix"/>.</param>
/// <returns>
/// The requested <see cref="Norm"/> of the matrix.
/// </returns>
public override <#=dataType#> MatrixNorm(Norm norm, int rows, int columns, <#=dataType#>[] matrix, <#=dataType#>[] work)
{
throw new NotImplementedException();
}
/// <summary>
/// Computes the LUP factorization of A. P*A = L*U.
@ -680,5 +527,3 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
{
throw new NotImplementedException();
}
}
}

2
src/Numerics/Algorithms/LinearAlgebra/native.footer.include

@ -0,0 +1,2 @@
 }
}

45
src/Numerics/Algorithms/LinearAlgebra/native.header.include

@ -0,0 +1,45 @@
// <copyright file="<#=library#>LinearAlgebraProvider.<#=dataType#>.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2010 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
/* This file is automatically generated - do not modify it.
Last generated on UTC <#=DateTime.UtcNow.ToString("u")#>
*/
namespace MathNet.Numerics.Algorithms.LinearAlgebra.<#=library#>
{
using System;
using System.Numerics;
using Properties;
/// <summary>
/// <#=title#> linear algebra provider.
/// </summary>
public partial class <#=library#>LinearAlgebraProvider : ManagedLinearAlgebraProvider
{

104
src/Numerics/Algorithms/LinearAlgebra/native.vector.include

@ -0,0 +1,104 @@
 /// <summary>
/// Does a point wise add of two arrays <c>z = x + y</c>. This can be used
/// to add vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void AddArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_add( x.Length, x, y, result );
}
/// <summary>
/// Does a point wise subtraction of two arrays <c>z = x - y</c>. This can be used
/// to subtract vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the subtraction.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void SubtractArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_subtract( x.Length, x, y, result );
}
/// <summary>
/// Does a point wise multiplication of two arrays <c>z = x * y</c>. This can be used
/// to multiple elements of vectors or matrices.
/// </summary>
/// <param name="x">The array x.</param>
/// <param name="y">The array y.</param>
/// <param name="result">The result of the point wise multiplication.</param>
/// <remarks>There is no equivalent BLAS routine, but many libraries
/// provide optimized (parallel and/or vectorized) versions of this
/// routine.</remarks>
public override void PointWiseMultiplyArrays(<#=dataType#>[] x, <#=dataType#>[] y, <#=dataType#>[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
if (x.Length != result.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
SafeNativeMethods.<#=prefix#>_vector_multiply( x.Length, x, y, result );
}

5
src/Numerics/Numerics.csproj

@ -70,6 +70,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Algorithms\LinearAlgebra\native.footer.include" />
<None Include="Algorithms\LinearAlgebra\native.common.include" />
<None Include="Algorithms\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex32.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MklLinearAlgebraProvider.Complex32.cs</LastGenOutput>
@ -90,7 +92,7 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>SafeNativeMethods.cs</LastGenOutput>
</None>
<None Include="Algorithms\LinearAlgebra\NativeAlgebraProvider.include" />
<None Include="Algorithms\LinearAlgebra\native.vector.include" />
<Compile Include="Algorithms\LinearAlgebra\ManagedLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Algorithms\LinearAlgebra\ManagedLinearAlgebraProvider.Complex.cs" />
<Compile Include="Algorithms\LinearAlgebra\ManagedLinearAlgebraProvider.Single.cs" />
@ -453,6 +455,7 @@
<None Include="..\MathNet.Numerics.snk">
<Link>MathNet.Numerics.snk</Link>
</None>
<None Include="Algorithms\LinearAlgebra\native.header.include" />
<None Include="Algorithms\LinearAlgebra\SafeNativeMethods.include">
<LastGenOutput>SafeNativeMethods.cs</LastGenOutput>
</None>

Loading…
Cancel
Save