forked from tsai/mathnet-numerics
11 changed files with 114 additions and 313 deletions
@ -1,22 +1,15 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFrameworks>net40;net45;net46;netstandard1.6;netstandard2.0</TargetFrameworks> |
<TargetFrameworks>net40;net45;net46;netstandard1.6;netstandard2.0</TargetFrameworks> |
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> |
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net40'"> |
|
||||
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
<ItemGroup> |
||||
</ItemGroup> |
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45'"> |
|
||||
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net46'"> |
|
||||
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> |
|
||||
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'"> |
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'"> |
||||
<PackageReference Include="MathNet.Numerics" Version="4.0.0-beta05" /> |
|
||||
<PackageReference Include="NETStandard.Library" Version="2.0.1" /> |
<PackageReference Include="NETStandard.Library" Version="2.0.1" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,55 @@ |
|||||
|
module Apply |
||||
|
|
||||
|
open System.Numerics |
||||
|
open MathNet.Numerics |
||||
|
open MathNet.Numerics.Distributions |
||||
|
open MathNet.Numerics.Random |
||||
|
open MathNet.Numerics.LinearAlgebra |
||||
|
open MathNet.Numerics.LinearAlgebra.Double |
||||
|
|
||||
|
/// The size of the vector we want to map things for. |
||||
|
let N = 1000000 |
||||
|
|
||||
|
/// The number of times we repeat a call. |
||||
|
let T = 10 |
||||
|
|
||||
|
/// The list of all functions we want to test. |
||||
|
let FunctionList : (string * (float -> float)) [] = |
||||
|
[| ("Cosine", cos); |
||||
|
("Sine", sin); |
||||
|
("Tangent", tan); |
||||
|
("Inverse Cosine", acos); |
||||
|
("Inverse Sine", asin); |
||||
|
("Inverse Tangent", atan); |
||||
|
("Hyperbolic Cosine", cosh); |
||||
|
("Hyperbolic Sine", sinh); |
||||
|
("Hyperbolic Tangent", tanh); |
||||
|
("Abs", abs); |
||||
|
("Exp", exp); |
||||
|
("Log", log); |
||||
|
("Sqrt", sqrt); |
||||
|
("Error Function", SpecialFunctions.Erf); |
||||
|
("Error Function Complement", SpecialFunctions.Erfc); |
||||
|
("Inverse Error Function", SpecialFunctions.ErfInv); |
||||
|
("Inverse Error Function Complement", SpecialFunctions.ErfcInv) |] |
||||
|
|
||||
|
/// A vector with random entries. |
||||
|
let w = |
||||
|
let dist = Normal(1.0, 10.0, Random.mersenneTwister ()) |
||||
|
DenseVector.random N dist |
||||
|
|
||||
|
/// A stopwatch to time the execution. |
||||
|
let sw = System.Diagnostics.Stopwatch() |
||||
|
|
||||
|
|
||||
|
printfn "%d-dimensional vector for %d iterations:" N T |
||||
|
|
||||
|
for (name, f) in FunctionList do |
||||
|
|
||||
|
let v = w.Clone() |
||||
|
|
||||
|
sw.Restart() |
||||
|
for t in 1 .. T do Vector.mapInPlace f v |
||||
|
sw.Stop() |
||||
|
|
||||
|
printfn "%s:\t\t%d ms" name sw.ElapsedMilliseconds |
||||
@ -1,86 +0,0 @@ |
|||||
// <copyright file="Apply.fsx" 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open System.Numerics |
|
||||
open MathNet.Numerics |
|
||||
open MathNet.Numerics.Distributions |
|
||||
open MathNet.Numerics.Random |
|
||||
open MathNet.Numerics.LinearAlgebra.Double |
|
||||
open MathNet.Numerics.LinearAlgebra.Generic |
|
||||
|
|
||||
/// The size of the vector we want to map things for. |
|
||||
let N = 1000000 |
|
||||
|
|
||||
/// The number of times we repeat a call. |
|
||||
let T = 10 |
|
||||
|
|
||||
/// The list of all functions we want to test. |
|
||||
let FunctionList : (string * (float -> float)) [] = |
|
||||
[| ("Cosine", cos); |
|
||||
("Sine", sin); |
|
||||
("Tangent", tan); |
|
||||
("Inverse Cosine", acos); |
|
||||
("Inverse Sine", asin); |
|
||||
("Inverse Tangent", atan); |
|
||||
("Hyperbolic Cosine", cosh); |
|
||||
("Hyperbolic Sine", sinh); |
|
||||
("Hyperbolic Tangent", tanh); |
|
||||
("Abs", abs); |
|
||||
("Exp", exp); |
|
||||
("Log", log); |
|
||||
("Sqrt", sqrt); |
|
||||
("Error Function", SpecialFunctions.Erf); |
|
||||
("Error Function Complement", SpecialFunctions.Erfc); |
|
||||
("Inverse Error Function", SpecialFunctions.ErfInv); |
|
||||
("Inverse Error Function Complement", SpecialFunctions.ErfcInv) |] |
|
||||
|
|
||||
/// A vector with random entries. |
|
||||
let w = |
|
||||
let dist = Normal(1.0, 10.0) |> withRandom (Random.mersenneTwister ()) |
|
||||
DenseVector.randomCreate N dist |
|
||||
|
|
||||
/// A stopwatch to time the execution. |
|
||||
let sw = System.Diagnostics.Stopwatch() |
|
||||
|
|
||||
|
|
||||
printfn "%d-dimensional vector for %d iterations:" N T |
|
||||
|
|
||||
for (name, f) in FunctionList do |
|
||||
|
|
||||
let v = w.Clone() |
|
||||
|
|
||||
sw.Restart() |
|
||||
for t in 1 .. T do Vector.mapInPlace f v |
|
||||
sw.Stop() |
|
||||
|
|
||||
printfn "%s:\t\t%d ms" name sw.ElapsedMilliseconds |
|
||||
@ -0,0 +1,17 @@ |
|||||
|
module Histogram |
||||
|
|
||||
|
open MathNet.Numerics.Statistics |
||||
|
|
||||
|
/// The number of buckets to use in our histogram. |
||||
|
let B = 4 |
||||
|
|
||||
|
/// Create a small dataset. |
||||
|
let data = [| 0.5; 1.5; 2.5; 3.5; 4.5; 5.5; 6.5; 7.5; 8.5; 9.5 |] |
||||
|
|
||||
|
/// A histogram with 4 buckets for this dataset. |
||||
|
let hist = new Histogram(data, B) |
||||
|
|
||||
|
// Print some histogram information. |
||||
|
printfn "Histogram.ToString(): %O" hist |
||||
|
for i in 0 .. B-1 do |
||||
|
printfn "Bucket %d contains %f datapoints." i hist.[i].Count |
||||
@ -1,48 +0,0 @@ |
|||||
// <copyright file="Histogram.fsx" 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open MathNet.Numerics.Statistics |
|
||||
|
|
||||
/// The number of buckets to use in our histogram. |
|
||||
let B = 4 |
|
||||
|
|
||||
/// Create a small dataset. |
|
||||
let data = [| 0.5; 1.5; 2.5; 3.5; 4.5; 5.5; 6.5; 7.5; 8.5; 9.5 |] |
|
||||
|
|
||||
/// A histogram with 4 buckets for this dataset. |
|
||||
let hist = new Histogram(data, B) |
|
||||
|
|
||||
// Print some histogram information. |
|
||||
printfn "Histogram.ToString(): %O" hist |
|
||||
for i in 0 .. B-1 do |
|
||||
printfn "Bucket %d contains %f datapoints." i hist.[i].Count |
|
||||
@ -1,35 +1,4 @@ |
|||||
// <copyright file="LinearRegression.fsx" company="Math.NET"> |
module LinearRegression |
||||
// 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open System |
open System |
||||
open MathNet.Numerics |
open MathNet.Numerics |
||||
@ -1,35 +1,4 @@ |
|||||
// <copyright file="MCMC.fsx" company="Math.NET"> |
module MCMC |
||||
// 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open MathNet.Numerics |
open MathNet.Numerics |
||||
open MathNet.Numerics.Random |
open MathNet.Numerics.Random |
||||
@ -1,35 +1,4 @@ |
|||||
// <copyright file="Matrices.fsx" company="Math.NET"> |
module Matrices |
||||
// 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open MathNet.Numerics.LinearAlgebra |
open MathNet.Numerics.LinearAlgebra |
||||
open MathNet.Numerics.LinearAlgebra.Double |
open MathNet.Numerics.LinearAlgebra.Double |
||||
@ -1,35 +1,4 @@ |
|||||
// <copyright file="Vectors.fsx" company="Math.NET"> |
module Vectors |
||||
// 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-2013 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> |
|
||||
|
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.dll" |
|
||||
#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll" |
|
||||
|
|
||||
open MathNet.Numerics.LinearAlgebra |
open MathNet.Numerics.LinearAlgebra |
||||
open MathNet.Numerics.LinearAlgebra.Double |
open MathNet.Numerics.LinearAlgebra.Double |
||||
Loading…
Reference in new issue