Browse Source

LA: vector dot-power with vector exponent, bound to provider

pull/445/head
Christoph Ruegg 10 years ago
parent
commit
d1dfb51a3d
  1. 26
      src/Numerics/LinearAlgebra/Complex/DenseVector.cs
  2. 10
      src/Numerics/LinearAlgebra/Complex/Vector.cs
  3. 20
      src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
  4. 10
      src/Numerics/LinearAlgebra/Complex32/Vector.cs
  5. 20
      src/Numerics/LinearAlgebra/Double/DenseVector.cs
  6. 10
      src/Numerics/LinearAlgebra/Double/Vector.cs
  7. 20
      src/Numerics/LinearAlgebra/Single/DenseVector.cs
  8. 10
      src/Numerics/LinearAlgebra/Single/Vector.cs
  9. 44
      src/Numerics/LinearAlgebra/Vector.Arithmetic.cs

26
src/Numerics/LinearAlgebra/Complex/DenseVector.cs

@ -635,16 +635,36 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <remarks></remarks>
protected override void DoPointwiseDivide(Vector<Complex> divisor, Vector<Complex> result)
{
var denseOther = divisor as DenseVector;
var denseDivisor = divisor as DenseVector;
var denseResult = result as DenseVector;
if (denseOther == null || denseResult == null)
if (denseDivisor == null || denseResult == null)
{
base.DoPointwiseDivide(divisor, result);
}
else
{
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseOther._values, denseResult._values);
Control.LinearAlgebraProvider.PointWiseDivideArrays(_values, denseDivisor._values, denseResult._values);
}
}
/// <summary>
/// Pointwise raise this vector to an exponent vector and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent vector to raise this vector values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Vector<Complex> exponent, Vector<Complex> result)
{
var denseExponent = exponent as DenseVector;
var denseResult = result as DenseVector;
if (denseExponent == null || denseResult == null)
{
base.DoPointwisePower(exponent, result);
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}

10
src/Numerics/LinearAlgebra/Complex/Vector.cs

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

20
src/Numerics/LinearAlgebra/Complex32/DenseVector.cs

@ -643,6 +643,26 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
/// <summary>
/// Pointwise raise this vector to an exponent vector and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent vector to raise this vector values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Vector<Complex32> exponent, Vector<Complex32> result)
{
var denseExponent = exponent as DenseVector;
var denseResult = result as DenseVector;
if (denseExponent == null || denseResult == null)
{
base.DoPointwisePower(exponent, result);
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}
#region Parse Functions
/// <summary>

10
src/Numerics/LinearAlgebra/Complex32/Vector.cs

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

20
src/Numerics/LinearAlgebra/Double/DenseVector.cs

@ -725,6 +725,26 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
/// <summary>
/// Pointwise raise this vector to an exponent vector and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent vector to raise this vector values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Vector<double> exponent, Vector<double> result)
{
var denseExponent = exponent as DenseVector;
var denseResult = result as DenseVector;
if (denseExponent == null || denseResult == null)
{
base.DoPointwisePower(exponent, result);
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}
#region Parse Functions
/// <summary>

10
src/Numerics/LinearAlgebra/Double/Vector.cs

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

20
src/Numerics/LinearAlgebra/Single/DenseVector.cs

@ -715,6 +715,26 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
/// <summary>
/// Pointwise raise this vector to an exponent vector and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent vector to raise this vector values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected override void DoPointwisePower(Vector<float> exponent, Vector<float> result)
{
var denseExponent = exponent as DenseVector;
var denseResult = result as DenseVector;
if (denseExponent == null || denseResult == null)
{
base.DoPointwisePower(exponent, result);
}
else
{
Control.LinearAlgebraProvider.PointWisePowerArrays(_values, denseExponent._values, denseResult._values);
}
}
#region Parse Functions
/// <summary>

10
src/Numerics/LinearAlgebra/Single/Vector.cs

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

44
src/Numerics/LinearAlgebra/Vector.Arithmetic.cs

@ -198,6 +198,13 @@ namespace MathNet.Numerics.LinearAlgebra
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected abstract void DoPointwisePower(T exponent, Vector<T> result);
/// <summary>
/// Pointwise raise this vector to an exponent vector and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent vector to raise this vector values to.</param>
/// <param name="result">The vector to store the result of the pointwise power.</param>
protected abstract void DoPointwisePower(Vector<T> exponent, Vector<T> result);
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this vector with another vector and stores the result into the result vector.
@ -822,6 +829,43 @@ namespace MathNet.Numerics.LinearAlgebra
DoPointwisePower(exponent, result);
}
/// <summary>
/// Pointwise raise this vector to an exponent and store the result into the result vector.
/// </summary>
/// <param name="exponent">The exponent to raise this vector values to.</param>
public Vector<T> PointwisePower(Vector<T> exponent)
{
if (Count != exponent.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "exponent");
}
var result = Build.SameAs(this);
DoPointwisePower(exponent, result);
return result;
}
/// <summary>
/// Pointwise raise this vector to an exponent.
/// </summary>
/// <param name="exponent">The exponent to raise this vector values to.</param>
/// <param name="result">The vector to store the result into.</param>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwisePower(Vector<T> exponent, Vector<T> result)
{
if (Count != exponent.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "exponent");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
}
DoPointwisePower(exponent, result);
}
/// <summary>
/// Pointwise canonical modulus, where the result has the sign of the divisor,
/// of this vector with another vector.

Loading…
Cancel
Save