From dc92821e4dbaafdd88ebde6b3fbff283b81cde08 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sat, 6 Sep 2014 15:50:16 +0200 Subject: [PATCH] Providers: generic access to allow fully generic operators --- src/Numerics/Control.cs | 6 ++++++ src/Numerics/LinearAlgebra/Complex/Vector.cs | 14 -------------- src/Numerics/LinearAlgebra/Complex32/Vector.cs | 14 -------------- src/Numerics/LinearAlgebra/Double/Vector.cs | 14 -------------- src/Numerics/LinearAlgebra/Single/Vector.cs | 14 -------------- src/Numerics/LinearAlgebra/Vector.Arithmetic.cs | 5 ++++- 6 files changed, 10 insertions(+), 57 deletions(-) diff --git a/src/Numerics/Control.cs b/src/Numerics/Control.cs index 66db2b19..529bbaae 100644 --- a/src/Numerics/Control.cs +++ b/src/Numerics/Control.cs @@ -178,6 +178,12 @@ namespace MathNet.Numerics } } + internal static IExperimentalLinearAlgebraProvider ExperimentalLinearAlgebraProviderFor() + where T : struct, IEquatable, IFormattable + { + return (IExperimentalLinearAlgebraProvider)_experimentalLinearAlgebraProvider; + } + /// /// Gets or sets a value indicating how many parallel worker threads shall be used /// when parallelization is applicable. diff --git a/src/Numerics/LinearAlgebra/Complex/Vector.cs b/src/Numerics/LinearAlgebra/Complex/Vector.cs index ca9fe7c7..60fc56c4 100644 --- a/src/Numerics/LinearAlgebra/Complex/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex/Vector.cs @@ -80,20 +80,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } } - /// - /// Adds another vector to this vector and stores the result into the result vector. - /// - /// - /// The vector to add to this one. - /// - /// - /// The vector to store the result of the addition. - /// - protected override sealed void DoAdd(Vector other, Vector result) - { - Control.ExperimentalLinearAlgebraProvider.AddVectors(Storage, other.Storage, result.Storage); - } - /// /// Subtracts a scalar from each element of the vector and stores the result in the result vector. /// diff --git a/src/Numerics/LinearAlgebra/Complex32/Vector.cs b/src/Numerics/LinearAlgebra/Complex32/Vector.cs index d302151f..18bdf106 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Vector.cs @@ -75,20 +75,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } } - /// - /// Adds another vector to this vector and stores the result into the result vector. - /// - /// - /// The vector to add to this one. - /// - /// - /// The vector to store the result of the addition. - /// - protected override sealed void DoAdd(Vector other, Vector result) - { - Control.ExperimentalLinearAlgebraProvider.AddVectors(Storage, other.Storage, result.Storage); - } - /// /// Subtracts a scalar from each element of the vector and stores the result in the result vector. /// diff --git a/src/Numerics/LinearAlgebra/Double/Vector.cs b/src/Numerics/LinearAlgebra/Double/Vector.cs index ebfa29c9..77a8ed76 100644 --- a/src/Numerics/LinearAlgebra/Double/Vector.cs +++ b/src/Numerics/LinearAlgebra/Double/Vector.cs @@ -73,20 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } - /// - /// Adds another vector to this vector and stores the result into the result vector. - /// - /// - /// The vector to add to this one. - /// - /// - /// The vector to store the result of the addition. - /// - protected override sealed void DoAdd(Vector other, Vector result) - { - Control.ExperimentalLinearAlgebraProvider.AddVectors(Storage, other.Storage, result.Storage); - } - /// /// Subtracts a scalar from each element of the vector and stores the result in the result vector. /// diff --git a/src/Numerics/LinearAlgebra/Single/Vector.cs b/src/Numerics/LinearAlgebra/Single/Vector.cs index ec79e7c4..3c23f94b 100644 --- a/src/Numerics/LinearAlgebra/Single/Vector.cs +++ b/src/Numerics/LinearAlgebra/Single/Vector.cs @@ -73,20 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single } } - /// - /// Adds another vector to this vector and stores the result into the result vector. - /// - /// - /// The vector to add to this one. - /// - /// - /// The vector to store the result of the addition. - /// - protected override sealed void DoAdd(Vector other, Vector result) - { - Control.ExperimentalLinearAlgebraProvider.AddVectors(Storage, other.Storage, result.Storage); - } - /// /// Subtracts a scalar from each element of the vector and stores the result in the result vector. /// diff --git a/src/Numerics/LinearAlgebra/Vector.Arithmetic.cs b/src/Numerics/LinearAlgebra/Vector.Arithmetic.cs index 87d44e6a..115482f5 100644 --- a/src/Numerics/LinearAlgebra/Vector.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Vector.Arithmetic.cs @@ -69,7 +69,10 @@ namespace MathNet.Numerics.LinearAlgebra /// /// The vector to add to this one. /// The vector to store the result of the addition. - protected abstract void DoAdd(Vector other, Vector result); + void DoAdd(Vector other, Vector result) + { + Control.ExperimentalLinearAlgebraProviderFor().AddVectors(Storage, other.Storage, result.Storage); + } /// /// Subtracts a scalar from each element of the vector and stores the result in the result vector.