diff --git a/src/Numerics/LinearAlgebra/Complex/Vector.cs b/src/Numerics/LinearAlgebra/Complex/Vector.cs
index b32957c9..39514064 100644
--- a/src/Numerics/LinearAlgebra/Complex/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/Vector.cs
@@ -146,6 +146,19 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
DoMultiply(1 / scalar, result);
}
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ protected override void DoDivideByThis(Complex scalar, Vector result)
+ {
+ for (var index = 0; index < Count; index++)
+ {
+ result.At(index, scalar / At(index));
+ }
+ }
+
///
/// Pointwise multiplies this vector with another vector and stores the result into the result vector.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/Vector.cs b/src/Numerics/LinearAlgebra/Complex32/Vector.cs
index 60a3ffc3..93aece30 100644
--- a/src/Numerics/LinearAlgebra/Complex32/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/Vector.cs
@@ -146,6 +146,19 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
DoMultiply(1 / scalar, result);
}
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ protected override void DoDivideByThis(Complex32 scalar, Vector result)
+ {
+ for (var index = 0; index < Count; index++)
+ {
+ result.At(index, scalar / At(index));
+ }
+ }
+
///
/// Pointwise multiplies this vector with another vector and stores the result into the result vector.
///
diff --git a/src/Numerics/LinearAlgebra/Double/Vector.cs b/src/Numerics/LinearAlgebra/Double/Vector.cs
index 26510d32..f6427777 100644
--- a/src/Numerics/LinearAlgebra/Double/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Double/Vector.cs
@@ -145,6 +145,19 @@ namespace MathNet.Numerics.LinearAlgebra.Double
DoMultiply(1 / scalar, result);
}
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ protected override void DoDivideByThis(double scalar, Vector result)
+ {
+ for (var index = 0; index < Count; index++)
+ {
+ result.At(index, scalar / At(index));
+ }
+ }
+
///
/// Pointwise multiplies this vector with another vector and stores the result into the result vector.
///
diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs
index 2081d49f..b62b0c4e 100644
--- a/src/Numerics/LinearAlgebra/Generic/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs
@@ -230,6 +230,13 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// The vector to store the result of the division.
protected abstract void DoDivide(T scalar, Vector result);
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ protected abstract void DoDivideByThis(T scalar, Vector result);
+
///
/// Computes the modulus for each element of the vector for the given divisor.
///
@@ -668,6 +675,40 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
DoDivide(scalar, result);
}
+ ///
+ /// Divides a scalar by each element of the vector.
+ ///
+ /// The scalar to divide.
+ /// A new vector that is the division of the vector and the scalar.
+ public Vector DevideByThis(T scalar)
+ {
+ var result = CreateVector(Count);
+ DoDivideByThis(scalar, result);
+ return result;
+ }
+
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ /// If the result vector is .
+ /// If this vector and are not the same size.
+ public void DivideByThis(T scalar, Vector result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException("result");
+ }
+
+ if (Count != result.Count)
+ {
+ throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
+ }
+
+ DoDivideByThis(scalar, result);
+ }
+
///
/// Computes the modulus for each element of the vector for the given divisor.
///
@@ -1048,6 +1089,23 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return leftSide.DotProduct(rightSide);
}
+ ///
+ /// Divides a scalar with a vector.
+ ///
+ /// The scalar to divide.
+ /// The vector.
+ /// The result of the division.
+ /// If is .
+ public static Vector operator /(T leftSide, Vector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return rightSide.DevideByThis(leftSide);
+ }
+
///
/// Divides a vector with a scalar.
///
@@ -1065,6 +1123,24 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return leftSide.Divide(rightSide);
}
+ ///
+ /// Pointwise divides two Vectors.
+ ///
+ /// The vector to divide.
+ /// The other vector.
+ /// The result of the division.
+ /// If and are not the same size.
+ /// If is .
+ public static Vector operator /(Vector leftSide, Vector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.PointwiseDivide(rightSide);
+ }
+
///
/// Computes the modulus of each element of the vector of the given divisor.
///
diff --git a/src/Numerics/LinearAlgebra/Single/Vector.cs b/src/Numerics/LinearAlgebra/Single/Vector.cs
index ed86d2f2..9996a41e 100644
--- a/src/Numerics/LinearAlgebra/Single/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Single/Vector.cs
@@ -145,6 +145,19 @@ namespace MathNet.Numerics.LinearAlgebra.Single
DoMultiply(1 / scalar, result);
}
+ ///
+ /// Divides a scalar by each element of the vector and stores the result in the result vector.
+ ///
+ /// The scalar to divide.
+ /// The vector to store the result of the division.
+ protected override void DoDivideByThis(float scalar, Vector result)
+ {
+ for (var index = 0; index < Count; index++)
+ {
+ result.At(index, scalar / At(index));
+ }
+ }
+
///
/// Pointwise multiplies this vector with another vector and stores the result into the result vector.
///