diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
index cba3033c..76bdeba8 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs
@@ -208,50 +208,39 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new SparseVector(size);
}
+ #region Operators and supplementary functions
+
///
/// Conjugates vector and save result to
///
/// Target vector
- public override void Conjugate(Vector target)
+ protected override void DoConjugate(Vector target)
{
- if (target == null)
- {
- throw new ArgumentNullException("target");
- }
-
- if (Count != target.Count)
- {
- throw new ArgumentException(Resources.ArgumentVectorsSameLength, "target");
- }
-
if (ReferenceEquals(this, target))
{
var tmp = CreateVector(Count);
- Conjugate(tmp);
+ DoConjugate(tmp);
tmp.CopyTo(target);
}
- var otherVector = target as SparseVector;
- if (otherVector == null)
+ var targetSparse = target as SparseVector;
+ if (targetSparse == null)
{
base.Conjugate(target);
+ return;
}
- else
- {
- // Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
- otherVector._storage.Values = new Complex[_storage.ValueCount];
- otherVector._storage.Indices = new int[_storage.ValueCount];
- otherVector._storage.ValueCount = _storage.ValueCount;
- if (_storage.ValueCount != 0)
- {
- CommonParallel.For(0, _storage.ValueCount, index => otherVector._storage.Values[index] = _storage.Values[index].Conjugate());
- Buffer.BlockCopy(_storage.Indices, 0, otherVector._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
- }
+ // Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
+ targetSparse._storage.Values = new Complex[_storage.ValueCount];
+ targetSparse._storage.Indices = new int[_storage.ValueCount];
+ targetSparse._storage.ValueCount = _storage.ValueCount;
+
+ if (_storage.ValueCount != 0)
+ {
+ CommonParallel.For(0, _storage.ValueCount, index => targetSparse._storage.Values[index] = _storage.Values[index].Conjugate());
+ Buffer.BlockCopy(_storage.Indices, 0, targetSparse._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
}
}
-
- #region Operators and supplementary functions
///
/// Adds 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 783389f4..ef9d6139 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs
@@ -208,50 +208,39 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new SparseVector(size);
}
+ #region Operators and supplementary functions
+
///
/// Conjugates vector and save result to
///
/// Target vector
- public override void Conjugate(Vector target)
+ protected override void DoConjugate(Vector target)
{
- if (target == null)
- {
- throw new ArgumentNullException("target");
- }
-
- if (Count != target.Count)
- {
- throw new ArgumentException(Resources.ArgumentVectorsSameLength, "target");
- }
-
if (ReferenceEquals(this, target))
{
var tmp = CreateVector(Count);
- Conjugate(tmp);
+ DoConjugate(tmp);
tmp.CopyTo(target);
}
- var otherVector = target as SparseVector;
- if (otherVector == null)
+ var targetSparse = target as SparseVector;
+ if (targetSparse == null)
{
base.Conjugate(target);
+ return;
}
- else
- {
- // Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
- otherVector._storage.Values = new Complex32[_storage.ValueCount];
- otherVector._storage.Indices = new int[_storage.ValueCount];
- otherVector._storage.ValueCount = _storage.ValueCount;
- if (_storage.ValueCount != 0)
- {
- CommonParallel.For(0, _storage.ValueCount, index => otherVector._storage.Values[index] = _storage.Values[index].Conjugate());
- Buffer.BlockCopy(_storage.Indices, 0, otherVector._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
- }
+ // Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
+ targetSparse._storage.Values = new Complex32[_storage.ValueCount];
+ targetSparse._storage.Indices = new int[_storage.ValueCount];
+ targetSparse._storage.ValueCount = _storage.ValueCount;
+
+ if (_storage.ValueCount != 0)
+ {
+ CommonParallel.For(0, _storage.ValueCount, index => targetSparse._storage.Values[index] = _storage.Values[index].Conjugate());
+ Buffer.BlockCopy(_storage.Indices, 0, targetSparse._storage.Indices, 0, _storage.ValueCount * Constants.SizeOfInt);
}
}
-
- #region Operators and supplementary functions
///
/// Adds a scalar to each element of the vector and stores the result in the result vector.
diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs
index f97c041c..73dfa7cb 100644
--- a/src/Numerics/LinearAlgebra/Generic/Vector.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs
@@ -1246,7 +1246,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Conjugates vector and save result to
///
/// Target vector
- public virtual void Conjugate(Vector target)
+ public void Conjugate(Vector target)
{
if (target == null)
{