Browse Source

Implemented DoTransposeThisAndMultiply for matrices & Vectors on Complex.

la-knuth
Alexander Karatarakis 16 years ago
committed by Marcus Cuda
parent
commit
765cae8482
  1. 62
      src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
  2. 40
      src/Numerics/LinearAlgebra/Complex/Matrix.cs

62
src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs

@ -404,6 +404,68 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
/// <summary>
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
/// </summary>
/// <param name="rightSide">The vector to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeThisAndMultiply(Vector<Complex> rightSide, Vector<Complex> result)
{
var denseRight = rightSide as DenseVector;
var denseResult = result as DenseVector;
if (denseRight == null || denseResult == null)
{
base.DoTransposeThisAndMultiply(rightSide, result);
}
else
{
Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate(
Algorithms.LinearAlgebra.Transpose.Transpose,
Algorithms.LinearAlgebra.Transpose.DontTranspose,
1.0,
Data,
RowCount,
ColumnCount,
denseRight.Data,
denseRight.Count,
1,
0.0,
denseResult.Data);
}
}
/// <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<Complex> other, Matrix<Complex> result)
{
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>
/// Negate each element of this matrix and place the results into the result matrix.
/// </summary>

40
src/Numerics/LinearAlgebra/Complex/Matrix.cs

@ -279,6 +279,46 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
/// <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<Complex> other, Matrix<Complex> result)
{
for (var j = 0; j < other.ColumnCount; j++)
{
for (var i = 0; i < ColumnCount; i++)
{
var s = Complex.Zero;
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>
/// <param name="rightSide">The vector to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
protected override void DoTransposeThisAndMultiply(Vector<Complex> rightSide, Vector<Complex> result)
{
for (var i = 0; i < ColumnCount; i++)
{
var s = Complex.Zero;
for (var j = 0; j != RowCount; j++)
{
s += At(j, i) * rightSide[j];
}
result[i] = s;
}
}
/// <summary>
/// Negate each element of this matrix and place the results into the result matrix.
/// </summary>

Loading…
Cancel
Save