Browse Source

Implemented DoTransposeThisAndMultiply for matrices on Double.

la-knuth
Alexander Karatarakis 16 years ago
committed by Marcus Cuda
parent
commit
71cd9c691d
  1. 25
      src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
  2. 22
      src/Numerics/LinearAlgebra/Double/Matrix.cs

25
src/Numerics/LinearAlgebra/Double/DenseMatrix.cs

@ -461,7 +461,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
Algorithms.LinearAlgebra.Transpose.DontTranspose,
Algorithms.LinearAlgebra.Transpose.Transpose,
Algorithms.LinearAlgebra.Transpose.DontTranspose,
1.0,
Data,
@ -482,7 +482,28 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeThisAndMultiply(Matrix<double> other, Matrix<double> result)
{
throw new NotImplementedException();
var denseOther = other as DenseMatrix;
var denseResult = result as DenseMatrix;
if (denseOther == null || denseResult == null)
{
base.DoTransposeThisAndMultiply(other, result);
}
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
Algorithms.LinearAlgebra.Transpose.Transpose,
Algorithms.LinearAlgebra.Transpose.DontTranspose,
1.0,
Data,
RowCount,
ColumnCount,
denseOther.Data,
denseOther.RowCount,
denseOther.ColumnCount,
0.0,
denseResult.Data);
}
}
/// <summary>

22
src/Numerics/LinearAlgebra/Double/Matrix.cs

@ -269,6 +269,28 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix.
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeThisAndMultiply(Matrix<double> other, Matrix<double> result)
{
for (var j = 0; j < other.ColumnCount; j++)
{
for (var i = 0; i < ColumnCount; i++)
{
var s = 0.0;
for (var l = 0; l < RowCount; l++)
{
s += At(l, i) * other.At(l, j);
}
result.At(i, j, s);
}
}
}
/// <summary>
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
/// </summary>

Loading…
Cancel
Save