Browse Source

matrix: MatrixMultiply now call MatrixMultiplyWithUpdate

pull/36/head
Marcus Cuda 17 years ago
parent
commit
b475b85b31
  1. 5
      src/FSharpExamples/FSharpExamples.fsproj
  2. 5
      src/FSharpUnitTests/FSharpUnitTests.fsproj
  3. 49
      src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs

5
src/FSharpExamples/FSharpExamples.fsproj

@ -37,6 +37,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FSharp\FSharp.fsproj">
<Name>FSharp</Name>
<Project>{37e8e802-a354-4114-bfc1-6e1357da605b}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Numerics\Numerics.csproj">
<Name>Numerics</Name>
<Project>{b7cae5f4-a23f-4438-b5be-41226618b695}</Project>

5
src/FSharpUnitTests/FSharpUnitTests.fsproj

@ -41,6 +41,11 @@
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FSharp\FSharp.fsproj">
<Name>FSharp</Name>
<Project>{37e8e802-a354-4114-bfc1-6e1357da605b}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Numerics\Numerics.csproj">
<Name>Numerics</Name>
<Project>{b7cae5f4-a23f-4438-b5be-41226618b695}</Project>

49
src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.cs

@ -328,20 +328,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
// TODO - For small matrices we should get rid of the parallelism because of startup costs.
// Perhaps the following implementations would be a good one
// http://blog.feradz.com/2009/01/cache-efficient-matrix-multiplication/
Parallel.For(0, xRows, i =>
{
int ixIndex = i * xColumns;
int iyIndex = i * yColumns;
for (int j = 0; j < yColumns; j++)
{
double s = 0;
for (int k = 0; k < xColumns; k++)
{
s += xdata[k + ixIndex] * ydata[j + yColumns * k];
}
result[j + iyIndex] = s;
}
});
MatrixMultiplyWithUpdate(Transpose.DontTranspose,Transpose.DontTranspose,1.0,x,xRows,xColumns,y,yRows,yColumns,0.0,result);
}
/// <summary>
@ -1117,16 +1104,8 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
// TODO - For small matrices we should get rid of the parallelism because of startup costs.
// Perhaps the following implementations would be a good one
// http://blog.feradz.com/2009/01/cache-efficient-matrix-multiplication/
Parallel.For(0, xRows, i =>
{
for (int j = 0; j < yColumns; j++)
{
for (int k = 0; k < xColumns; k++)
{
result[j + yColumns * i] += xdata[k + xColumns * i] * ydata[j + yColumns * k];
}
}
});
MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0f, x, xRows, xColumns, y, yRows, yColumns, 0.0f, result);
}
/// <summary>
@ -1909,16 +1888,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
// TODO - For small matrices we should get rid of the parallelism because of startup costs.
// Perhaps the following implementations would be a good one
// http://blog.feradz.com/2009/01/cache-efficient-matrix-multiplication/
Parallel.For(0, xRows, i =>
{
for (int j = 0; j < yColumns; j++)
{
for (int k = 0; k < xColumns; k++)
{
result[j + yColumns * i] += xdata[k + xColumns * i] * ydata[j + yColumns * k];
}
}
});
MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex.One, x, xRows, xColumns, y, yRows, yColumns, Complex.Zero, result);
}
/// <summary>
@ -2669,16 +2639,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra
// TODO - For small matrices we should get rid of the parallelism because of startup costs.
// Perhaps the following implementations would be a good one
// http://blog.feradz.com/2009/01/cache-efficient-matrix-multiplication/
Parallel.For(0, xRows, i =>
{
for (int j = 0; j < yColumns; j++)
{
for (int k = 0; k < xColumns; k++)
{
result[j + yColumns * i] += xdata[k + xColumns * i] * ydata[j + yColumns * k];
}
}
});
MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, Complex32.One, x, xRows, xColumns, y, yRows, yColumns, Complex32.Zero, result);
}
/// <summary>

Loading…
Cancel
Save