Browse Source

LA: Matrix.Conjugate

v2
Christoph Ruegg 14 years ago
parent
commit
836a07457e
  1. 15
      src/Numerics/LinearAlgebra/Complex/Matrix.cs
  2. 15
      src/Numerics/LinearAlgebra/Complex32/Matrix.cs
  3. 14
      src/Numerics/LinearAlgebra/Double/Matrix.cs
  4. 38
      src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
  5. 14
      src/Numerics/LinearAlgebra/Single/Matrix.cs

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

@ -301,6 +301,21 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
/// <summary>
/// Complex conjugates each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
protected override void DoConjugate(Matrix<Complex> result)
{
for (var i = 0; i < RowCount; i++)
{
for (var j = 0; j != ColumnCount; j++)
{
result.At(i, j, At(i, j).Conjugate());
}
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

15
src/Numerics/LinearAlgebra/Complex32/Matrix.cs

@ -301,6 +301,21 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
/// <summary>
/// Complex conjugates each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
protected override void DoConjugate(Matrix<Complex32> result)
{
for (var i = 0; i < RowCount; i++)
{
for (var j = 0; j != ColumnCount; j++)
{
result.At(i, j, At(i, j).Conjugate());
}
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

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

@ -291,6 +291,20 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Complex conjugates each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
protected override void DoConjugate(Matrix<double> result)
{
if (ReferenceEquals(this, result))
{
return;
}
CopyTo(result);
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

38
src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs

@ -56,6 +56,12 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">The result of the negation.</param>
protected abstract void DoNegate(Matrix<T> result);
/// <summary>
/// Complex conjugates each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
protected abstract void DoConjugate(Matrix<T> result);
/// <summary>
/// Adds another matrix to this matrix.
/// </summary>
@ -804,6 +810,38 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
DoNegate(result);
}
/// <summary>
/// Complex conjugate each element of this matrix.
/// </summary>
/// <returns>A matrix containing the conjugated values.</returns>
public Matrix<T> Conjugate()
{
var result = CreateMatrix(RowCount, ColumnCount);
DoConjugate(result);
return result;
}
/// <summary>
/// Complex conjugate each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">if the result matrix's dimensions are not the same as this matrix.</exception>
public void Conjugate(Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
}
DoConjugate(result);
}
/// <summary>
/// Adds two matrices together and returns the results.
/// </summary>

14
src/Numerics/LinearAlgebra/Single/Matrix.cs

@ -307,6 +307,20 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
/// <summary>
/// Complex conjugates each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
protected override void DoConjugate(Matrix<float> result)
{
if (ReferenceEquals(this, result))
{
return;
}
CopyTo(result);
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

Loading…
Cancel
Save