diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
index 0da08e7b..21e54b91 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
@@ -36,7 +36,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
using System.Numerics;
using Generic;
using NumberTheory;
- using Properties;
using Storage;
using Threading;
@@ -67,8 +66,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
_storage = storage;
}
- #region Constructors
-
///
/// Initializes a new instance of the class with a given size.
///
@@ -143,8 +140,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
- #endregion
-
///
/// Creates a matrix with the given dimensions using the same storage type
/// as this vector.
@@ -178,8 +173,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new SparseVector(size);
}
- #region Operators and supplementary functions
-
///
/// Conjugates vector and save result to
///
@@ -351,41 +344,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
- ///
- /// Returns a Vector containing the same values of .
- ///
- /// This method is included for completeness.
- /// The vector to get the values from.
- /// A vector containing a the same values as .
- /// If is .
- public static SparseVector operator +(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Plus();
- }
-
- ///
- /// Adds two Vectors together and returns the results.
- ///
- /// One of the vectors to add.
- /// The other vector to add.
- /// The result of the addition.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Add(rightSide);
- }
-
///
/// Subtracts a scalar from each element of the vector and stores the result in the result vector.
///
@@ -489,40 +447,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
- ///
- /// Returns a Vector containing the negated values of .
- ///
- /// The vector to get the values from.
- /// A vector containing the negated values as .
- /// If is .
- public static SparseVector operator -(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Negate();
- }
-
- ///
- /// Subtracts two Vectors and returns the results.
- ///
- /// The vector to subtract from.
- /// The vector to subtract.
- /// The result of the subtraction.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Subtract(rightSide);
- }
-
///
/// Returns a negated vector.
///
@@ -610,6 +534,75 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return result;
}
+ ///
+ /// Returns a Vector containing the same values of .
+ ///
+ /// This method is included for completeness.
+ /// The vector to get the values from.
+ /// A vector containing a the same values as .
+ /// If is .
+ public static SparseVector operator +(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Plus();
+ }
+
+ ///
+ /// Adds two Vectors together and returns the results.
+ ///
+ /// One of the vectors to add.
+ /// The other vector to add.
+ /// The result of the addition.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Add(rightSide);
+ }
+
+ ///
+ /// Returns a Vector containing the negated values of .
+ ///
+ /// The vector to get the values from.
+ /// A vector containing the negated values as .
+ /// If is .
+ public static SparseVector operator -(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Negate();
+ }
+
+ ///
+ /// Subtracts two Vectors and returns the results.
+ ///
+ /// The vector to subtract from.
+ /// The vector to subtract.
+ /// The result of the subtraction.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Subtract(rightSide);
+ }
+
///
/// Multiplies a vector with a complex.
///
@@ -679,6 +672,23 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return (SparseVector)leftSide.Divide(rightSide);
}
+ ///
+ /// Computes the modulus of each element of the vector of the given divisor.
+ ///
+ /// The vector whose elements we want to compute the modulus of.
+ /// The divisor to use,
+ /// The result of the calculation
+ /// If is .
+ public static SparseVector operator %(SparseVector leftSide, Complex rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Modulus(rightSide);
+ }
+
///
/// Returns the index of the absolute minimum element.
///
@@ -831,10 +841,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return OuterProduct(this, v);
}
- #endregion
-
- #region Vector Norms
-
///
/// Computes the p-Norm.
///
@@ -871,8 +877,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return Math.Pow(sum, 1.0 / p);
}
- #endregion
-
#region Parse Functions
///
@@ -1031,8 +1035,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
#endregion
- #region System.Object override
-
public override string ToString(string format, IFormatProvider formatProvider)
{
if (Count > 20)
@@ -1043,8 +1045,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return base.ToString(format, formatProvider);
}
- #endregion
-
///
/// Returns an that contains the position and value of the element.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
index 5dacdd32..8693d914 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
@@ -36,7 +36,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
using Generic;
using NumberTheory;
using Numerics;
- using Properties;
using Storage;
using Threading;
@@ -67,8 +66,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
_storage = storage;
}
- #region Constructors
-
///
/// Initializes a new instance of the class with a given size.
///
@@ -143,8 +140,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
- #endregion
-
///
/// Creates a matrix with the given dimensions using the same storage type
/// as this vector.
@@ -178,8 +173,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new SparseVector(size);
}
- #region Operators and supplementary functions
-
///
/// Conjugates vector and save result to
///
@@ -351,41 +344,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
- ///
- /// Returns a Vector containing the same values of .
- ///
- /// This method is included for completeness.
- /// The vector to get the values from.
- /// A vector containing a the same values as .
- /// If is .
- public static SparseVector operator +(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Plus();
- }
-
- ///
- /// Adds two Vectors together and returns the results.
- ///
- /// One of the vectors to add.
- /// The other vector to add.
- /// The result of the addition.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Add(rightSide);
- }
-
///
/// Subtracts a scalar from each element of the vector and stores the result in the result vector.
///
@@ -489,40 +447,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
- ///
- /// Returns a Vector containing the negated values of .
- ///
- /// The vector to get the values from.
- /// A vector containing the negated values as .
- /// If is .
- public static SparseVector operator -(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Negate();
- }
-
- ///
- /// Subtracts two Vectors and returns the results.
- ///
- /// The vector to subtract from.
- /// The vector to subtract.
- /// The result of the subtraction.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Subtract(rightSide);
- }
-
///
/// Returns a negated vector.
///
@@ -610,6 +534,75 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return result;
}
+ ///
+ /// Returns a Vector containing the same values of .
+ ///
+ /// This method is included for completeness.
+ /// The vector to get the values from.
+ /// A vector containing a the same values as .
+ /// If is .
+ public static SparseVector operator +(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Plus();
+ }
+
+ ///
+ /// Adds two Vectors together and returns the results.
+ ///
+ /// One of the vectors to add.
+ /// The other vector to add.
+ /// The result of the addition.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Add(rightSide);
+ }
+
+ ///
+ /// Returns a Vector containing the negated values of .
+ ///
+ /// The vector to get the values from.
+ /// A vector containing the negated values as .
+ /// If is .
+ public static SparseVector operator -(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Negate();
+ }
+
+ ///
+ /// Subtracts two Vectors and returns the results.
+ ///
+ /// The vector to subtract from.
+ /// The vector to subtract.
+ /// The result of the subtraction.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Subtract(rightSide);
+ }
+
///
/// Multiplies a vector with a complex.
///
@@ -679,6 +672,23 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return (SparseVector)leftSide.Divide(rightSide);
}
+ ///
+ /// Computes the modulus of each element of the vector of the given divisor.
+ ///
+ /// The vector whose elements we want to compute the modulus of.
+ /// The divisor to use,
+ /// The result of the calculation
+ /// If is .
+ public static SparseVector operator %(SparseVector leftSide, Complex32 rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Modulus(rightSide);
+ }
+
///
/// Returns the index of the absolute minimum element.
///
@@ -831,10 +841,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return OuterProduct(this, v);
}
- #endregion
-
- #region Vector Norms
-
///
/// Computes the p-Norm.
///
@@ -871,8 +877,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return (float)Math.Pow(sum, 1.0 / p);
}
- #endregion
-
#region Parse Functions
///
@@ -1031,8 +1035,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
#endregion
- #region System.Object override
-
public override string ToString(string format, IFormatProvider formatProvider)
{
if (Count > 20)
@@ -1043,8 +1045,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return base.ToString(format, formatProvider);
}
- #endregion
-
///
/// Returns an that contains the position and value of the element.
///
diff --git a/src/Numerics/LinearAlgebra/Double/SparseVector.cs b/src/Numerics/LinearAlgebra/Double/SparseVector.cs
index fea9f87b..8fb6b1ef 100644
--- a/src/Numerics/LinearAlgebra/Double/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Double/SparseVector.cs
@@ -36,7 +36,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
using System.Linq;
using Generic;
using NumberTheory;
- using Properties;
using Storage;
using Threading;
@@ -67,8 +66,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
_storage = storage;
}
- #region Constructors
-
///
/// Initializes a new instance of the class with a given size.
///
@@ -143,8 +140,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
- #endregion
-
///
/// Creates a matrix with the given dimensions using the same storage type
/// as this vector.
@@ -178,8 +173,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new SparseVector(size);
}
- #region Operators and supplementary functions
-
///
/// Adds a scalar to each element of the vector and stores the result in the result vector.
/// Warning, the new 'sparse vector' with a non-zero scalar added to it will be a 100% filled
@@ -319,41 +312,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
- ///
- /// Returns a Vector containing the same values of .
- ///
- /// This method is included for completeness.
- /// The vector to get the values from.
- /// A vector containing a the same values as .
- /// If is .
- public static SparseVector operator +(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Plus();
- }
-
- ///
- /// Adds two Vectors together and returns the results.
- ///
- /// One of the vectors to add.
- /// The other vector to add.
- /// The result of the addition.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Add(rightSide);
- }
-
///
/// Subtracts a scalar from each element of the vector and stores the result in the result vector.
///
@@ -457,40 +415,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
- ///
- /// Returns a Vector containing the negated values of .
- ///
- /// The vector to get the values from.
- /// A vector containing the negated values as .
- /// If is .
- public static SparseVector operator -(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Negate();
- }
-
- ///
- /// Subtracts two Vectors and returns the results.
- ///
- /// The vector to subtract from.
- /// The vector to subtract.
- /// The result of the subtraction.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Subtract(rightSide);
- }
-
///
/// Returns a negated vector.
///
@@ -578,6 +502,99 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return result;
}
+ ///
+ /// Computes the modulus for each element of the vector for the given divisor.
+ ///
+ /// The divisor to use.
+ /// A vector to store the results in.
+ protected override void DoModulus(double divisor, Vector result)
+ {
+ if (ReferenceEquals(this, result))
+ {
+ for (var index = 0; index < _storage.ValueCount; index++)
+ {
+ _storage.Values[index] %= divisor;
+ }
+ }
+ else
+ {
+ result.Clear();
+ for (var index = 0; index < _storage.ValueCount; index++)
+ {
+ result.At(_storage.Indices[index], _storage.Values[index] % divisor);
+ }
+ }
+ }
+
+ ///
+ /// Returns a Vector containing the same values of .
+ ///
+ /// This method is included for completeness.
+ /// The vector to get the values from.
+ /// A vector containing a the same values as .
+ /// If is .
+ public static SparseVector operator +(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Plus();
+ }
+
+ ///
+ /// Adds two Vectors together and returns the results.
+ ///
+ /// One of the vectors to add.
+ /// The other vector to add.
+ /// The result of the addition.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Add(rightSide);
+ }
+
+ ///
+ /// Returns a Vector containing the negated values of .
+ ///
+ /// The vector to get the values from.
+ /// A vector containing the negated values as .
+ /// If is .
+ public static SparseVector operator -(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Negate();
+ }
+
+ ///
+ /// Subtracts two Vectors and returns the results.
+ ///
+ /// The vector to subtract from.
+ /// The vector to subtract.
+ /// The result of the subtraction.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Subtract(rightSide);
+ }
+
///
/// Multiplies a vector with a scalar.
///
@@ -647,30 +664,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return (SparseVector)leftSide.Divide(rightSide);
}
- ///
- /// Computes the modulus for each element of the vector for the given divisor.
- ///
- /// The divisor to use.
- /// A vector to store the results in.
- protected override void DoModulus(double divisor, Vector result)
- {
- if (ReferenceEquals(this, result))
- {
- for (var index = 0; index < _storage.ValueCount; index++)
- {
- _storage.Values[index] %= divisor;
- }
- }
- else
- {
- result.Clear();
- for (var index = 0; index < _storage.ValueCount; index++)
- {
- result.At(_storage.Indices[index], _storage.Values[index] % divisor);
- }
- }
- }
-
///
/// Computes the modulus of each element of the vector of the given divisor.
///
@@ -887,10 +880,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return OuterProduct(this, v);
}
- #endregion
-
- #region Vector Norms
-
///
/// Computes the p-Norm.
///
@@ -927,8 +916,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return Math.Pow(sum, 1.0 / p);
}
- #endregion
-
#region Parse Functions
///
@@ -1088,8 +1075,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
#endregion
- #region System.Object override
-
public override string ToString(string format, IFormatProvider formatProvider)
{
if (Count > 20)
@@ -1100,8 +1085,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return base.ToString(format, formatProvider);
}
- #endregion
-
///
/// Returns an that contains the position and value of the element.
///
diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
index 16a8fb2c..28971f17 100644
--- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs
@@ -36,7 +36,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
using System.Linq;
using Generic;
using NumberTheory;
- using Properties;
using Storage;
using Threading;
@@ -67,8 +66,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
_storage = storage;
}
- #region Constructors
-
///
/// Initializes a new instance of the class with a given size.
///
@@ -143,8 +140,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
- #endregion
-
///
/// Creates a matrix with the given dimensions using the same storage type
/// as this vector.
@@ -178,8 +173,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return new SparseVector(size);
}
- #region Operators and supplementary functions
-
///
/// Adds a scalar to each element of the vector and stores the result in the result vector.
/// Warning, the new 'sparse vector' with a non-zero scalar added to it will be a 100% filled
@@ -320,41 +313,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
- ///
- /// Returns a Vector containing the same values of .
- ///
- /// This method is included for completeness.
- /// The vector to get the values from.
- /// A vector containing a the same values as .
- /// If is .
- public static SparseVector operator +(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Plus();
- }
-
- ///
- /// Adds two Vectors together and returns the results.
- ///
- /// One of the vectors to add.
- /// The other vector to add.
- /// The result of the addition.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Add(rightSide);
- }
-
///
/// Subtracts a scalar from each element of the vector and stores the result in the result vector.
///
@@ -458,40 +416,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
- ///
- /// Returns a Vector containing the negated values of .
- ///
- /// The vector to get the values from.
- /// A vector containing the negated values as .
- /// If is .
- public static SparseVector operator -(SparseVector rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return (SparseVector)rightSide.Negate();
- }
-
- ///
- /// Subtracts two Vectors and returns the results.
- ///
- /// The vector to subtract from.
- /// The vector to subtract.
- /// The result of the subtraction.
- /// If and are not the same size.
- /// If or is .
- public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return (SparseVector)leftSide.Subtract(rightSide);
- }
-
///
/// Returns a negated vector.
///
@@ -579,6 +503,99 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return result;
}
+ ///
+ /// Computes the modulus for each element of the vector for the given divisor.
+ ///
+ /// The divisor to use.
+ /// A vector to store the results in.
+ protected override void DoModulus(float divisor, Vector result)
+ {
+ if (ReferenceEquals(this, result))
+ {
+ for (var index = 0; index < _storage.ValueCount; index++)
+ {
+ _storage.Values[index] %= divisor;
+ }
+ }
+ else
+ {
+ result.Clear();
+ for (var index = 0; index < _storage.ValueCount; index++)
+ {
+ result.At(_storage.Indices[index], _storage.Values[index] % divisor);
+ }
+ }
+ }
+
+ ///
+ /// Returns a Vector containing the same values of .
+ ///
+ /// This method is included for completeness.
+ /// The vector to get the values from.
+ /// A vector containing a the same values as .
+ /// If is .
+ public static SparseVector operator +(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Plus();
+ }
+
+ ///
+ /// Adds two Vectors together and returns the results.
+ ///
+ /// One of the vectors to add.
+ /// The other vector to add.
+ /// The result of the addition.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator +(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Add(rightSide);
+ }
+
+ ///
+ /// Returns a Vector containing the negated values of .
+ ///
+ /// The vector to get the values from.
+ /// A vector containing the negated values as .
+ /// If is .
+ public static SparseVector operator -(SparseVector rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return (SparseVector)rightSide.Negate();
+ }
+
+ ///
+ /// Subtracts two Vectors and returns the results.
+ ///
+ /// The vector to subtract from.
+ /// The vector to subtract.
+ /// The result of the subtraction.
+ /// If and are not the same size.
+ /// If or is .
+ public static SparseVector operator -(SparseVector leftSide, SparseVector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return (SparseVector)leftSide.Subtract(rightSide);
+ }
+
///
/// Multiplies a vector with a scalar.
///
@@ -648,30 +665,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return (SparseVector)leftSide.Divide(rightSide);
}
- ///
- /// Computes the modulus for each element of the vector for the given divisor.
- ///
- /// The divisor to use.
- /// A vector to store the results in.
- protected override void DoModulus(float divisor, Vector result)
- {
- if (ReferenceEquals(this, result))
- {
- for (var index = 0; index < _storage.ValueCount; index++)
- {
- _storage.Values[index] %= divisor;
- }
- }
- else
- {
- result.Clear();
- for (var index = 0; index < _storage.ValueCount; index++)
- {
- result.At(_storage.Indices[index], _storage.Values[index] % divisor);
- }
- }
- }
-
///
/// Computes the modulus of each element of the vector of the given divisor.
///
@@ -891,10 +884,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return OuterProduct(this, v);
}
- #endregion
-
- #region Vector Norms
-
///
/// Computes the p-Norm.
///
@@ -931,8 +920,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return (float)Math.Pow(sum, 1.0 / p);
}
- #endregion
-
#region Parse Functions
///
@@ -1092,8 +1079,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
#endregion
- #region System.Object override
-
public override string ToString(string format, IFormatProvider formatProvider)
{
if (Count > 20)
@@ -1104,8 +1089,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return base.ToString(format, formatProvider);
}
- #endregion
-
///
/// Returns an that contains the position and value of the element.
///