From b4a0cc97ed69fdc4431c466600b89a903286c864 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 5 Apr 2013 00:08:14 +0200 Subject: [PATCH] LA Perf: replace parallel copy loops with native copy II --- .../ManagedLinearAlgebraProvider.Complex.cs | 14 ++++---------- .../ManagedLinearAlgebraProvider.Complex32.cs | 14 ++++---------- .../ManagedLinearAlgebraProvider.Double.cs | 14 ++++---------- .../ManagedLinearAlgebraProvider.Single.cs | 14 ++++---------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs index 2beb3952..1e254853 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs @@ -2100,16 +2100,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra } // Fill result matrix - CommonParallel.For(0, columnsR, (u, v) => - { - for (int row = u; row < v; row++) - { - for (var col = 0; col < columnsB; col++) - { - x[(col*columnsA) + row] = sol[row + (col*rowsA)]; - } - } - }); + for (var col = 0; col < columnsB; col++) + { + Array.Copy(sol, col * rowsA, x, col * columnsA, columnsR); + } } /// diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs index 9add9980..06421f48 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs @@ -2097,16 +2097,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra } // Fill result matrix - CommonParallel.For(0, columnsR, (u, v) => - { - for (int row = u; row < v; row++) - { - for (var col = 0; col < columnsB; col++) - { - x[(col*columnsA) + row] = sol[row + (col*rowsA)]; - } - } - }); + for (var col = 0; col < columnsB; col++) + { + Array.Copy(sol, col * rowsA, x, col * columnsA, columnsR); + } } /// diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs index b18e700f..5f8c9b01 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs @@ -1985,16 +1985,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra } // Fill result matrix - CommonParallel.For(0, columnsR, (u, v) => - { - for (int row = u; row < v; row++) - { - for (var col = 0; col < columnsB; col++) - { - x[(col*columnsA) + row] = sol[row + (col*rowsA)]; - } - } - }); + for (var col = 0; col < columnsB; col++) + { + Array.Copy(sol, col*rowsA, x, col*columnsA, columnsR); + } } /// diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs index 0e32efa7..46402b52 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs @@ -1987,16 +1987,10 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra } // Fill result matrix - CommonParallel.For(0, columnsR, (u, v) => - { - for (int row = u; row < v; row++) - { - for (var col = 0; col < columnsB; col++) - { - x[(col*columnsA) + row] = sol[row + (col*rowsA)]; - } - } - }); + for (var col = 0; col < columnsB; col++) + { + Array.Copy(sol, col * rowsA, x, col * columnsA, columnsR); + } } ///