Browse Source

Vector: used Parallel.ForEach where we could

Signed-off-by: Marcus Cuda <marcus@cuda.net>
la-knuth
Marcus Cuda 17 years ago
parent
commit
5c2efa6c86
  1. 18
      src/Numerics/LinearAlgebra/Double/Vector.cs

18
src/Numerics/LinearAlgebra/Double/Vector.cs

@ -334,7 +334,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double
public virtual Vector Negate() public virtual Vector Negate()
{ {
var result = CreateVector(Count); var result = CreateVector(Count);
Parallel.For(0, Count, i => result[i] = -this[i]);
Parallel.ForEach(GetIndexedEnumerator(), item => result[item.Key] = -item.Value);
return result; return result;
} }
@ -404,7 +406,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return; return;
} }
Parallel.For(0, Count, i => this[i] *= scalar); Parallel.ForEach(GetIndexedEnumerator(), item => this[item.Key] = scalar * item.Value);
} }
/// <summary> /// <summary>
@ -766,10 +768,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return; return;
} }
for (var index = 0; index < Count; index++) Parallel.ForEach(GetIndexedEnumerator(), item => target[item.Key] = item.Value);
{
target[index] = this[index];
}
} }
/// <summary> /// <summary>
@ -822,10 +821,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double
} }
else else
{ {
for (var index = 0; index < count; index++) Parallel.For(0, count,
{ index => destination[destinationOffset + index] = this[offset + index]
destination[destinationOffset + index] = this[offset + index]; );
}
} }
} }

Loading…
Cancel
Save