diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
index 50be94b0..4869d296 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
@@ -706,6 +706,28 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return result;
}
+ ///
+ /// Multiplies a scalar to each element of the vector.
+ ///
+ /// The scalar to multiply.
+ /// A new vector that is the multiplication of the vector and the scalar.
+ public override Vector Multiply(Complex scalar)
+ {
+ if (scalar == Complex.One)
+ {
+ return Clone();
+ }
+
+ if (scalar == Complex.Zero)
+ {
+ return new SparseVector(Count);
+ }
+
+ var copy = new SparseVector(this);
+ Control.LinearAlgebraProvider.ScaleArray(scalar, copy._nonZeroValues, copy._nonZeroValues);
+ return copy;
+ }
+
///
/// Multiplies a scalar to each element of the vector and stores the result in the result vector.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
index 816d0119..80b6339b 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
@@ -736,6 +736,28 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return result;
}
+ ///
+ /// Multiplies a scalar to each element of the vector.
+ ///
+ /// The scalar to multiply.
+ /// A new vector that is the multiplication of the vector and the scalar.
+ public override Vector Multiply(Complex32 scalar)
+ {
+ if (scalar == Complex32.One)
+ {
+ return Clone();
+ }
+
+ if (scalar == Complex32.Zero)
+ {
+ return new SparseVector(Count);
+ }
+
+ var copy = new SparseVector(this);
+ Control.LinearAlgebraProvider.ScaleArray(scalar, copy._nonZeroValues, copy._nonZeroValues);
+ return copy;
+ }
+
///
/// Multiplies a scalar to each element of the vector and stores the result in the result vector.
///
diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
index 9526acaa..7b1c4e32 100644
--- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
@@ -688,6 +688,28 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return result;
}
+ ///
+ /// Multiplies a scalar to each element of the vector.
+ ///
+ /// The scalar to multiply.
+ /// A new vector that is the multiplication of the vector and the scalar.
+ public override Vector Multiply(float scalar)
+ {
+ if (scalar == 1.0f)
+ {
+ return Clone();
+ }
+
+ if (scalar == 0f)
+ {
+ return new SparseVector(Count);
+ }
+
+ var copy = new SparseVector(this);
+ Control.LinearAlgebraProvider.ScaleArray(scalar, copy._nonZeroValues, copy._nonZeroValues);
+ return copy;
+ }
+
///
/// Multiplies a scalar to each element of the vector and stores the result in the result vector.
///