Browse Source

LA: Add matrix dot-power with matrix exponent

benchmark-la
Christoph Ruegg 10 years ago
parent
commit
5a5bc8a6f5
  1. 14
      src/Numerics/LinearAlgebra/Complex/Matrix.cs
  2. 14
      src/Numerics/LinearAlgebra/Complex32/Matrix.cs
  3. 14
      src/Numerics/LinearAlgebra/Double/Matrix.cs
  4. 43
      src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs
  5. 14
      src/Numerics/LinearAlgebra/Single/Matrix.cs

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

@ -347,15 +347,25 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result vector.
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Complex exponent, Matrix<Complex> result)
{
Map(x => x.Power(exponent), result, Zeros.Include);
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Matrix<Complex> exponent, Matrix<Complex> result)
{
Map2(Complex.Pow, result, Zeros.Include);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix with another matrix and stores the result into the result matrix.

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

@ -342,15 +342,25 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result vector.
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Complex32 exponent, Matrix<Complex32> result)
{
Map(x => x.Power(exponent), result, Zeros.Include);
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Matrix<Complex32> exponent, Matrix<Complex32> result)
{
Map2(Complex32.Pow, result, Zeros.Include);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix with another matrix and stores the result into the result matrix.

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

@ -357,15 +357,25 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result vector.
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected override void DoPointwisePower(double exponent, Matrix<double> result)
{
Map(x => Math.Pow(x, exponent), result, exponent > 0.0 ? Zeros.AllowSkip : Zeros.Include);
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Matrix<double> exponent, Matrix<double> result)
{
Map2(Math.Pow, result, Zeros.Include);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix with another matrix and stores the result into the result matrix.

43
src/Numerics/LinearAlgebra/Matrix.Arithmetic.cs

@ -224,12 +224,19 @@ namespace MathNet.Numerics.LinearAlgebra
protected abstract void DoPointwiseDivide(Matrix<T> divisor, Matrix<T> result);
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result vector.
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected abstract void DoPointwisePower(T exponent, Matrix<T> result);
/// <summary>
/// Pointwise raise this matrix to an exponent matrix and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent matrix to raise this matrix values to.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected abstract void DoPointwisePower(Matrix<T> exponent, Matrix<T> result);
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix with another matrix and stores the result into the result matrix.
@ -1391,6 +1398,38 @@ namespace MathNet.Numerics.LinearAlgebra
DoPointwisePower(exponent, result);
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
public Matrix<T> PointwisePower(Matrix<T> exponent)
{
if (ColumnCount != exponent.ColumnCount || RowCount != exponent.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, exponent);
}
var result = Build.SameAs(this);
DoPointwisePower(exponent, result);
return result;
}
/// <summary>
/// Pointwise raise this matrix to an exponent.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The matrix to store the result into.</param>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwisePower(Matrix<T> exponent, Matrix<T> result)
{
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != exponent.ColumnCount || RowCount != exponent.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, exponent, result);
}
DoPointwisePower(exponent, result);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix by another matrix.

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

@ -357,15 +357,25 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result vector.
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
/// <param name="result">The matrix to store the result of the pointwise power.</param>
protected override void DoPointwisePower(float exponent, Matrix<float> result)
{
Map(x => (float)Math.Pow(x, exponent), result, exponent > 0.0f ? Zeros.AllowSkip : Zeros.Include);
}
/// <summary>
/// Pointwise raise this matrix to an exponent and store the result into the result matrix.
/// </summary>
/// <param name="exponent">The exponent to raise this matrix values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Matrix<float> exponent, Matrix<float> result)
{
Map2((x, y) => (float)Math.Pow(x, y), result, Zeros.Include);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this matrix with another matrix and stores the result into the result matrix.

Loading…
Cancel
Save