Browse Source

fixed native scale bugs and added pointwise divide

la-knuth
Marcus Cuda 16 years ago
parent
commit
e2ef47c574
  1. 16
      src/NativeWrappers/MKL/vector_functions.c
  2. 4
      src/NativeWrappers/Windows/MKLWrapper32Tests/MKLWrapper32Tests.csproj
  3. 2
      src/NativeWrappers/Windows/MKLWrapper64Tests/MKLWrapper64Tests.csproj
  4. 18
      src/Numerics/Algorithms/LinearAlgebra/native.generic.include
  5. 2
      src/Numerics/Algorithms/LinearAlgebra/native.vector.include
  6. 15
      src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

16
src/NativeWrappers/MKL/vector_functions.c

@ -15,6 +15,10 @@ DLLEXPORT void s_vector_multiply( const int n, const float x[], const float y[],
vsMul( n, x, y, result );
}
DLLEXPORT void s_vector_divide( const int n, const float x[], const float y[], float result[] ){
vsDiv( n, x, y, result );
}
DLLEXPORT void d_vector_add( const int n, const double x[], const double y[], double result[] ){
vdAdd( n, x, y, result );
}
@ -27,6 +31,10 @@ DLLEXPORT void d_vector_multiply( const int n, const double x[], const double y[
vdMul( n, x, y, result );
}
DLLEXPORT void d_vector_divide( const int n, const double x[], const double y[], double result[] ){
vdDiv( n, x, y, result );
}
DLLEXPORT void c_vector_add( const int n, const Complex8 x[], const Complex8 y[], Complex8 result[] ){
vcAdd( n, x, y, result );
}
@ -39,6 +47,10 @@ DLLEXPORT void c_vector_multiply( const int n, const Complex8 x[], const Complex
vcMul( n, x, y, result );
}
DLLEXPORT void c_vector_divide( const int n, const Complex8 x[], const Complex8 y[], Complex8 result[] ){
vcDiv( n, x, y, result );
}
DLLEXPORT void z_vector_add( const int n, const Complex16 x[], const Complex16 y[], Complex16 result[] ){
vzAdd( n, x, y, result );
}
@ -50,3 +62,7 @@ DLLEXPORT void z_vector_subtract( const int n, const Complex16 x[], const Comple
DLLEXPORT void z_vector_multiply( const int n, const Complex16 x[], const Complex16 y[], Complex16 result[] ){
vzMul( n, x, y, result );
}
DLLEXPORT void z_vector_divide( const int n, const Complex16 x[], const Complex16 y[], Complex16 result[] ){
vzDiv( n, x, y, result );
}

4
src/NativeWrappers/Windows/MKLWrapper32Tests/MKLWrapper32Tests.csproj

@ -55,9 +55,9 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="MathNet.Numerics, Version=2010.11.21.836, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<Reference Include="MathNet.Numerics, Version=2011.2.14.770, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\out\lib\Net40\MathNet.Numerics.dll</HintPath>
<HintPath>..\..\..\..\out\debug\Net40\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\lib\NUnit.2.5.9\nunit.framework.dll</HintPath>

2
src/NativeWrappers/Windows/MKLWrapper64Tests/MKLWrapper64Tests.csproj

@ -55,7 +55,7 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="MathNet.Numerics, Version=2010.7.9.1414, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<Reference Include="MathNet.Numerics, Version=2011.2.14.756, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\out\debug\Net40\MathNet.Numerics.dll</HintPath>
</Reference>

18
src/Numerics/Algorithms/LinearAlgebra/native.generic.include

@ -23,15 +23,16 @@
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (!ReferenceEquals(y, result))
{
Array.Copy(y, 0, result, 0, y.Length);
}
if (alpha == <#=zero#>)
{
return;
}
if (!ReferenceEquals(y, result)){
Array.Copy(y, 0, result, 0, y.Length * 8);
}
SafeNativeMethods.<#=prefix#>_axpy(y.Length, <#=reff#>alpha, x, result);
}
@ -49,15 +50,16 @@
throw new ArgumentNullException("x");
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
}
if (alpha == <#=one#>)
{
return;
}
if (!ReferenceEquals(x, result)){
Array.Copy(x, 0, result, 0, x.Length * 8);
}
SafeNativeMethods.<#=prefix#>_scale(x.Length, <#=reff#>alpha, result);
}

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

@ -103,7 +103,7 @@
SafeNativeMethods.<#=prefix#>_vector_multiply(x.Length, x, y, result);
}
/// <summary>
/// <summary>
/// Does a point wise division of two arrays <c>z = x / y</c>. This can be used
/// to divide elements of vectors or matrices.
/// </summary>

15
src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

@ -181,6 +181,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
}
}
/// <summary>
/// Can pointwise divide two arrays.
/// </summary>
[Test]
public void CanPointWiseDivideArrays()
{
var result = new double[_y.Length];
Provider.PointWiseDivideArrays(_x, _y, result);
for (var i = 0; i < result.Length; i++)
{
Assert.AreEqual(_x[i] / _y[i], result[i]);
}
}
/// <summary>
/// Can compute L1 norm.
/// </summary>

Loading…
Cancel
Save