├── .editorconfig
├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ └── bug_report.md
├── dependabot.yml
└── workflows
│ ├── codeql.yml
│ └── github-pages.yml
├── .gitignore
├── .stylecop.json
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── CI
├── azure-pipelines.yml
└── codecov.yml
├── CODEOWNERS
├── Directory.Build.targets
├── Directory.Packages.props
├── LICENSE
├── README.md
├── SECURITY.md
├── docs
├── .gitignore
├── api
│ └── .gitignore
├── articles
│ ├── breaking-changes.md
│ ├── change-log.md
│ ├── custom-expression.md
│ ├── get-started.md
│ ├── how-to-build.md
│ ├── performance-comparison.md
│ ├── simplification-rules.md
│ ├── supported-functions-and-operations.md
│ └── toc.yml
├── docfx.json
├── images
│ ├── favicon.ico
│ └── logo.png
├── index.md
└── toc.yml
├── version.json
├── xFunc Grammar.txt
├── xFunc.Benchmark
├── Benchmarks
│ ├── ConvertBenchmark.cs
│ ├── CtorBenchmark.cs
│ ├── DifferentiatorBenchmark.cs
│ ├── GcdBenchmark.cs
│ ├── MatrixBenchmark.cs
│ ├── ProcessorBenchmark.cs
│ ├── SimplifierBenchmark.cs
│ ├── StatisticalBenchmark.cs
│ ├── TransposeBenchmark.cs
│ ├── TypeAnalyzerBenchmark.cs
│ └── VectorBenchmark.cs
├── Program.cs
└── xFunc.Benchmark.csproj
├── xFunc.Cli
├── Options
│ ├── BaseOptions.cs
│ ├── DebugInfoOptions.cs
│ ├── InteractiveOptions.cs
│ ├── ParseOptions.cs
│ ├── RunFileOptions.cs
│ └── SolveOptions.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
└── xFunc.Cli.csproj
├── xFunc.Maths
├── Analyzers
│ ├── Analyzer{TResult,TContext}.cs
│ ├── Analyzer{TResult}.cs
│ ├── Differentiator.cs
│ ├── DifferentiatorContext.cs
│ ├── Formatters
│ │ ├── CommonFormatter.cs
│ │ └── IFormatter.cs
│ ├── IAnalyzer{TResult,TContext}.cs
│ ├── IAnalyzer{TResult}.cs
│ ├── IDifferentiator.cs
│ ├── ISimplifier.cs
│ ├── Simplifier.cs
│ └── TypeAnalyzers
│ │ ├── BinaryParameterTypeMismatchException.cs
│ │ ├── DifferentParameterTypeMismatchException.cs
│ │ ├── ITypeAnalyzer.cs
│ │ ├── ParameterTypeMismatchException.cs
│ │ ├── ResultTypes.cs
│ │ ├── ResultTypesExtensions.cs
│ │ └── TypeAnalyzer.cs
├── Builder.cs
├── ComplexExtensions.cs
├── Expressions
│ ├── Abs.cs
│ ├── Add.cs
│ ├── Assign.cs
│ ├── BinaryExpression.cs
│ ├── CallExpression.cs
│ ├── Ceil.cs
│ ├── ComplexNumbers
│ │ ├── ComplexNumber.cs
│ │ ├── Conjugate.cs
│ │ ├── Im.cs
│ │ ├── Phase.cs
│ │ ├── Re.cs
│ │ ├── Reciprocal.cs
│ │ └── ToComplex.cs
│ ├── Curry.cs
│ ├── Del.cs
│ ├── DelegateExpression.cs
│ ├── Derivative.cs
│ ├── DifferentParametersExpression.cs
│ ├── Div.cs
│ ├── Domains
│ │ ├── Domain.cs
│ │ ├── DomainBuilder.cs
│ │ ├── DomainRange.cs
│ │ └── DomainRangeBuilder.cs
│ ├── EmptyValue.cs
│ ├── ExecutionException.cs
│ ├── Exp.cs
│ ├── Fact.cs
│ ├── Floor.cs
│ ├── Frac.cs
│ ├── GCD.cs
│ ├── Hyperbolic
│ │ ├── Arcosh.cs
│ │ ├── Arcoth.cs
│ │ ├── Arcsch.cs
│ │ ├── Arsech.cs
│ │ ├── Arsinh.cs
│ │ ├── Artanh.cs
│ │ ├── Cosh.cs
│ │ ├── Coth.cs
│ │ ├── Csch.cs
│ │ ├── HyperbolicExpression.cs
│ │ ├── InverseHyperbolicExpression.cs
│ │ ├── Sech.cs
│ │ ├── Sinh.cs
│ │ └── Tanh.cs
│ ├── IExpression.cs
│ ├── LCM.cs
│ ├── Lambda.cs
│ ├── LambdaExpression.cs
│ ├── LambdaExtensions.cs
│ ├── Lb.cs
│ ├── Lg.cs
│ ├── Ln.cs
│ ├── Log.cs
│ ├── LogicalAndBitwise
│ │ ├── And.cs
│ │ ├── Bool.cs
│ │ ├── Equality.cs
│ │ ├── Implication.cs
│ │ ├── NAnd.cs
│ │ ├── NOr.cs
│ │ ├── Not.cs
│ │ ├── Or.cs
│ │ └── XOr.cs
│ ├── Matrices
│ │ ├── CrossProduct.cs
│ │ ├── Determinant.cs
│ │ ├── DotProduct.cs
│ │ ├── InvalidMatrixException.cs
│ │ ├── Inverse.cs
│ │ ├── Matrix.cs
│ │ ├── MatrixValue.cs
│ │ ├── Transpose.cs
│ │ ├── Vector.cs
│ │ └── VectorValue.cs
│ ├── Mod.cs
│ ├── Mul.cs
│ ├── Number.cs
│ ├── NumberValue.cs
│ ├── Parameters
│ │ ├── ExpressionParameters.ScopedExpressionParameters.cs
│ │ ├── ExpressionParameters.cs
│ │ ├── Parameter.cs
│ │ ├── ParameterIsReadOnlyException.cs
│ │ ├── ParameterType.cs
│ │ └── ParameterValue.cs
│ ├── Pow.cs
│ ├── Programming
│ │ ├── AddAssign.cs
│ │ ├── ConditionalAnd.cs
│ │ ├── ConditionalOr.cs
│ │ ├── Dec.cs
│ │ ├── DivAssign.cs
│ │ ├── Equal.cs
│ │ ├── For.cs
│ │ ├── GreaterOrEqual.cs
│ │ ├── GreaterThan.cs
│ │ ├── If.cs
│ │ ├── Inc.cs
│ │ ├── LeftShift.cs
│ │ ├── LeftShiftAssign.cs
│ │ ├── LessOrEqual.cs
│ │ ├── LessThan.cs
│ │ ├── MulAssign.cs
│ │ ├── NotEqual.cs
│ │ ├── RightShift.cs
│ │ ├── RightShiftAssign.cs
│ │ ├── SubAssign.cs
│ │ ├── VariableBinaryExpression.cs
│ │ ├── VariableUnaryExpression.cs
│ │ └── While.cs
│ ├── Rational.cs
│ ├── RationalValue.cs
│ ├── Root.cs
│ ├── Round.cs
│ ├── Sign.cs
│ ├── Simplify.cs
│ ├── Sqrt.cs
│ ├── Statistical
│ │ ├── Avg.cs
│ │ ├── Count.cs
│ │ ├── Max.cs
│ │ ├── Min.cs
│ │ ├── Product.cs
│ │ ├── StatisticalExpression.cs
│ │ ├── Stdev.cs
│ │ ├── Stdevp.cs
│ │ ├── Sum.cs
│ │ ├── Var.cs
│ │ └── Varp.cs
│ ├── StringExpression.cs
│ ├── Sub.cs
│ ├── ToBin.cs
│ ├── ToHex.cs
│ ├── ToNumber.cs
│ ├── ToOct.cs
│ ├── ToRational.cs
│ ├── Trigonometric
│ │ ├── Arccos.cs
│ │ ├── Arccot.cs
│ │ ├── Arccsc.cs
│ │ ├── Arcsec.cs
│ │ ├── Arcsin.cs
│ │ ├── Arctan.cs
│ │ ├── Cos.cs
│ │ ├── Cot.cs
│ │ ├── Csc.cs
│ │ ├── InverseTrigonometricExpression.cs
│ │ ├── Sec.cs
│ │ ├── Sin.cs
│ │ ├── Tan.cs
│ │ └── TrigonometricExpression.cs
│ ├── Trunc.cs
│ ├── UnaryExpression.cs
│ ├── UnaryMinus.cs
│ ├── Unassign.cs
│ ├── Units
│ │ ├── AngleUnits
│ │ │ ├── Angle.cs
│ │ │ ├── AngleUnit.cs
│ │ │ ├── AngleValue.cs
│ │ │ ├── ToDegree.cs
│ │ │ ├── ToGradian.cs
│ │ │ └── ToRadian.cs
│ │ ├── AreaUnits
│ │ │ ├── Area.cs
│ │ │ ├── AreaUnit.cs
│ │ │ └── AreaValue.cs
│ │ ├── Convert.cs
│ │ ├── Converters
│ │ │ ├── AngleConverter.cs
│ │ │ ├── AreaConverter.cs
│ │ │ ├── Converter.cs
│ │ │ ├── IConverter.cs
│ │ │ ├── IConverter{TValue}.cs
│ │ │ ├── LengthConverter.cs
│ │ │ ├── MassConverter.cs
│ │ │ ├── PowerConverter.cs
│ │ │ ├── TemperatureConverter.cs
│ │ │ ├── TimeConverter.cs
│ │ │ └── VolumeConverter.cs
│ │ ├── LengthUnits
│ │ │ ├── Length.cs
│ │ │ ├── LengthUnit.cs
│ │ │ └── LengthValue.cs
│ │ ├── MassUnits
│ │ │ ├── Mass.cs
│ │ │ ├── MassUnit.cs
│ │ │ └── MassValue.cs
│ │ ├── PowerUnits
│ │ │ ├── Power.cs
│ │ │ ├── PowerUnit.cs
│ │ │ └── PowerValue.cs
│ │ ├── TemperatureUnits
│ │ │ ├── Temperature.cs
│ │ │ ├── TemperatureUnit.cs
│ │ │ └── TemperatureValue.cs
│ │ ├── TimeUnits
│ │ │ ├── Time.cs
│ │ │ ├── TimeUnit.cs
│ │ │ └── TimeValue.cs
│ │ ├── Unit.cs
│ │ ├── UnitIsNotSupportedException.cs
│ │ ├── ValueIsNotSupportedException.cs
│ │ └── VolumeUnits
│ │ │ ├── Volume.cs
│ │ │ ├── VolumeUnit.cs
│ │ │ └── VolumeValue.cs
│ └── Variable.cs
├── IParser.cs
├── InvalidResultException.cs
├── MathExtensions.cs
├── ParseException.cs
├── Parser.ExpressionFactory.cs
├── Parser.TokenReader.cs
├── Parser.cs
├── Processor.cs
├── Resources
│ ├── Resource.Designer.cs
│ └── Resource.resx
├── Results
│ ├── Result.AngleResult.cs
│ ├── Result.AreaResult.cs
│ ├── Result.BooleanResult.cs
│ ├── Result.ComplexNumberResult.cs
│ ├── Result.EmptyResult.cs
│ ├── Result.LambdaResult.cs
│ ├── Result.LengthResult.cs
│ ├── Result.MassResult.cs
│ ├── Result.MatrixResult.cs
│ ├── Result.NumberResult.cs
│ ├── Result.PowerResult.cs
│ ├── Result.RationalResult.cs
│ ├── Result.StringResult.cs
│ ├── Result.TemperatureResult.cs
│ ├── Result.TimeResult.cs
│ ├── Result.VectorResult.cs
│ ├── Result.VolumeResult.cs
│ └── Result.cs
├── Tokenization
│ ├── Lexer.IdToken.cs
│ ├── Lexer.NumberToken.cs
│ ├── Lexer.OperatorToken.cs
│ ├── Lexer.StringToken.cs
│ ├── Lexer.SymbolToken.cs
│ ├── Lexer.cs
│ ├── ParseNumbers.cs
│ ├── Token.cs
│ └── TokenKind.cs
├── TokenizeException.cs
└── xFunc.Maths.csproj
├── xFunc.Tests
├── AllExpressionsData.cs
├── Analyzers
│ ├── DifferentiatorTests
│ │ ├── DifferentiatorTest.cs
│ │ └── NullArgumentTest.cs
│ ├── Formatters
│ │ └── CommonFormatterTest.cs
│ ├── SimplifierTests
│ │ ├── AddSimplifierTest.cs
│ │ ├── AngleSimplifierTest.cs
│ │ ├── BaseSimplifierTest.cs
│ │ ├── DivSimplifierTest.cs
│ │ ├── LogSimplifierTest.cs
│ │ ├── MulSimplifierTest.cs
│ │ ├── PowerSimplifierTest.cs
│ │ ├── SimplifierTest.cs
│ │ ├── SubSimplifierTest.cs
│ │ ├── ToNumberSimplifierTest.cs
│ │ └── TrigonometricSimplifierTest.cs
│ └── TypeAnalyzerTests
│ │ ├── AbsTests.cs
│ │ ├── AddTests.cs
│ │ ├── CeilTests.cs
│ │ ├── ComplexNumberTests.cs
│ │ ├── DivTests.cs
│ │ ├── FloorTests.cs
│ │ ├── FracTests.cs
│ │ ├── HyperbolicTests.cs
│ │ ├── LogTests.cs
│ │ ├── LogicalBitwiseTests.cs
│ │ ├── LogicalTests.cs
│ │ ├── MatrixTests.cs
│ │ ├── MulTests.cs
│ │ ├── NumericConvertionTests.cs
│ │ ├── PowTests.cs
│ │ ├── ProgrammingTests
│ │ ├── AssignmentOperatorsTests.cs
│ │ ├── ConditionalOperatorsTests.cs
│ │ ├── EqualityOperatorsTests.cs
│ │ ├── ProgrammingTest.cs
│ │ ├── RelationalOperatorsTests.cs
│ │ └── ShiftOperatorsTests.cs
│ │ ├── RootTests.cs
│ │ ├── RoundTests.cs
│ │ ├── SignTests.cs
│ │ ├── StandardTests.cs
│ │ ├── StatisticalTests.cs
│ │ ├── SubTests.cs
│ │ ├── ToNumberTests.cs
│ │ ├── TrigonometricTests.cs
│ │ ├── TruncTests.cs
│ │ ├── TypeAnalyzerBaseTests.cs
│ │ └── UnaryMinusTests.cs
├── BaseTest.cs
├── BuilderTest.cs
├── Expressions
│ ├── AbsTest.cs
│ ├── AddTest.cs
│ ├── AssignTest.cs
│ ├── BaseExpressionTests.cs
│ ├── BinaryTest.cs
│ ├── CallExpressionTest.cs
│ ├── CeilTest.cs
│ ├── ComplexNumbers
│ │ ├── ComplexNumberTest.cs
│ │ ├── ConjugateTest.cs
│ │ ├── ImTest.cs
│ │ ├── PhaseTest.cs
│ │ ├── ReTest.cs
│ │ ├── ReciprocalTest.cs
│ │ └── ToComplexTest.cs
│ ├── CurryTest.cs
│ ├── DelTest.cs
│ ├── DelegateExpressionTest.cs
│ ├── DerivativeTest.cs
│ ├── DivTest.cs
│ ├── Domains
│ │ ├── DomainBuilderTests.cs
│ │ ├── DomainRangeTests.cs
│ │ └── DomainTests.cs
│ ├── ExpTest.cs
│ ├── FactTest.cs
│ ├── FloorTest.cs
│ ├── FracTest.cs
│ ├── GCDTest.cs
│ ├── Hyperbolic
│ │ ├── HyperbolicArcosecantTest.cs
│ │ ├── HyperbolicArcosineTest.cs
│ │ ├── HyperbolicArcotangentTest.cs
│ │ ├── HyperbolicArsecantTest.cs
│ │ ├── HyperbolicArsineTest.cs
│ │ ├── HyperbolicArtangentTest.cs
│ │ ├── HyperbolicCosecantTest.cs
│ │ ├── HyperbolicCosineTest.cs
│ │ ├── HyperbolicCotangentTest.cs
│ │ ├── HyperbolicSecantTest.cs
│ │ ├── HyperbolicSineTest.cs
│ │ └── HyperbolicTangentTest.cs
│ ├── LCMTest.cs
│ ├── LambdaExpressionTest.cs
│ ├── LambdaTests.cs
│ ├── LbTest.cs
│ ├── LgTest.cs
│ ├── LnTest.cs
│ ├── LogTest.cs
│ ├── LogicalAndBitwise
│ │ ├── AndTest.cs
│ │ ├── BoolTest.cs
│ │ ├── EqualityTest.cs
│ │ ├── ImplicationTest.cs
│ │ ├── NAndTest.cs
│ │ ├── NOrTest.cs
│ │ ├── NotTest.cs
│ │ ├── OrTest.cs
│ │ └── XOrTest.cs
│ ├── Matrices
│ │ ├── CrossProductTests.cs
│ │ ├── DeterminantTest.cs
│ │ ├── DotProductTests.cs
│ │ ├── InverseTest.cs
│ │ ├── MatrixTest.cs
│ │ ├── MatrixValueTests.cs
│ │ ├── TransposeTest.cs
│ │ ├── VectorTest.cs
│ │ └── VectorValueTests.cs
│ ├── ModTest.cs
│ ├── MulTest.cs
│ ├── NumberTest.cs
│ ├── NumberValueTest.cs
│ ├── Parameters
│ │ ├── ExpressionParameterTest.cs
│ │ ├── ParameterTest.cs
│ │ └── ParameterValueTest.cs
│ ├── PowTest.cs
│ ├── Programming
│ │ ├── AddAssignTest.cs
│ │ ├── ConditionalAndTest.cs
│ │ ├── ConditionalOrTest.cs
│ │ ├── DecTest.cs
│ │ ├── DivAssignTest.cs
│ │ ├── EqualTest.cs
│ │ ├── ForTest.cs
│ │ ├── GreaterOrEqualTest.cs
│ │ ├── GreaterTest.cs
│ │ ├── IfTest.cs
│ │ ├── IncTest.cs
│ │ ├── LeftShiftAssignTest.cs
│ │ ├── LeftShiftTest.cs
│ │ ├── LessOrEqualTest.cs
│ │ ├── LessThanTest.cs
│ │ ├── MulAssignTest.cs
│ │ ├── NotEqualTest.cs
│ │ ├── RightShiftAssignTest.cs
│ │ ├── RightShiftTest.cs
│ │ ├── SubAssignTest.cs
│ │ └── WhileTest.cs
│ ├── RationalTest.cs
│ ├── RationalValueTests.cs
│ ├── RootTest.cs
│ ├── RoundTest.cs
│ ├── SignTest.cs
│ ├── SimplifyTest.cs
│ ├── SqrtTest.cs
│ ├── Statistical
│ │ ├── AvgTest.cs
│ │ ├── CountTest.cs
│ │ ├── MaxTest.cs
│ │ ├── MinTest.cs
│ │ ├── ProductTest.cs
│ │ ├── StatisticalTests.cs
│ │ ├── StdevTest.cs
│ │ ├── StdevpTest.cs
│ │ ├── SumTest.cs
│ │ ├── VarTest.cs
│ │ └── VarpTest.cs
│ ├── StringExpressionTests.cs
│ ├── SubTest.cs
│ ├── ToBinTest.cs
│ ├── ToHexTest.cs
│ ├── ToNumberTest.cs
│ ├── ToOctTest.cs
│ ├── ToRationalTest.cs
│ ├── Trigonometric
│ │ ├── ArccosTest.cs
│ │ ├── ArccotTest.cs
│ │ ├── ArccscTest.cs
│ │ ├── ArcsecTest.cs
│ │ ├── ArcsinTest.cs
│ │ ├── ArctanTest.cs
│ │ ├── CosecantTest.cs
│ │ ├── CosineTest.cs
│ │ ├── CotangentTest.cs
│ │ ├── SecantTest.cs
│ │ ├── SineTest.cs
│ │ └── TangentTest.cs
│ ├── TruncTest.cs
│ ├── UnaryMinusTest.cs
│ ├── UnaryTest.cs
│ ├── UnassignTest.cs
│ ├── Units
│ │ ├── AngleUnits
│ │ │ ├── AngleTest.cs
│ │ │ ├── AngleUnitTest.cs
│ │ │ ├── AngleValueTest.cs
│ │ │ ├── ToDegreeTest.cs
│ │ │ ├── ToGradianTest.cs
│ │ │ └── ToRadianTest.cs
│ │ ├── AreaUnits
│ │ │ ├── AreaTest.cs
│ │ │ ├── AreaUnitTest.cs
│ │ │ └── AreaValueTest.cs
│ │ ├── ConvertTests.cs
│ │ ├── Converters
│ │ │ ├── AngleConverterTests.cs
│ │ │ ├── AreaConverterTests.cs
│ │ │ ├── ConverterTests.cs
│ │ │ ├── LengthConverterTests.cs
│ │ │ ├── MassConverterTests.cs
│ │ │ ├── PowerConverterTests.cs
│ │ │ ├── TemperatureConverterTests.cs
│ │ │ ├── TimeConverterTests.cs
│ │ │ └── VolumeConverterTests.cs
│ │ ├── LengthUnits
│ │ │ ├── LengthTest.cs
│ │ │ ├── LengthUnitTest.cs
│ │ │ └── LengthValueTest.cs
│ │ ├── MassUnits
│ │ │ ├── MassTest.cs
│ │ │ ├── MassUnitTest.cs
│ │ │ └── MassValueTest.cs
│ │ ├── PowerUnits
│ │ │ ├── PowerTest.cs
│ │ │ ├── PowerUnitTests.cs
│ │ │ └── PowerValueTest.cs
│ │ ├── TemperatureUnits
│ │ │ ├── TemperatureTest.cs
│ │ │ ├── TemperatureUnitTests.cs
│ │ │ └── TemperatureValueTest.cs
│ │ ├── TimeUnits
│ │ │ ├── TimeTest.cs
│ │ │ ├── TimeUnitTest.cs
│ │ │ └── TimeValueTest.cs
│ │ └── VolumeUnits
│ │ │ ├── VolumeTest.cs
│ │ │ ├── VolumeUnitTest.cs
│ │ │ └── VolumeValueTest.cs
│ └── VariableTest.cs
├── ParserTests
│ ├── AngleTests.cs
│ ├── AreaUnitTests.cs
│ ├── AssignTests.cs
│ ├── BaseParserTests.cs
│ ├── ComplexNumberTests.cs
│ ├── ConditionalOperatorTests.cs
│ ├── EqualityOperatorTests.cs
│ ├── ForTests.cs
│ ├── GCDTests.cs
│ ├── HyperbolicTests.cs
│ ├── IfTests.cs
│ ├── LambdaTests.cs
│ ├── LengthUnitTests.cs
│ ├── LogTests.cs
│ ├── LogicalOperatorTests.cs
│ ├── MassUnitTests.cs
│ ├── NotBalancedParenthesisTests.cs
│ ├── NumberTests.cs
│ ├── ParserTest.cs
│ ├── PowerTests.cs
│ ├── PowerUnitTests.cs
│ ├── RelationalOperatorTests.cs
│ ├── ReverseHyperbolicTests.cs
│ ├── ReverseTrigonometricTests.cs
│ ├── StringTests.cs
│ ├── TemperatureUnitTests.cs
│ ├── TimeUnitTests.cs
│ ├── TrigonometricTests.cs
│ ├── UnassignTests.cs
│ ├── UnitTests.cs
│ ├── VolumeUnitTests.cs
│ └── WhileTests.cs
├── ProcessorTest.cs
├── Results
│ ├── AngleResultTest.cs
│ ├── AreaResultTest.cs
│ ├── BooleanResultTest.cs
│ ├── ComplexNumberResultTest.cs
│ ├── LambdaResultTest.cs
│ ├── LengthResultTest.cs
│ ├── MassResultTest.cs
│ ├── MatrixResultTest.cs
│ ├── NumberResultTest.cs
│ ├── PowerResultTest.cs
│ ├── RationalResultTest.cs
│ ├── StringResultTest.cs
│ ├── TemperatureResultTest.cs
│ ├── TimeResultTest.cs
│ ├── VectorResultTest.cs
│ └── VolumeResultTest.cs
└── xFunc.Tests.csproj
├── xFunc.png
├── xFunc.ruleset
└── xFunc.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: DmytroKyshchenko
5 | # open_collective: # Replace with a single Open Collective username
6 | # ko_fi: # Replace with a single Ko-fi username
7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | # liberapay: # Replace with a single Liberapay username
10 | # issuehunt: # Replace with a single IssueHunt username
11 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | # polar: # Replace with a single Polar username
13 | # buy_me_a_coffee:
14 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1.
13 | 2.
14 | 3.
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Actual behavior**
20 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "nuget"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | target-branch: "dev"
8 | assignees:
9 | - "sys27"
10 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [ "dev", master ]
6 | pull_request:
7 | branches: [ "dev", master ]
8 | schedule:
9 | - cron: '44 18 * * 3'
10 |
11 | jobs:
12 | analyze:
13 | name: Analyze
14 | runs-on: ubuntu-latest
15 | permissions:
16 | actions: read
17 | contents: read
18 | security-events: write
19 |
20 | strategy:
21 | fail-fast: false
22 | matrix:
23 | include:
24 | - language: csharp
25 | build-mode: none
26 |
27 | steps:
28 | - name: Checkout repository
29 | uses: actions/checkout@v4
30 | with:
31 | fetch-depth: 0
32 |
33 | - name: Initialize CodeQL
34 | uses: github/codeql-action/init@v3
35 | with:
36 | languages: ${{ matrix.language }}
37 | build-mode: ${{ matrix.build-mode }}
38 |
39 | - name: Perform CodeQL Analysis
40 | uses: github/codeql-action/analyze@v3
41 | with:
42 | category: "/language:${{matrix.language}}"
43 |
--------------------------------------------------------------------------------
/.github/workflows/github-pages.yml:
--------------------------------------------------------------------------------
1 | name: Deploy static content to Pages
2 |
3 | on:
4 | push:
5 | branches: ["dev"]
6 |
7 | workflow_dispatch:
8 |
9 | permissions:
10 | contents: read
11 | pages: write
12 | id-token: write
13 |
14 | concurrency:
15 | group: "pages"
16 | cancel-in-progress: false
17 |
18 | jobs:
19 | deploy:
20 | environment:
21 | name: github-pages
22 | url: ${{ steps.deployment.outputs.page_url }}
23 | runs-on: ubuntu-latest
24 | steps:
25 | - name: Checkout
26 | uses: actions/checkout@v4
27 | with:
28 | fetch-depth: 0
29 |
30 | - uses: actions/setup-dotnet@v4
31 | with:
32 | dotnet-version: '9.0.x'
33 |
34 | - run: dotnet build -c Release xFunc.sln
35 | - run: dotnet tool update -g docfx
36 | - run: docfx docs/docfx.json
37 |
38 | - name: Setup Pages
39 | uses: actions/configure-pages@v3
40 |
41 | - name: Upload artifact
42 | uses: actions/upload-pages-artifact@v3
43 | with:
44 | path: './docs/_site/'
45 |
46 | - name: Deploy to GitHub Pages
47 | id: deployment
48 | uses: actions/deploy-pages@v4
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | [Bb]in/
2 | [Oo]bj/
3 | [Dd]ebug/
4 | [Rr]elease/
5 | TestResults
6 | packages
7 | .idea/
8 | .vs/
9 | BenchmarkDotNet.Artifacts/
10 |
11 | desktop.ini
12 | .DS_Store
13 |
14 | coverage
15 | coverage.xml
16 | coverage.cobertura.xml
17 |
18 | *.com
19 | *.dll
20 | *.exe
21 | *.pdb
22 | *.obj
23 |
24 | *.zip
25 | *.log
26 |
27 | *.mdf
28 | *.ldf
29 | *.suo
30 | *.vssscc
31 | *.vspscc
32 | *.psess
33 | *.vsp
34 | *.user
35 | *.nupkg
36 | *.nuspec
37 | *.diff
38 | *.design
39 | *.pfx
40 |
41 | [Pp]laylist\
42 | *.playlist
43 |
44 | Thumbs.db
--------------------------------------------------------------------------------
/.stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "xmlHeader": false,
6 | "companyName": "Dmytro Kyshchenko",
7 | "copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",
8 | "variables": {
9 | "licenseName": "MIT",
10 | "licenseFile": "LICENSE"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "xFunc.Benchmark",
6 | "type": "coreclr",
7 | "request": "launch",
8 | "preLaunchTask": "Build",
9 | "program": "${workspaceFolder}/xFunc.Benchmark/bin/Debug/net6.0/xFunc.Benchmark.dll",
10 | "args": [],
11 | "cwd": "${workspaceFolder}/xFunc.Benchmark",
12 | "console": "internalConsole",
13 | "stopAtEntry": false
14 | },
15 | {
16 | "name": "xFunc.DotnetTool",
17 | "type": "coreclr",
18 | "request": "launch",
19 | "preLaunchTask": "Build",
20 | "program": "${workspaceFolder}/xFunc.DotnetTool/bin/Debug/net6.0/xFunc.DotnetTool.dll",
21 | "args": [
22 | "interactive"
23 | ],
24 | "cwd": "${workspaceFolder}/xFunc.DotnetTool",
25 | "console": "integratedTerminal",
26 | "stopAtEntry": false
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/.git": true,
4 | "**/.svn": true,
5 | "**/.hg": true,
6 | "**/CVS": true,
7 | "**/.DS_Store": true,
8 | "**/.vs": true,
9 | "**/bin": true,
10 | "**/obj": true,
11 | "**/packages": true,
12 | "**/coverage": true,
13 | "**/.idea": true,
14 | "coverage.xml": true,
15 | "coverage.cobertura.xml": true,
16 | "xFunc": true,
17 | "desktop.ini": true
18 | },
19 | "dotnet.defaultSolution": "xFunc.sln"
20 | }
21 |
--------------------------------------------------------------------------------
/CI/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | precision: 2
3 | round: down
4 | range: "80...90"
5 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | *.* @sys27
2 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | <_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Directory.Packages.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright © 2012-2024 Dmytro Kyshchenko
3 |
4 | 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:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | 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.
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | | Version | Supported |
6 | | ------- | ------------------ |
7 | | 4.1.x | :white_check_mark: |
8 | | 4.0.x | :white_check_mark: |
9 | | < 4.0 | :x: |
10 |
11 | ## Reporting a Vulnerability
12 |
13 | All security issues can be reported publicly via the [GitHub Issues](https://github.com/sys27/xFunc/issues) page. You should receive a response within several days.
14 | If for some reason you do not, please ping the author again. :blush:
15 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # folder #
3 | ###############
4 | /**/DROP/
5 | /**/TEMP/
6 | /**/packages/
7 | /**/bin/
8 | /**/obj/
9 | _site
10 |
--------------------------------------------------------------------------------
/docs/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # temp file #
3 | ###############
4 | *.yml
5 | .manifest
6 |
--------------------------------------------------------------------------------
/docs/articles/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Get Started
2 | href: get-started.md
3 | - name: ChangeLog
4 | href: change-log.md
5 | - name: Breaking Changes
6 | href: breaking-changes.md
7 | - name: Performance comparison
8 | href: performance-comparison.md
9 | - name: Supported Function and Operators
10 | href: supported-functions-and-operations.md
11 | - name: Simplification rules
12 | href: simplification-rules.md
13 | - name: Advanced
14 | items:
15 | - name: How to build project
16 | href: how-to-build.md
17 | - name: How to implement own expression
18 | href: custom-expression.md
--------------------------------------------------------------------------------
/docs/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sys27/xFunc/ed48d73bad5d59adb8fbfb826e9432383fc0fbd6/docs/images/favicon.ico
--------------------------------------------------------------------------------
/docs/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sys27/xFunc/ed48d73bad5d59adb8fbfb826e9432383fc0fbd6/docs/images/logo.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ../README.md
--------------------------------------------------------------------------------
/docs/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Articles
2 | href: articles/
3 | - name: Api Documentation
4 | href: api/
5 | homepage: api/xFunc.Maths.Processor.yml
6 |
--------------------------------------------------------------------------------
/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "version": "4.5.0-preview.{height}",
4 | "assemblyVersion": {
5 | "precision": "revision"
6 | },
7 | "publicReleaseRefSpec": [
8 | "^refs/heads/master$",
9 | "^refs/heads/dev$"
10 | ],
11 | "nugetPackageVersion": {
12 | "semVer": 2
13 | },
14 | "cloudBuild": {
15 | "setVersionVariables": true,
16 | "buildNumber": {
17 | "enabled": true
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/CtorBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class CtorBenchmark
7 | {
8 | [Benchmark]
9 | public IParser ParserCtor()
10 | {
11 | return new Parser();
12 | }
13 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/DifferentiatorBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class DifferentiatorBenchmark
7 | {
8 | private Differentiator differentiator;
9 |
10 | private IExpression complexExp;
11 |
12 | [GlobalSetup]
13 | public void Setup()
14 | {
15 | differentiator = new Differentiator();
16 |
17 | var processor = new Processor();
18 |
19 | complexExp = processor.Parse("(2 * abs(3 * sin(4 * cos(5 * tan(6 * ctg(x ^ 2))))) - ln(x ^ 2)) + arcsin(arccos(arctan(arcctg(x ^ 10))))");
20 | }
21 |
22 | [Benchmark]
23 | public IExpression ComplexExpression()
24 | => complexExp.Analyze(differentiator, new DifferentiatorContext());
25 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/GcdBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class GcdBenchmark
7 | {
8 | private IExpression gcd;
9 | private IExpression lcm;
10 |
11 | [GlobalSetup]
12 | public void Setup()
13 | {
14 | var processor = new Processor();
15 |
16 | gcd = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
17 | lcm = processor.Parse("gcd(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
18 | }
19 |
20 | [Benchmark]
21 | public object GcdExecute() => gcd.Execute();
22 |
23 | [Benchmark]
24 | public object LcmExecute() => lcm.Execute();
25 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/MatrixBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Immutable;
5 |
6 | namespace xFunc.Benchmark.Benchmarks;
7 |
8 | public class MatrixBenchmark
9 | {
10 | private Matrix matrix1;
11 | private Matrix matrix2;
12 |
13 | [Params(2, 10, 100)]
14 | public int Size;
15 |
16 | [GlobalSetup]
17 | public void Setup()
18 | {
19 | matrix1 = CreateMatrix();
20 | matrix2 = CreateMatrix();
21 | }
22 |
23 | private Matrix CreateMatrix()
24 | {
25 | var vectors = ImmutableArray.CreateBuilder(Size);
26 | for (var i = 0; i < Size; i++)
27 | {
28 | var vector = ImmutableArray.CreateBuilder(Size);
29 | for (var j = 0; j < Size; j++)
30 | vector.Add(new Number(Random.Shared.Next()));
31 |
32 | vectors.Add(new Vector(vector.ToImmutableArray()));
33 | }
34 |
35 | return new Matrix(vectors.ToImmutableArray());
36 | }
37 |
38 | [Benchmark]
39 | public object AddMatrix()
40 | => new Add(matrix1, matrix2).Execute();
41 |
42 | [Benchmark]
43 | public object SubMatrix()
44 | => new Sub(matrix1, matrix2).Execute();
45 |
46 | [Benchmark]
47 | public object MulMatrix()
48 | => new Mul(matrix1, matrix2).Execute();
49 |
50 | [Benchmark]
51 | public object MulMatrixByNumber()
52 | => new Mul(matrix1, Number.Two).Execute();
53 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/ProcessorBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class ProcessorBenchmark
7 | {
8 | private Processor processor;
9 |
10 | [GlobalSetup]
11 | public void Setup()
12 | {
13 | processor = new Processor();
14 | }
15 |
16 | [Benchmark]
17 | public IExpression Parse()
18 | => processor.Parse("(100.1 + 2 * (3 * sin(4 * cos(5 * tan(6 * ctg(10 * x)))) * 3) / (func(a, b, c) ^ 2)) - (cos(y) - 111.3) & (true | false impl true eq false) + (det({{1, 2}, {3, 4}}) * 10 * log(2, 3)) + re(3 + 2 * i) - im(2 - 9 * i) + (9 + 2 * i)");
19 |
20 | [Benchmark]
21 | public Result Solve()
22 | => processor.Solve("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!");
23 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/SimplifierBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class SimplifierBenchmark
7 | {
8 | private Simplifier simplifier;
9 |
10 | private IExpression exp;
11 |
12 | [GlobalSetup]
13 | public void Setup()
14 | {
15 | simplifier = new Simplifier();
16 |
17 | var processor = new Processor();
18 |
19 | 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)");
20 | }
21 |
22 | [Benchmark]
23 | public IExpression Simplify()
24 | => exp.Analyze(simplifier);
25 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/StatisticalBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Benchmark.Benchmarks;
5 |
6 | public class StatisticalBenchmark
7 | {
8 | private IExpression stdev;
9 | private IExpression stdevp;
10 |
11 | private IExpression var;
12 | private IExpression varp;
13 |
14 | [GlobalSetup]
15 | public void Setup()
16 | {
17 | var processor = new Processor();
18 |
19 | stdev = processor.Parse("stdev(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
20 | stdevp = processor.Parse("stdevp(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
21 |
22 | var = processor.Parse("var(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
23 | varp = processor.Parse("varp(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)");
24 | }
25 |
26 | [Benchmark]
27 | public object StdevExecute() => stdev.Execute();
28 |
29 | [Benchmark]
30 | public object StdevpExecute() => stdevp.Execute();
31 |
32 | [Benchmark]
33 | public object VarExecute() => var.Execute();
34 |
35 | [Benchmark]
36 | public object VarpExecute() => varp.Execute();
37 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/TransposeBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Immutable;
5 |
6 | namespace xFunc.Benchmark.Benchmarks;
7 |
8 | public class TransposeBenchmark
9 | {
10 | private Transpose transpose;
11 |
12 | [ParamsSource(nameof(GetSizes))]
13 | public (int rows, int columns) Size;
14 |
15 | public IEnumerable<(int rows, int columns)> GetSizes()
16 | {
17 | yield return (2, 3);
18 | yield return (8, 10);
19 | }
20 |
21 | [GlobalSetup]
22 | public void Setup()
23 | {
24 | var matrix = CreateMatrix();
25 |
26 | transpose = new Transpose(matrix);
27 | }
28 |
29 | private Matrix CreateMatrix()
30 | {
31 | var vectors = ImmutableArray.CreateBuilder(Size.rows);
32 | for (var i = 0; i < Size.rows; i++)
33 | {
34 | var vector = ImmutableArray.CreateBuilder(Size.columns);
35 | for (var j = 0; j < Size.columns; j++)
36 | vector.Add(new Number(Random.Shared.Next()));
37 |
38 | vectors.Add(new Vector(vector.ToImmutableArray()));
39 | }
40 |
41 | return new Matrix(vectors.ToImmutableArray());
42 | }
43 |
44 | [Benchmark]
45 | public object TransposeMatrix() => transpose.Execute();
46 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Benchmarks/VectorBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Immutable;
5 | using xFunc.Maths.Expressions.Statistical;
6 |
7 | namespace xFunc.Benchmark.Benchmarks;
8 |
9 | public class VectorBenchmark
10 | {
11 | private Vector vector1;
12 | private Vector vector2;
13 |
14 | [Params(2, 10, 100)]
15 | public int Size;
16 |
17 | [GlobalSetup]
18 | public void Setup()
19 | {
20 | vector1 = CreateVector();
21 | vector2 = CreateVector();
22 | }
23 |
24 | private Vector CreateVector()
25 | {
26 | var vector = ImmutableArray.CreateBuilder(Size);
27 | for (var j = 0; j < Size; j++)
28 | vector.Add(new Number(Random.Shared.Next()));
29 |
30 | return new Vector(vector.ToImmutableArray());
31 | }
32 |
33 | [Benchmark]
34 | public object AbsVector()
35 | => new Abs(vector1).Execute();
36 |
37 | [Benchmark]
38 | public object AddVectors()
39 | => new Add(vector1, vector2).Execute();
40 |
41 | [Benchmark]
42 | public object SubVectors()
43 | => new Sub(vector1, vector2).Execute();
44 |
45 | [Benchmark]
46 | public object MulVectors()
47 | => new Mul(vector1, vector2).Execute();
48 |
49 | [Benchmark]
50 | public object MulVectorByNumber()
51 | => new Mul(vector1, Number.Two).Execute();
52 |
53 | [Benchmark]
54 | public object SumVector()
55 | => new Sum(new[] { vector1 }).Execute();
56 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using BenchmarkDotNet.Configs;
5 | using BenchmarkDotNet.Diagnosers;
6 | using BenchmarkDotNet.Jobs;
7 | using BenchmarkDotNet.Running;
8 | using BenchmarkDotNet.Toolchains.CsProj;
9 |
10 | namespace xFunc.Benchmark;
11 |
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | if (args is null || args.Length == 0)
17 | args = ["--filter", "*"];
18 |
19 | BenchmarkSwitcher
20 | .FromAssembly(typeof(Program).Assembly)
21 | .Run(args,
22 | ManualConfig.Create(DefaultConfig.Instance)
23 | .AddJob(Job.MediumRun
24 | .WithToolchain(CsProjCoreToolchain.NetCoreApp90))
25 | .AddDiagnoser(MemoryDiagnoser.Default)
26 | .StopOnFirstError());
27 | }
28 | }
--------------------------------------------------------------------------------
/xFunc.Benchmark/xFunc.Benchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | latest
7 | false
8 | enable
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/xFunc.Cli/Options/BaseOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | public abstract class BaseOptions : DebugInfoOptions
7 | {
8 | [Value(0, Required = true, MetaName = "String Expression", HelpText = "The string expression.")]
9 | public string StringExpression { get; set; }
10 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Options/DebugInfoOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | public abstract class DebugInfoOptions
7 | {
8 | [Option('d', "debug", Default = false, Required = false, HelpText = "Show stack trace.")]
9 | public bool Debug { get; set; }
10 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Options/InteractiveOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | [Verb("interactive", HelpText = "Run interactive mode.")]
7 | public class InteractiveOptions : DebugInfoOptions
8 | {
9 | [Usage(ApplicationAlias = "xfunc")]
10 | public static IEnumerable Examples
11 | => new List
12 | {
13 | new Example("Run iteractive mode", new InteractiveOptions())
14 | };
15 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Options/ParseOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | [Verb("parse", HelpText = "Parse string expression.")]
7 | public class ParseOptions : BaseOptions
8 | {
9 | [Usage(ApplicationAlias = "xfunc")]
10 | public static IEnumerable Examples
11 | => new List
12 | {
13 | new Example(
14 | "Parse string expression",
15 | new ParseOptions { StringExpression = "1 + 1" })
16 | };
17 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Options/RunFileOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | [Verb("run", HelpText = "Run all expressions from a file.")]
7 | public class RunFileOptions : DebugInfoOptions
8 | {
9 | [Value(0, Required = true, MetaName = "File", HelpText = "Path to a file.")]
10 | public string File { get; set; }
11 |
12 | [Usage(ApplicationAlias = "xfunc")]
13 | public static IEnumerable Examples
14 | => new List
15 | {
16 | new Example("Run all expressions from a file", new RunFileOptions { File = "./file.xf" })
17 | };
18 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Options/SolveOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Cli.Options;
5 |
6 | [Verb("solve", HelpText = "Calculate result of expression.")]
7 | public class SolveOptions : BaseOptions
8 | {
9 | [Usage(ApplicationAlias = "xfunc")]
10 | public static IEnumerable Examples
11 | => new List
12 | {
13 | new Example(
14 | "Calculate string expression",
15 | new SolveOptions { StringExpression = "1 + 1" }),
16 | };
17 | }
--------------------------------------------------------------------------------
/xFunc.Cli/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "xFunc.Cli": {
4 | "commandName": "Project",
5 | "commandLineArgs": "interactive"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Analyzers/DifferentiatorContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Analyzers;
5 |
6 | ///
7 | /// The context for differentiator.
8 | ///
9 | public class DifferentiatorContext
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | public DifferentiatorContext()
15 | : this(Variable.X)
16 | {
17 | }
18 |
19 | ///
20 | /// Initializes a new instance of the class.
21 | ///
22 | /// The variable.
23 | public DifferentiatorContext(Variable variable)
24 | => Variable = variable ?? throw new ArgumentNullException(nameof(variable));
25 |
26 | ///
27 | /// Gets the variable.
28 | ///
29 | public Variable Variable { get; }
30 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Analyzers/Formatters/IFormatter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Analyzers.Formatters;
5 |
6 | ///
7 | /// The common interface for expression formatters.
8 | ///
9 | ///
10 | public interface IFormatter : IAnalyzer;
--------------------------------------------------------------------------------
/xFunc.Maths/Analyzers/IDifferentiator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Analyzers;
5 |
6 | ///
7 | /// The interface for differentiator.
8 | ///
9 | public interface IDifferentiator : IAnalyzer;
--------------------------------------------------------------------------------
/xFunc.Maths/Analyzers/ISimplifier.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Analyzers;
5 |
6 | ///
7 | /// The interface for mathematical expression simplifier.
8 | ///
9 | public interface ISimplifier : IAnalyzer;
--------------------------------------------------------------------------------
/xFunc.Maths/Analyzers/TypeAnalyzers/ITypeAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Analyzers.TypeAnalyzers;
5 |
6 | ///
7 | /// Type Analyzer checks the expression tree for argument type and result type. If result type is Undefined, then Type Analyzer cannot determine the right type and bypass current expression.
8 | ///
9 | ///
10 | public interface ITypeAnalyzer : IAnalyzer;
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/EmptyValue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions;
5 |
6 | ///
7 | /// Represents the empty value (needed for functions that don't return any value).
8 | ///
9 | public sealed class EmptyValue
10 | {
11 | private EmptyValue()
12 | {
13 | }
14 |
15 | ///
16 | /// Gets the single instance of .
17 | ///
18 | public static EmptyValue Instance { get; } = new EmptyValue();
19 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/LogicalAndBitwise/Not.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.LogicalAndBitwise;
7 |
8 | ///
9 | /// Represents a bitwise NOT operator.
10 | ///
11 | public class Not : UnaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The argument of function.
17 | ///
18 | public Not(IExpression expression)
19 | : base(expression)
20 | {
21 | }
22 |
23 | ///
24 | public override object Execute(ExpressionParameters? parameters)
25 | {
26 | var arg = Argument.Execute(parameters);
27 |
28 | return arg switch
29 | {
30 | bool boolean => !boolean,
31 | NumberValue number => ~number,
32 | _ => throw ExecutionException.For(this),
33 | };
34 | }
35 |
36 | ///
37 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
38 | => analyzer.Analyze(this);
39 |
40 | ///
41 | [ExcludeFromCodeCoverage]
42 | protected override TResult AnalyzeInternal(
43 | IAnalyzer analyzer,
44 | TContext context)
45 | => analyzer.Analyze(this, context);
46 |
47 | ///
48 | public override IExpression Clone(IExpression? argument = null)
49 | => new Not(argument ?? Argument);
50 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Matrices/InvalidMatrixException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions.Matrices;
5 |
6 | ///
7 | /// Thrown in matrix building.
8 | ///
9 | [Serializable]
10 | public class InvalidMatrixException : Exception
11 | {
12 | ///
13 | /// Initializes a new instance of the class.
14 | ///
15 | public InvalidMatrixException()
16 | {
17 | }
18 |
19 | ///
20 | /// Initializes a new instance of the class.
21 | ///
22 | /// The message that describes the error.
23 | public InvalidMatrixException(string message)
24 | : base(message)
25 | {
26 | }
27 |
28 | ///
29 | /// Initializes a new instance of the class.
30 | ///
31 | /// A that describes the error.
32 | /// The exception that is the cause of the current exception.
33 | public InvalidMatrixException(string message, Exception inner)
34 | : base(message, inner)
35 | {
36 | }
37 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Parameters/ParameterType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions.Parameters;
5 |
6 | ///
7 | /// Contains types of parameter.
8 | ///
9 | public enum ParameterType
10 | {
11 | ///
12 | /// The normal parameter.
13 | ///
14 | Normal,
15 |
16 | ///
17 | /// The read-only parameter. It can be added/removed, but it can't be changed.
18 | ///
19 | ReadOnly,
20 |
21 | ///
22 | /// The constant parameter. It can be added, but can't be changed or removed.
23 | ///
24 | Constant,
25 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/AddAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the "+=" operator.
10 | ///
11 | public class AddAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public AddAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => variableValue + value;
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new AddAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/Dec.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the decrement operator.
10 | ///
11 | public class Dec : VariableUnaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | public Dec(Variable argument)
18 | : base(argument)
19 | {
20 | }
21 |
22 | ///
23 | protected override object Execute(NumberValue number) => number - 1;
24 |
25 | ///
26 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
27 | => analyzer.Analyze(this);
28 |
29 | ///
30 | [ExcludeFromCodeCoverage]
31 | protected override TResult AnalyzeInternal(
32 | IAnalyzer analyzer,
33 | TContext context)
34 | => analyzer.Analyze(this, context);
35 |
36 | ///
37 | public override IExpression Clone(Variable? variable = null)
38 | => new Dec(variable ?? Variable);
39 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/DivAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the "/=" operator.
10 | ///
11 | public class DivAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public DivAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => variableValue / value;
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new DivAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/Inc.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the increment operator.
10 | ///
11 | public class Inc : VariableUnaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | public Inc(Variable argument)
18 | : base(argument)
19 | {
20 | }
21 |
22 | ///
23 | protected override object Execute(NumberValue number) => number + 1;
24 |
25 | ///
26 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
27 | => analyzer.Analyze(this);
28 |
29 | ///
30 | [ExcludeFromCodeCoverage]
31 | protected override TResult AnalyzeInternal(
32 | IAnalyzer analyzer,
33 | TContext context)
34 | => analyzer.Analyze(this, context);
35 |
36 | ///
37 | public override IExpression Clone(Variable? variable = null)
38 | => new Inc(variable ?? Variable);
39 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/LeftShiftAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the '<<=' operator.
10 | ///
11 | public class LeftShiftAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public LeftShiftAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => NumberValue.LeftShift(variableValue, value);
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new LeftShiftAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/MulAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the "*=" operator.
10 | ///
11 | public class MulAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public MulAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => variableValue * value;
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new MulAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/RightShiftAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the '<<=' operator.
10 | ///
11 | public class RightShiftAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public RightShiftAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => NumberValue.RightShift(variableValue, value);
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new RightShiftAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Programming/SubAssign.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics.CodeAnalysis;
5 |
6 | namespace xFunc.Maths.Expressions.Programming;
7 |
8 | ///
9 | /// Represents the "-=" operator.
10 | ///
11 | public class SubAssign : VariableBinaryExpression
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The variable.
17 | /// The expression.
18 | public SubAssign(Variable variable, IExpression exp)
19 | : base(variable, exp)
20 | {
21 | }
22 |
23 | ///
24 | protected override object Execute(NumberValue variableValue, NumberValue value)
25 | => variableValue - value;
26 |
27 | ///
28 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
29 | => analyzer.Analyze(this);
30 |
31 | ///
32 | [ExcludeFromCodeCoverage]
33 | protected override TResult AnalyzeInternal(
34 | IAnalyzer analyzer,
35 | TContext context)
36 | => analyzer.Analyze(this, context);
37 |
38 | ///
39 | public override IExpression Clone(Variable? variable = null, IExpression? value = null)
40 | => new SubAssign(variable ?? Variable, value ?? Value);
41 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Units/AngleUnits/Angle.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions.Units.AngleUnits;
5 |
6 | ///
7 | /// Represents an angle number.
8 | ///
9 | public class Angle : Unit
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | /// An angle.
15 | public Angle(AngleValue value)
16 | : base(value)
17 | {
18 | }
19 |
20 | ///
21 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
22 | => analyzer.Analyze(this);
23 |
24 | ///
25 | protected override TResult AnalyzeInternal(
26 | IAnalyzer analyzer,
27 | TContext context)
28 | => analyzer.Analyze(this, context);
29 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Units/AreaUnits/Area.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions.Units.AreaUnits;
5 |
6 | ///
7 | /// Represents a area number.
8 | ///
9 | public class Area : Unit
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | /// A area value.
15 | public Area(AreaValue value)
16 | : base(value)
17 | {
18 | }
19 |
20 | ///
21 | protected override TResult AnalyzeInternal(IAnalyzer analyzer)
22 | => analyzer.Analyze(this);
23 |
24 | ///
25 | protected override TResult AnalyzeInternal(
26 | IAnalyzer analyzer,
27 | TContext context)
28 | => analyzer.Analyze(this, context);
29 | }
--------------------------------------------------------------------------------
/xFunc.Maths/Expressions/Units/Converters/AngleConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Dmytro Kyshchenko. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace xFunc.Maths.Expressions.Units.Converters;
5 |
6 | ///
7 | /// The angle unit converter.
8 | ///
9 | public class AngleConverter : IConverter, IConverter