|
|
|
@ -1320,22 +1320,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 |
|
|
|
// Item already exist at itemIndex
|
|
|
|
if (value == Complex32.Zero) |
|
|
|
{ |
|
|
|
// Value is zero. Let's delete it from Values and Indices array
|
|
|
|
for (var i = itemIndex + 1; i < NonZerosCount; i++) |
|
|
|
{ |
|
|
|
_nonZeroValues[i - 1] = _nonZeroValues[i]; |
|
|
|
_nonZeroIndices[i - 1] = _nonZeroIndices[i]; |
|
|
|
} |
|
|
|
|
|
|
|
NonZerosCount -= 1; |
|
|
|
|
|
|
|
// Check if the storage needs to be shrink. This is reasonable to do if
|
|
|
|
// there are a lot of non-zero elements and storage is two times bigger
|
|
|
|
if ((NonZerosCount > 1024) && (NonZerosCount < _nonZeroIndices.Length / 2)) |
|
|
|
{ |
|
|
|
Array.Resize(ref _nonZeroValues, NonZerosCount); |
|
|
|
Array.Resize(ref _nonZeroIndices, NonZerosCount); |
|
|
|
} |
|
|
|
RemoveAtUnchecked(itemIndex); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
@ -1380,6 +1365,26 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 |
|
|
|
NonZerosCount += 1; |
|
|
|
} |
|
|
|
|
|
|
|
private void RemoveAtUnchecked(int itemIndex) |
|
|
|
{ |
|
|
|
// Value is zero. Let's delete it from Values and Indices array
|
|
|
|
for (var i = itemIndex + 1; i < NonZerosCount; i++) |
|
|
|
{ |
|
|
|
_nonZeroValues[i - 1] = _nonZeroValues[i]; |
|
|
|
_nonZeroIndices[i - 1] = _nonZeroIndices[i]; |
|
|
|
} |
|
|
|
|
|
|
|
NonZerosCount -= 1; |
|
|
|
|
|
|
|
// Check if the storage needs to be shrink. This is reasonable to do if
|
|
|
|
// there are a lot of non-zero elements and storage is two times bigger
|
|
|
|
if ((NonZerosCount > 1024) && (NonZerosCount < _nonZeroIndices.Length / 2)) |
|
|
|
{ |
|
|
|
Array.Resize(ref _nonZeroValues, NonZerosCount); |
|
|
|
Array.Resize(ref _nonZeroIndices, NonZerosCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Calculates the amount with which to grow the storage array's if they need to be
|
|
|
|
/// increased in size.
|
|
|
|
|