-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
461 changed files
with
42,288 additions
and
44,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths; | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
public class CtorBenchmark | ||
{ | ||
public class CtorBenchmark | ||
[Benchmark] | ||
public IParser ParserCtor() | ||
{ | ||
[Benchmark] | ||
public IParser ParserCtor() | ||
{ | ||
return new Parser(); | ||
} | ||
return new Parser(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths; | ||
using xFunc.Maths.Analyzers; | ||
using xFunc.Maths.Expressions; | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
public class DifferentiatorBenchmark | ||
{ | ||
public class DifferentiatorBenchmark | ||
{ | ||
private Differentiator differentiator; | ||
private DifferentiatorContext context; | ||
|
||
private IExpression complexExp; | ||
private Differentiator differentiator; | ||
private DifferentiatorContext context; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
differentiator = new Differentiator(); | ||
context = DifferentiatorContext.Default(); | ||
private IExpression complexExp; | ||
|
||
var processor = new Processor(); | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
differentiator = new Differentiator(); | ||
context = DifferentiatorContext.Default(); | ||
|
||
complexExp = processor.Parse("(2 * abs(3 * sin(4 * cos(5 * tan(6 * ctg(x ^ 2))))) - ln(x ^ 2)) + arcsin(arccos(arctan(arcctg(x ^ 10))))"); | ||
} | ||
var processor = new Processor(); | ||
|
||
[Benchmark] | ||
public IExpression ComplexExpression() | ||
=> complexExp.Analyze(differentiator, context); | ||
complexExp = processor.Parse("(2 * abs(3 * sin(4 * cos(5 * tan(6 * ctg(x ^ 2))))) - ln(x ^ 2)) + arcsin(arccos(arctan(arcctg(x ^ 10))))"); | ||
} | ||
|
||
[Benchmark] | ||
public IExpression ComplexExpression() | ||
=> complexExp.Analyze(differentiator, context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths; | ||
using xFunc.Maths.Expressions; | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
public class GcdBenchmark | ||
{ | ||
public class GcdBenchmark | ||
{ | ||
private IExpression gcd; | ||
private IExpression lcm; | ||
private IExpression gcd; | ||
private IExpression lcm; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var processor = new Processor(); | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var processor = new Processor(); | ||
|
||
gcd = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)"); | ||
lcm = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)"); | ||
} | ||
gcd = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)"); | ||
lcm = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)"); | ||
} | ||
|
||
[Benchmark] | ||
public object GcdExecute() => gcd.Execute(); | ||
[Benchmark] | ||
public object GcdExecute() => gcd.Execute(); | ||
|
||
[Benchmark] | ||
public object LcmExecute() => lcm.Execute(); | ||
} | ||
[Benchmark] | ||
public object LcmExecute() => lcm.Execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,43 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Immutable; | ||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths.Expressions; | ||
using xFunc.Maths.Expressions.Matrices; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
public class MulMatrixBenchmark | ||
{ | ||
public class MulMatrixBenchmark | ||
{ | ||
private readonly Random random = new Random(); | ||
private readonly Random random = new Random(); | ||
|
||
private Mul mul; | ||
private Mul mul; | ||
|
||
[Params(2, 10, 100)] | ||
public int Size; | ||
[Params(2, 10, 100)] | ||
public int Size; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var left = CreateMatrix(); | ||
var right = CreateMatrix(); | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var left = CreateMatrix(); | ||
var right = CreateMatrix(); | ||
|
||
mul = new Mul(left, right); | ||
} | ||
mul = new Mul(left, right); | ||
} | ||
|
||
private Matrix CreateMatrix() | ||
private Matrix CreateMatrix() | ||
{ | ||
var vectors = ImmutableArray.CreateBuilder<Vector>(Size); | ||
for (var i = 0; i < Size; i++) | ||
{ | ||
var vectors = ImmutableArray.CreateBuilder<Vector>(Size); | ||
for (var i = 0; i < Size; i++) | ||
{ | ||
var vector = ImmutableArray.CreateBuilder<IExpression>(Size); | ||
for (var j = 0; j < Size; j++) | ||
vector.Add(new Number(random.Next())); | ||
var vector = ImmutableArray.CreateBuilder<IExpression>(Size); | ||
for (var j = 0; j < Size; j++) | ||
vector.Add(new Number(random.Next())); | ||
|
||
vectors.Add(new Vector(vector.ToImmutableArray())); | ||
} | ||
|
||
return new Matrix(vectors.ToImmutableArray()); | ||
vectors.Add(new Vector(vector.ToImmutableArray())); | ||
} | ||
|
||
[Benchmark] | ||
public object MulMatrix() => mul.Execute(); | ||
return new Matrix(vectors.ToImmutableArray()); | ||
} | ||
|
||
[Benchmark] | ||
public object MulMatrix() => mul.Execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,37 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Immutable; | ||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths.Expressions; | ||
using xFunc.Maths.Expressions.Matrices; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
{ | ||
public class MulVectorBenchmark | ||
{ | ||
private readonly Random random = new Random(); | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
private Mul mul; | ||
public class MulVectorBenchmark | ||
{ | ||
private readonly Random random = new Random(); | ||
|
||
[Params(2, 10, 100)] | ||
public int Size; | ||
private Mul mul; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var left = CreateVector(); | ||
var right = CreateVector(); | ||
[Params(2, 10, 100)] | ||
public int Size; | ||
|
||
mul = new Mul(left, right); | ||
} | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var left = CreateVector(); | ||
var right = CreateVector(); | ||
|
||
private Vector CreateVector() | ||
{ | ||
var vector = ImmutableArray.CreateBuilder<IExpression>(Size); | ||
for (var j = 0; j < Size; j++) | ||
vector.Add(new Number(random.Next())); | ||
mul = new Mul(left, right); | ||
} | ||
|
||
return new Vector(vector.ToImmutableArray()); | ||
} | ||
private Vector CreateVector() | ||
{ | ||
var vector = ImmutableArray.CreateBuilder<IExpression>(Size); | ||
for (var j = 0; j < Size; j++) | ||
vector.Add(new Number(random.Next())); | ||
|
||
[Benchmark] | ||
public object MulVector() => mul.Execute(); | ||
return new Vector(vector.ToImmutableArray()); | ||
} | ||
|
||
[Benchmark] | ||
public object MulVector() => mul.Execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths; | ||
using xFunc.Maths.Expressions; | ||
using xFunc.Maths.Results; | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
public class ProcessorBenchmark | ||
{ | ||
public class ProcessorBenchmark | ||
{ | ||
private Processor processor; | ||
private Processor processor; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
processor = new Processor(); | ||
} | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
processor = new Processor(); | ||
} | ||
|
||
[Benchmark] | ||
public IExpression Parse() | ||
=> processor.Parse("(100.1 + 2(3sin(4cos(5tan(6ctg(10x)))) * 3) / (func(a, b, c) ^ 2)) - (cos(y) - 111.3) & (true | false -> true <-> false eq true) + (det({{1, 2}, {3, 4}}) * 10log(2, 3)) + re(3 + 2i) - im(2 - 9i) + (9 + 2i)"); | ||
[Benchmark] | ||
public IExpression Parse() | ||
=> processor.Parse("(100.1 + 2(3sin(4cos(5tan(6ctg(10x)))) * 3) / (func(a, b, c) ^ 2)) - (cos(y) - 111.3) & (true | false -> true <-> false eq true) + (det({{1, 2}, {3, 4}}) * 10log(2, 3)) + re(3 + 2i) - im(2 - 9i) + (9 + 2i)"); | ||
|
||
[Benchmark] | ||
public NumberResult Solve() | ||
=> processor.Solve<NumberResult>("count(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + (2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5) * 10 ^ 6 + 10!"); | ||
} | ||
[Benchmark] | ||
public NumberResult Solve() | ||
=> processor.Solve<NumberResult>("count(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + (2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5 + 2 * sin(4 * cos(6 * tan(8 * cot(pi / 4) ^ 2) ^ 3) ^ 4) ^ 5) * 10 ^ 6 + 10!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
// Copyright (c) Dmytro Kyshchenko. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using xFunc.Maths; | ||
using xFunc.Maths.Analyzers; | ||
using xFunc.Maths.Expressions; | ||
namespace xFunc.Benchmark.Benchmarks; | ||
|
||
namespace xFunc.Benchmark.Benchmarks | ||
public class SimplifierBenchmark | ||
{ | ||
public class SimplifierBenchmark | ||
{ | ||
private Simplifier simplifier; | ||
|
||
private IExpression exp; | ||
private Simplifier simplifier; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
simplifier = new Simplifier(); | ||
private IExpression exp; | ||
|
||
var processor = new Processor(); | ||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
simplifier = new Simplifier(); | ||
|
||
exp = processor.Parse("0 + x + x + 0 + 1 + 2 + 3 + x + (2 * x) + (3 * x) + (x * 4) - 0 - x - 0 - 1 - 2 - 3 - (2 * x) - (x * 3) + (x * 0) - (0 * x) + (1 * x) - (x * 1) * (x * x) * (2 * x) * (x * 3) + (x ^ 0) + (x ^ 0) + (e ^ ln(1)) + cos(arccos(0)) + (x * 0) + tan(arctan(0)) + sin(arcsin(x)) - (0 * x)"); | ||
} | ||
var processor = new Processor(); | ||
|
||
[Benchmark] | ||
public IExpression Simplify() | ||
=> exp.Analyze(simplifier); | ||
exp = processor.Parse("0 + x + x + 0 + 1 + 2 + 3 + x + (2 * x) + (3 * x) + (x * 4) - 0 - x - 0 - 1 - 2 - 3 - (2 * x) - (x * 3) + (x * 0) - (0 * x) + (1 * x) - (x * 1) * (x * x) * (2 * x) * (x * 3) + (x ^ 0) + (x ^ 0) + (e ^ ln(1)) + cos(arccos(0)) + (x * 0) + tan(arctan(0)) + sin(arcsin(x)) - (0 * x)"); | ||
} | ||
|
||
[Benchmark] | ||
public IExpression Simplify() | ||
=> exp.Analyze(simplifier); | ||
} |
Oops, something went wrong.