Browse Source

Providers: Experimental Linear Algebra Provider

provider
Christoph Ruegg 12 years ago
parent
commit
46d5ceb188
  1. 18
      src/Numerics/Control.cs
  2. 6
      src/Numerics/Numerics.csproj
  3. 60
      src/Numerics/Providers/ExperimentalLinearAlgebra/IExperimentalLinearAlgebraProvider.cs
  4. 48
      src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Complex.cs
  5. 43
      src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Complex32.cs
  6. 43
      src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Double.cs
  7. 43
      src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Single.cs
  8. 20
      src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.cs

18
src/Numerics/Control.cs

@ -28,6 +28,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.Providers.ExperimentalLinearAlgebra;
using MathNet.Numerics.Providers.LinearAlgebra;
using System;
using System.Threading.Tasks;
@ -44,6 +45,7 @@ namespace MathNet.Numerics
static int _parallelizeOrder;
static int _parallelizeElements;
static ILinearAlgebraProvider _linearAlgebraProvider;
static IExperimentalLinearAlgebraProvider _experimentalLinearAlgebraProvider;
static Control()
{
@ -85,6 +87,9 @@ namespace MathNet.Numerics
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
}
#endif
// Experimental Linear Algebra Provider
ExperimentalLinearAlgebraProvider = new ReferenceExperimentalLinearAlgebraProvider();
}
public static void UseSingleThread()
@ -156,6 +161,19 @@ namespace MathNet.Numerics
}
}
[Obsolete("Experimental with breaking changes expected between minor version. Do not use until properly released.")]
public static IExperimentalLinearAlgebraProvider ExperimentalLinearAlgebraProvider
{
get { return _experimentalLinearAlgebraProvider; }
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_experimentalLinearAlgebraProvider = value;
}
}
/// <summary>
/// Gets or sets a value indicating how many parallel worker threads shall be used
/// when parallelization is applicable.

6
src/Numerics/Numerics.csproj

@ -148,6 +148,12 @@
<Compile Include="LinearRegression\WeightedRegression.cs" />
<Compile Include="LinearRegression\SimpleRegression.cs" />
<Compile Include="LinearRegression\Util.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\IExperimentalLinearAlgebraProvider.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\ReferenceExperimentalLinearAlgebraProvider.Single.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\ReferenceExperimentalLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\ReferenceExperimentalLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\ReferenceExperimentalLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\ExperimentalLinearAlgebra\ReferenceExperimentalLinearAlgebraProvider.cs" />
<Compile Include="Providers\LinearAlgebra\Acml\AcmlLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\LinearAlgebra\Acml\AcmlLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Providers\LinearAlgebra\Acml\AcmlLinearAlgebraProvider.Double.cs" />

60
src/Numerics/Providers/ExperimentalLinearAlgebra/IExperimentalLinearAlgebraProvider.cs

@ -0,0 +1,60 @@
// <copyright file="IExperimentalLinearAlgebraProvider.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
#endif
[Obsolete("Experimental with breaking changes expected between minor version. Do not use until properly released.")]
public interface IExperimentalLinearAlgebraProvider :
IExperimentalLinearAlgebraProvider<double>,
IExperimentalLinearAlgebraProvider<float>,
IExperimentalLinearAlgebraProvider<Complex>,
IExperimentalLinearAlgebraProvider<Complex32>
{
/// <summary>
/// Initialize and verify that the provided is indeed available. If not, fall back to alternatives like the managed provider
/// </summary>
void InitializeVerify();
}
[Obsolete("Experimental with breaking changes expected between minor version. Do not use until properly released.")]
public interface IExperimentalLinearAlgebraProvider<T>
where T : struct, IEquatable<T>, IFormattable
{
void AddVectors(VectorStorage<T> x, VectorStorage<T> y, VectorStorage<T> result);
}
}

48
src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Complex.cs

@ -0,0 +1,48 @@
// <copyright file="ReferenceExperimentalLinearAlgebraProvider.Complex.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
#if !NOSYSNUMERICS
using Complex = System.Numerics.Complex;
#endif
public partial class ReferenceExperimentalLinearAlgebraProvider
{
public void AddVectors(VectorStorage<Complex> x, VectorStorage<Complex> y, VectorStorage<Complex> result)
{
x.Map2To(result, y, (u, v) => u+v, Zeros.AllowSkip, ExistingData.Clear);
}
}
}

43
src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Complex32.cs

@ -0,0 +1,43 @@
// <copyright file="ReferenceExperimentalLinearAlgebraProvider.Complex32.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
public partial class ReferenceExperimentalLinearAlgebraProvider
{
public void AddVectors(VectorStorage<Complex32> x, VectorStorage<Complex32> y, VectorStorage<Complex32> result)
{
x.Map2To(result, y, (u, v) => u+v, Zeros.AllowSkip, ExistingData.Clear);
}
}
}

43
src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Double.cs

@ -0,0 +1,43 @@
// <copyright file="ReferenceExperimentalLinearAlgebraProvider.Double.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
public partial class ReferenceExperimentalLinearAlgebraProvider
{
public void AddVectors(VectorStorage<double> x, VectorStorage<double> y, VectorStorage<double> result)
{
x.Map2To(result, y, (u,v) => u+v, Zeros.AllowSkip, ExistingData.Clear);
}
}
}

43
src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.Single.cs

@ -0,0 +1,43 @@
// <copyright file="ReferenceExperimentalLinearAlgebraProvider.Single.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Storage;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
public partial class ReferenceExperimentalLinearAlgebraProvider
{
public void AddVectors(VectorStorage<float> x, VectorStorage<float> y, VectorStorage<float> result)
{
x.Map2To(result, y, (u, v) => u+v, Zeros.AllowSkip, ExistingData.Clear);
}
}
}

20
src/Numerics/Providers/ExperimentalLinearAlgebra/ReferenceExperimentalLinearAlgebraProvider.cs

@ -0,0 +1,20 @@
using System;
namespace MathNet.Numerics.Providers.ExperimentalLinearAlgebra
{
[Obsolete("Experimental with breaking changes expected between minor version. Do not use until properly released.")]
public partial class ReferenceExperimentalLinearAlgebraProvider : IExperimentalLinearAlgebraProvider
{
/// <summary>
/// Initialize and verify that the provided is indeed available. If not, fall back to alternatives like the managed provider
/// </summary>
public virtual void InitializeVerify()
{
}
public override string ToString()
{
return "Reference";
}
}
}
Loading…
Cancel
Save