Browse Source

LA: Leverage providers for scalar division

optimization-1
Christoph Ruegg 13 years ago
parent
commit
d0d982f77e
  1. 18
      src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
  2. 18
      src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
  3. 18
      src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
  4. 18
      src/Numerics/LinearAlgebra/Single/DenseMatrix.cs

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

@ -546,6 +546,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
/// <summary>
/// Divides each element of the matrix by a scalar and places results into the result matrix.
/// </summary>
/// <param name="scalar">The scalar to divide the matrix with.</param>
/// <param name="result">The matrix to store the result of the division.</param>
protected override void DoDivide(Complex scalar, Matrix<Complex> result)
{
var denseResult = result as DenseMatrix;
if (denseResult == null)
{
base.DoDivide(scalar, result);
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0/scalar, _values, denseResult._values);
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

18
src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs

@ -541,6 +541,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
/// <summary>
/// Divides each element of the matrix by a scalar and places results into the result matrix.
/// </summary>
/// <param name="scalar">The scalar to divide the matrix with.</param>
/// <param name="result">The matrix to store the result of the division.</param>
protected override void DoDivide(Complex32 scalar, Matrix<Complex32> result)
{
var denseResult = result as DenseMatrix;
if (denseResult == null)
{
base.DoDivide(scalar, result);
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/scalar, _values, denseResult._values);
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

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

@ -627,6 +627,24 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Divides each element of the matrix by a scalar and places results into the result matrix.
/// </summary>
/// <param name="scalar">The scalar to divide the matrix with.</param>
/// <param name="result">The matrix to store the result of the division.</param>
protected override void DoDivide(double scalar, Matrix<double> result)
{
var denseResult = result as DenseMatrix;
if (denseResult == null)
{
base.DoDivide(scalar, result);
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0/scalar, _values, denseResult._values);
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

18
src/Numerics/LinearAlgebra/Single/DenseMatrix.cs

@ -627,6 +627,24 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
/// <summary>
/// Divides each element of the matrix by a scalar and places results into the result matrix.
/// </summary>
/// <param name="scalar">The scalar to divide the matrix with.</param>
/// <param name="result">The matrix to store the result of the division.</param>
protected override void DoDivide(float scalar, Matrix<float> result)
{
var denseResult = result as DenseMatrix;
if (denseResult == null)
{
base.DoDivide(scalar, result);
}
else
{
Control.LinearAlgebraProvider.ScaleArray(1.0f/scalar, _values, denseResult._values);
}
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>

Loading…
Cancel
Save