|
|
|
@ -244,87 +244,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds a complex to each element of the vector.
|
|
|
|
/// Adds a scalar to each element of the vector and stores the result in the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="complex">The complex to add.</param>
|
|
|
|
/// <returns>A copy of the vector with the complex added.</returns>
|
|
|
|
public override Vector<Complex> Add(Complex complex) |
|
|
|
{ |
|
|
|
if (complex == Complex.Zero) |
|
|
|
{ |
|
|
|
return Clone(); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = (DenseVector)Clone(); |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => copy.Data[index] += complex); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds a complex to each element of the vector and stores the result in the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="complex">The complex to add.</param>
|
|
|
|
/// <param name="scalar">The scalar to add.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the addition.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void Add(Complex complex, Vector<Complex> result) |
|
|
|
protected override void DoAdd(Complex scalar, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
base.Add(complex, result); |
|
|
|
base.DoAdd(scalar, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] + complex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds another vector to this vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to add to this one.</param>
|
|
|
|
/// <returns>A new vector containing the sum of both vectors.</returns>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
public override Vector<Complex> Add(Vector<Complex> other) |
|
|
|
{ |
|
|
|
if (other == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("other"); |
|
|
|
index => dense.Data[index] = Data[index] + scalar); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
} |
|
|
|
|
|
|
|
var denseVector = other as DenseVector; |
|
|
|
|
|
|
|
if (denseVector == null) |
|
|
|
{ |
|
|
|
return base.Add(other); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = new DenseVector(Count); |
|
|
|
Control.LinearAlgebraProvider.AddVectorToScaledVector(Data, Complex.One, denseVector.Data, copy.Data); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -332,27 +269,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to add to this one.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the addition.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void Add(Vector<Complex> other, Vector<Complex> result) |
|
|
|
protected override void DoAdd(Vector<Complex> other, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
var rdense = result as DenseVector; |
|
|
|
var odense = other as DenseVector; |
|
|
|
if (rdense != null && odense != null) |
|
|
|
@ -361,10 +279,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => result[index] = Data[index] + other[index]); |
|
|
|
base.DoAdd(other, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -414,127 +329,42 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Subtracts a complex from each element of the vector.
|
|
|
|
/// Subtracts a scalar from each element of the vector and stores the result in the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="complex">The complex to subtract.</param>
|
|
|
|
/// <returns>A new vector containing the subtraction of this vector and the complex.</returns>
|
|
|
|
public override Vector<Complex> Subtract(Complex complex) |
|
|
|
{ |
|
|
|
if (complex == Complex.Zero) |
|
|
|
{ |
|
|
|
return Clone(); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = (DenseVector)Clone(); |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => copy.Data[index] -= complex); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Subtracts a complex from each element of the vector and stores the result in the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="complex">The complex to subtract.</param>
|
|
|
|
/// <param name="scalar">The scalar to subtract.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the subtraction.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void Subtract(Complex complex, Vector<Complex> result) |
|
|
|
protected override void DoSubtract(Complex scalar, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
base.Subtract(complex, result); |
|
|
|
base.DoSubtract(scalar, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] - complex); |
|
|
|
index => dense.Data[index] = Data[index] - scalar); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Subtracts another vector from this vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to subtract from this one.</param>
|
|
|
|
/// <returns>A new vector containing the subtraction of the the two vectors.</returns>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
public override Vector<Complex> Subtract(Vector<Complex> 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.Subtract(other); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = new DenseVector(Count); |
|
|
|
Control.LinearAlgebraProvider.AddVectorToScaledVector(Data, -Complex.One, denseVector.Data, copy.Data); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Subtracts another vector to this vector and stores the result into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to subtract from this one.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the subtraction.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void Subtract(Vector<Complex> other, Vector<Complex> result) |
|
|
|
protected override void DoSubtract(Vector<Complex> other, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
var rdense = result as DenseVector; |
|
|
|
var odense = other as DenseVector; |
|
|
|
if (rdense != null && odense != null) |
|
|
|
{ |
|
|
|
Control.LinearAlgebraProvider.AddVectorToScaledVector(Data, -Complex.One, odense.Data, rdense.Data); |
|
|
|
Control.LinearAlgebraProvider.AddVectorToScaledVector(Data, -1.0, odense.Data, rdense.Data); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => result[index] = Data[index] - other[index]); |
|
|
|
base.DoSubtract(other, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -599,49 +429,35 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies a complex to each element of the vector.
|
|
|
|
/// Multiplies a scalar to each element of the vector and stores the result in the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="complex">The complex to multiply.</param>
|
|
|
|
/// <returns>A new vector that is the multiplication of the vector and the complex.</returns>
|
|
|
|
public override Vector<Complex> Multiply(Complex complex) |
|
|
|
/// <param name="scalar">The scalar to multiply.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the multiplication.</param>
|
|
|
|
/// <remarks></remarks>
|
|
|
|
protected override void DoMultiply(Complex scalar, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (complex == Complex.One) |
|
|
|
var denseResult = result as DenseVector; |
|
|
|
if (denseResult == null) |
|
|
|
{ |
|
|
|
return Clone(); |
|
|
|
base.DoMultiply(scalar, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Control.LinearAlgebraProvider.ScaleArray(scalar, Data, denseResult.Data); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = new DenseVector(Count); |
|
|
|
Control.LinearAlgebraProvider.ScaleArray(complex, Data, copy.Data); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <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 Complex DotProduct(Vector<Complex> other) |
|
|
|
/// <returns>s
|
|
|
|
/// The result of the addition.</returns>
|
|
|
|
protected override Complex DoDotProduct(Vector<Complex> 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); |
|
|
|
} |
|
|
|
|
|
|
|
return Control.LinearAlgebraProvider.DotProduct(Data, denseVector.Data); |
|
|
|
return denseVector == null ? base.DoDotProduct(other) : Control.LinearAlgebraProvider.DotProduct(Data, denseVector.Data); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -877,124 +693,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this vector with another vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to pointwise multiply with this one.</param>
|
|
|
|
/// <returns>A new vector which is the pointwise multiplication of the two vectors.</returns>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
public override Vector<Complex> PointwiseMultiply(Vector<Complex> 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.PointwiseMultiply(other); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = (DenseVector)Clone(); |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Count, |
|
|
|
index => copy[index] *= other[index]); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this vector with another vector and stores the result into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to pointwise multiply with this one.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the pointwise multiplication.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void PointwiseMultiply(Vector<Complex> other, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (other == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReferenceEquals(this, result) || ReferenceEquals(other, result)) |
|
|
|
{ |
|
|
|
var tmp = PointwiseMultiply(other); |
|
|
|
tmp.CopyTo(result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
base.PointwiseMultiply(other, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] * other[index]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise divide this vector with another vector.
|
|
|
|
/// Pointwise divide this vector with another vector and stores the result into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to pointwise divide this one by.</param>
|
|
|
|
/// <returns>A new vector which is the pointwise division of the two vectors.</returns>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
public override Vector<Complex> PointwiseDivide(Vector<Complex> other) |
|
|
|
/// <param name="result">The vector to store the result of the pointwise division.</param>
|
|
|
|
protected override void DoPointwiseMultiply(Vector<Complex> other, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (other == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
base.DoPointwiseMultiply(other, result); |
|
|
|
} |
|
|
|
|
|
|
|
var denseVector = other as DenseVector; |
|
|
|
|
|
|
|
if (denseVector == null) |
|
|
|
else |
|
|
|
{ |
|
|
|
return base.PointwiseMultiply(other); |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] * other[index]); |
|
|
|
} |
|
|
|
|
|
|
|
var copy = (DenseVector)Clone(); |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Count, |
|
|
|
index => copy[index] /= other[index]); |
|
|
|
return copy; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1002,51 +718,20 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The vector to pointwise divide this one by.</param>
|
|
|
|
/// <param name="result">The vector to store the result of the pointwise division.</param>
|
|
|
|
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
|
|
|
|
public override void PointwiseDivide(Vector<Complex> other, Vector<Complex> result) |
|
|
|
/// <remarks></remarks>
|
|
|
|
protected override void DoPointwiseDivide(Vector<Complex> other, Vector<Complex> result) |
|
|
|
{ |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (other == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException("other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != other.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other"); |
|
|
|
} |
|
|
|
|
|
|
|
if (Count != result.Count) |
|
|
|
{ |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReferenceEquals(this, result) || ReferenceEquals(other, result)) |
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
var tmp = PointwiseDivide(other); |
|
|
|
tmp.CopyTo(result); |
|
|
|
base.DoPointwiseDivide(other, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var dense = result as DenseVector; |
|
|
|
if (dense == null) |
|
|
|
{ |
|
|
|
base.PointwiseDivide(other, result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] / other[index]); |
|
|
|
} |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Data.Length, |
|
|
|
index => dense.Data[index] = Data[index] / other[index]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1309,39 +994,22 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
/// Conjugates vector and save result to <paramref name="target"/>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="target">Target vector</param>
|
|
|
|
public override void Conjugate(Vector<Complex> target) |
|
|
|
protected override void DoConjugate(Vector<Complex> 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); |
|
|
|
tmp.CopyTo(target); |
|
|
|
} |
|
|
|
var denseTarget = target as DenseVector; |
|
|
|
|
|
|
|
var otherVector = target as DenseVector; |
|
|
|
if (otherVector == null) |
|
|
|
if (denseTarget == null) |
|
|
|
{ |
|
|
|
base.Conjugate(target); |
|
|
|
base.DoConjugate(target); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
Count, |
|
|
|
index => otherVector.Data[index] = Data[index].Conjugate()); |
|
|
|
index => denseTarget.Data[index] = Data[index].Conjugate()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>Gets the value at the given <paramref name="index"/>.</summary>
|
|
|
|
/// <param name="index">The index of the value to get or set.</param>
|
|
|
|
/// <returns>The value of the vector at the given <paramref name="index"/>.</returns>
|
|
|
|
|