|
|
@ -620,6 +620,38 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
Control.LinearAlgebraProvider.ScaleArray(scalar, Data); |
|
|
Control.LinearAlgebraProvider.ScaleArray(scalar, Data); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Computes the dot product between this vector and another vector.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="other">The other vector to add.</param>
|
|
|
|
|
|
/// <returns>The result of the addition.</returns>
|
|
|
|
|
|
/// <exception cref="ArgumentException">If <paramref name="other"/> is not of the same size.</exception>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException">If <paramref name="other"/> is <see langword="null" />.</exception>
|
|
|
|
|
|
public override double DotProduct(Vector other) |
|
|
|
|
|
{ |
|
|
|
|
|
if (other == null) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentNullException("other"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var denseVector = other as DenseVector; |
|
|
|
|
|
|
|
|
|
|
|
if (denseVector == null) |
|
|
|
|
|
{ |
|
|
|
|
|
return base.DotProduct(other); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return Control.LinearAlgebraProvider.DotProduct(this.Data, denseVector.Data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Multiplies a vector with a scalar.
|
|
|
/// Multiplies a vector with a scalar.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -658,6 +690,34 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Computes the dot product between two <strong>Vectors</strong>.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="leftSide">The left row vector.</param>
|
|
|
|
|
|
/// <param name="rightSide">The right column vector.</param>
|
|
|
|
|
|
/// <returns>The dot product between the two vectors.</returns>
|
|
|
|
|
|
/// <exception cref="ArgumentException">If <paramref name="leftSide"/> and <paramref name="rightSide"/> are not the same size.</exception>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
|
|
|
|
|
|
public static double operator *(DenseVector leftSide, DenseVector rightSide) |
|
|
|
|
|
{ |
|
|
|
|
|
if (rightSide == null) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentNullException("rightSide"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (leftSide == null) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentNullException("leftSide"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (leftSide.Count != rightSide.Count) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "rightSide"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Control.LinearAlgebraProvider.DotProduct(leftSide.Data, rightSide.Data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Divides a vector with a scalar.
|
|
|
/// Divides a vector with a scalar.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|