Skip to content

Commit

Permalink
Close #331 - Immutable expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
sys27 committed Sep 26, 2020
1 parent 1bb7ef9 commit 4627295
Show file tree
Hide file tree
Showing 199 changed files with 3,093 additions and 2,924 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"-p:CollectCoverage=true",
"-p:CoverletOutputFormat=cobertura",
"-p:CoverletOutput=\"../coverage/\"",
"-p:ExcludeByAttribute=\"ExcludeFromCodeCoverage\"",
"-p:ExcludeByAttribute=\"ExcludeFromCodeCoverage,GeneratedCode\"",
"-p:Include=\"[xFunc.*]*\"",
"-p:Exclude=\"[xFunc.Tests*]*%2c[xFunc.*]*.Resource%2c[xFunc.*]*Exception\"",
"-p:Threshold=90",
Expand Down
2 changes: 1 addition & 1 deletion CI/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
inputs:
command: test
projects: '$(solution)'
arguments: '--nologo --no-build -c $(buildConfiguration) -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput="$(Build.SourcesDirectory)/coverage/" -p:ExcludeByAttribute="ExcludeFromCodeCoverage" -p:Include="[xFunc.*]*" -p:Exclude="[xFunc.Tests*]*%2c[xFunc.*]*.Resource%2c[xFunc.*]*Exception" -p:Threshold=90 -p:ThresholdStat=total'
arguments: '--nologo --no-build -c $(buildConfiguration) -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput="$(Build.SourcesDirectory)/coverage/" -p:ExcludeByAttribute=ExcludeFromCodeCoverage%2cGeneratedCode -p:Include="[xFunc.*]*" -p:Exclude="[xFunc.Tests*]*%2c[xFunc.*]*.Resource%2c[xFunc.*]*Exception" -p:Threshold=90 -p:ThresholdStat=total'
publishTestResults: true

- task: CmdLine@2
Expand Down
11 changes: 6 additions & 5 deletions xFunc.Benchmark/Benchmarks/MulMatrixBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

using System;
using System.Collections.Immutable;
using BenchmarkDotNet.Attributes;
using xFunc.Maths.Expressions;
using xFunc.Maths.Expressions.Matrices;
Expand All @@ -40,17 +41,17 @@ public void Setup()

private Matrix CreateMatrix()
{
var vectors = new Vector[Size];
var vectors = ImmutableArray.CreateBuilder<Vector>(Size);
for (var i = 0; i < Size; i++)
{
var vector = new IExpression[Size];
var vector = ImmutableArray.CreateBuilder<IExpression>(Size);
for (var j = 0; j < Size; j++)
vector[j] = new Number(random.Next());
vector.Add(new Number(random.Next()));

vectors[i] = new Vector(vector);
vectors.Add(new Vector(vector.ToImmutableArray()));
}

return new Matrix(vectors);
return new Matrix(vectors.ToImmutableArray());
}

[Benchmark]
Expand Down
7 changes: 4 additions & 3 deletions xFunc.Benchmark/Benchmarks/MulVectorBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

using System;
using System.Collections.Immutable;
using BenchmarkDotNet.Attributes;
using xFunc.Maths.Expressions;
using xFunc.Maths.Expressions.Matrices;
Expand All @@ -40,11 +41,11 @@ public void Setup()

private Vector CreateVector()
{
var vector = new IExpression[Size];
var vector = ImmutableArray.CreateBuilder<IExpression>(Size);
for (var j = 0; j < Size; j++)
vector[j] = new Number(random.Next());
vector.Add(new Number(random.Next()));

return new Vector(vector);
return new Vector(vector.ToImmutableArray());
}

[Benchmark]
Expand Down
11 changes: 6 additions & 5 deletions xFunc.Benchmark/Benchmarks/TransposeBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using BenchmarkDotNet.Attributes;
using xFunc.Maths.Expressions;
using xFunc.Maths.Expressions.Matrices;
Expand Down Expand Up @@ -46,17 +47,17 @@ public void Setup()

private Matrix CreateMatrix()
{
var vectors = new Vector[Size.rows];
var vectors = ImmutableArray.CreateBuilder<Vector>(Size.rows);
for (var i = 0; i < Size.rows; i++)
{
var vector = new IExpression[Size.columns];
var vector = ImmutableArray.CreateBuilder<IExpression>(Size.columns);
for (var j = 0; j < Size.columns; j++)
vector[j] = new Number(random.Next());
vector.Add(new Number(random.Next()));

vectors[i] = new Vector(vector);
vectors.Add(new Vector(vector.ToImmutableArray()));
}

return new Matrix(vectors);
return new Matrix(vectors.ToImmutableArray());
}

[Benchmark]
Expand Down

0 comments on commit 4627295

Please sign in to comment.