|
|
|
@ -65,11 +65,31 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
} |
|
|
|
else if (alpha == 1.0) |
|
|
|
{ |
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => result[index] = y[index] + x[index]); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = y[index] + x[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => result[index] = y[index] + x[index]); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => result[index] = y[index] + (alpha * x[index])); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = y[index] + (alpha * x[index]); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => result[index] = y[index] + (alpha * x[index])); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -97,7 +117,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.ElementFor(0, x.Length, x.Length, index => { result[index] = alpha * x[index]; }); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = alpha * x[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, x.Length, index => { result[index] = alpha * x[index]; }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -167,7 +197,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength); |
|
|
|
} |
|
|
|
|
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => { result[index] = x[index] + y[index]; }); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = x[index] + y[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => { result[index] = x[index] + y[index]; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -202,7 +242,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength); |
|
|
|
} |
|
|
|
|
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => { result[index] = x[index] - y[index]; }); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = x[index] - y[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => { result[index] = x[index] - y[index]; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -237,7 +287,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength); |
|
|
|
} |
|
|
|
|
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => { result[index] = x[index] * y[index]; }); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = x[index] * y[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => { result[index] = x[index] * y[index]; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -272,7 +332,17 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
throw new ArgumentException(Resources.ArgumentVectorsSameLength); |
|
|
|
} |
|
|
|
|
|
|
|
CommonParallel.ElementFor(0, y.Length, y.Length, index => { result[index] = x[index] / y[index]; }); |
|
|
|
if (x.Length < Control.ParallelizeElements || Control.DisableParallelization) |
|
|
|
{ |
|
|
|
for (var index = 0; index < x.Length; index++) |
|
|
|
{ |
|
|
|
result[index] = x[index] / y[index]; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
CommonParallel.For(0, y.Length, index => { result[index] = x[index] / y[index]; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1119,7 +1189,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
{ |
|
|
|
var tmpColCount = colLimit - firstCol; |
|
|
|
|
|
|
|
if ((availableCores > 1) && (tmpColCount > 200)) |
|
|
|
if ((availableCores > 1) && (tmpColCount > Control.ParallelizeElements)) |
|
|
|
{ |
|
|
|
var tmpSplit = firstCol + (tmpColCount / 3); |
|
|
|
var tmpCores = availableCores / 2; |
|
|
|
@ -1207,6 +1277,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra |
|
|
|
throw new ArgumentException(Resources.ArgumentReferenceDifferent); |
|
|
|
} |
|
|
|
|
|
|
|
if( ) |
|
|
|
CommonParallel.For( |
|
|
|
0, |
|
|
|
columnsB, |
|
|
|
|