|
AngouriMath
|
Namespaces |
Classes | |
| class | AngouriMathException |
| class | Entity |
| class | EntityEvaluationExtension |
| struct | ErrorCode |
| struct | HandleDeleter |
| class | InnerEvalZeroedSinCosConditions |
| class | InternalAMExtensions |
| This is a set of extensions for internal use. | |
| class | MathS |
| Use functions from this class More... | |
Typedefs | |
| using | NumericsComplex = System.Numerics.Complex |
| using | GenTensor = GenericTensor.Core.GenTensor< Entity, Entity.Matrix.EntityTensorWrapperOperations > |
| using | SortLevel = Functions.TreeAnalyzer.SortLevel |
Enumerations | |
| enum | ApproachFrom : std::int32_t { BothSides = 0, Left = 1, Right = 2 } |
Functions | |||||
| abstract Entity | Replace (Func< Entity, Entity > func) | ||||
| Applies the given function to every node starting from the leaves More... | |||||
| virtual Entity | Substitute (Entity x, Entity value) | ||||
Replaces all
| |||||
| Entity | Substitute ((Entity x1, Entity x2) x,(Entity v1, Entity v2) value) | ||||
| Replaces x.x1 with value.v1 and x.x2 with value.v2 More... | |||||
| Entity | Substitute ((Entity x1, Entity x2, Entity x3) x,(Entity v1, Entity v2, Entity v3) value) | ||||
| Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 More... | |||||
| Entity | Substitute ((Entity x1, Entity x2, Entity x3, Entity x4) x,(Entity v1, Entity v2, Entity v3, Entity v4) value) | ||||
| Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 and x.x4 with value.v4 More... | |||||
| Entity | Substitute< TFrom, TTo > (IReadOnlyDictionary< TFrom, TTo > replacements) | ||||
Replaces all
| |||||
| bool | ContainsNode (Entity x) | ||||
| Checks if x is a subnode inside this Entity tree. More... | |||||
| abstract IEnumerable< Entity > | InvertNode (Entity value, Entity x) | ||||
| Use Invert(Entity, Entity) instead which auto-simplifies value More... | |||||
| Entity | Sinh (const Entity &arg0) | ||||
| Entity | Sinh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cosh (const Entity &arg0) | ||||
| Entity | Cosh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Tanh (const Entity &arg0) | ||||
| Entity | Tanh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cotanh (const Entity &arg0) | ||||
| Entity | Cotanh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Sech (const Entity &arg0) | ||||
| Entity | Sech (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cosech (const Entity &arg0) | ||||
| Entity | Cosech (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arsinh (const Entity &arg0) | ||||
| Entity | Arsinh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arcosh (const Entity &arg0) | ||||
| Entity | Arcosh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Artanh (const Entity &arg0) | ||||
| Entity | Artanh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arcotanh (const Entity &arg0) | ||||
| Entity | Arcotanh (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arsech (const Entity &arg0) | ||||
| Entity | Arsech (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arcosech (const Entity &arg0) | ||||
| Entity | Arcosech (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Sin (const Entity &arg0) | ||||
| Entity | Sin (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cos (const Entity &arg0) | ||||
| Entity | Cos (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Sec (const Entity &arg0) | ||||
| Entity | Sec (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cosec (const Entity &arg0) | ||||
| Entity | Cosec (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Log (const Entity &arg0, const Entity &arg1) | ||||
| Entity | Log (const Entity &arg0, const Entity &arg1, ErrorCode &e) | ||||
| Entity | Pow (const Entity &arg0, const Entity &arg1) | ||||
| Entity | Pow (const Entity &arg0, const Entity &arg1, ErrorCode &e) | ||||
| Entity | Sqrt (const Entity &arg0) | ||||
| Entity | Sqrt (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cbrt (const Entity &arg0) | ||||
| Entity | Cbrt (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Sqr (const Entity &arg0) | ||||
| Entity | Sqr (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Tan (const Entity &arg0) | ||||
| Entity | Tan (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Cotan (const Entity &arg0) | ||||
| Entity | Cotan (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arcsin (const Entity &arg0) | ||||
| Entity | Arcsin (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arccos (const Entity &arg0) | ||||
| Entity | Arccos (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arctan (const Entity &arg0) | ||||
| Entity | Arctan (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arccotan (const Entity &arg0) | ||||
| Entity | Arccotan (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arcsec (const Entity &arg0) | ||||
| Entity | Arcsec (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Arccosec (const Entity &arg0) | ||||
| Entity | Arccosec (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Ln (const Entity &arg0) | ||||
| Entity | Ln (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Factorial (const Entity &arg0) | ||||
| Entity | Factorial (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Gamma (const Entity &arg0) | ||||
| Entity | Gamma (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Signum (const Entity &arg0) | ||||
| Entity | Signum (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Abs (const Entity &arg0) | ||||
| Entity | Abs (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Negation (const Entity &arg0) | ||||
| Entity | Negation (const Entity &arg0, ErrorCode &e) | ||||
| Entity | Provided (const Entity &arg0, const Entity &arg1) | ||||
| Entity | Provided (const Entity &arg0, const Entity &arg1, ErrorCode &e) | ||||
| Entity | CreateByHandle (Internal::EntityRef handle) | ||||
| Internal::EntityRef | ParseString (const char *expr) | ||||
| Internal::EntityRef | GetHandle (const Entity &e) | ||||
| std::ostream & | operator<< (std::ostream &out, const AngouriMath::Entity &e) | ||||
Variables | |
| IReadOnlyList< Entity > | DirectChildren => directChildren.GetValue(static @this => @this.InitDirectChildren(), this) |
| Represents all direct children of a node More... | |
| IEnumerable< Entity > | Nodes => nodes.GetValue(static @this => @this.DirectChildren.SelectMany(c => c.Nodes).Prepend(@this), this) |
| The list of all subnodes of the given expression, including its own. More... | |
| bool | IsFinite => isFinite.GetValue(static @this => @this.ThisIsFinite && @this.DirectChildren.All(x => x.IsFinite), this) |
| Whether both parts of the complex number are finite meaning that it could be safely used for calculations. More... | |
| virtual bool | ThisIsFinite => true |
| Not NaN and not infinity More... | |
| int | Complexity => complexity.GetValue(static @this => 1 + @this.DirectChildren.Sum(x => x.Complexity), this) |
| Number of nodes in tree More... | |
| IReadOnlyList< Variable > | Vars |
Set of unique variables, for example it extracts , from (x + 2 * goose) - pi * x More... | |
| IReadOnlyCollection< Variable > | VarsAndConsts |
Set of unique variables, for example it extracts , , from (x + 2 * goose) - pi * x More... | |
| IReadOnlyCollection< Variable > | FreeVariables |
| Returns a set of free variables. More... | |
| double | SimplifiedRate => simplifiedRate.GetValue(MathS.Settings.ComplexityCriteria.Value, this) |
| Shows how simple the given expression is. More... | |
| bool | IsSymbolic => Vars.Any() |
| Checks whether the given expression contains variable More... | |
| bool | IsConstantLeaf => this is Boolean or Number or Set.SpecialSet |
| Checks whether the given expression is a finite constant leaf More... | |
| bool | IsNaN => this == Real.NaN |
| Checks whether this entity represents the undefined value (MathS.NaN). More... | |
| partial record | x => throw new AngouriBugException("This function must contain " + nameof(x)) |
| partial record | v |
| partial record MathS.Settings. | NewtonSolver |
| bool AngouriMath.ContainsNode | ( | Entity | x | ) |
Checks if x is a subnode inside this Entity tree.
Optimized for Variable.
Prints
|
protectedpure virtual |
Use Invert(Entity, Entity) instead which auto-simplifies value
Applies the given function to every node starting from the leaves
| func | The delegate that takes the current node as an argument and replaces the current node with the result of the delegate |
Prints
Replaces all
| x | with
|
Prints
Replaces x.x1 with value.v1 and x.x2 with value.v2
See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.
| Entity AngouriMath.Substitute | ( | (Entity x1, Entity x2, Entity x3) | x, |
| (Entity v1, Entity v2, Entity v3) | value | ||
| ) |
Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3
See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.
Prints
| Entity AngouriMath.Substitute | ( | (Entity x1, Entity x2, Entity x3, Entity x4) | x, |
| (Entity v1, Entity v2, Entity v3, Entity v4) | value | ||
| ) |
Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 and x.x4 with value.v4
See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.
Prints
| Entity AngouriMath.Substitute< TFrom, TTo > | ( | IReadOnlyDictionary< TFrom, TTo > | replacements | ) |
Replaces all
| replacements |
See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.
Prints
| TFrom | : | Entity | |
| TTo | : | Entity |
| int AngouriMath.Complexity => complexity.GetValue(static @this => 1 + @this.DirectChildren.Sum(x => x.Complexity), this) |
Number of nodes in tree
using System; using static AngouriMath.MathS;
var (x, y) = Var("x", "y"); var expr1 = x; Console.WriteLine($"{expr1}: {expr1.Complexity}"); var expr2 = x * 2; Console.WriteLine($"{expr2}: {expr2.Complexity}"); var expr3 = Sin(x); Console.WriteLine($"{expr3}: {expr3.Complexity}"); var expr4 = Sin(x) + Cos(x + 2); Console.WriteLine($"{expr4}: {expr4.Complexity}"); Prints x: 1 x * 2: 3 sin(x): 2 sin(x) + cos(x + 2): 7
| IReadOnlyList<Entity> AngouriMath.DirectChildren => directChildren.GetValue(static @this => @this.InitDirectChildren(), this) |
Represents all direct children of a node
Prints
| IReadOnlyCollection<Variable> AngouriMath.FreeVariables |
Returns a set of free variables.
We call a bound variable a variable which is a parameter of some outer lambda. Then, all other variables are free.
Prints
| bool AngouriMath.IsConstantLeaf => this is Boolean or Number or Set.SpecialSet |
Checks whether the given expression is a finite constant leaf
Prints
| bool AngouriMath.IsFinite => isFinite.GetValue(static @this => @this.ThisIsFinite && @this.DirectChildren.All(x => x.IsFinite), this) |
Whether both parts of the complex number are finite meaning that it could be safely used for calculations.
By finite we mean that it is not a MathS.NaN and it is not positive or negative infinity.
Prints
| bool AngouriMath.IsNaN => this == Real.NaN |
Checks whether this entity represents the undefined value (MathS.NaN).
| bool AngouriMath.IsSymbolic => Vars.Any() |
Checks whether the given expression contains variable
Prints
| IEnumerable<Entity> AngouriMath.Nodes => nodes.GetValue(static @this => @this.DirectChildren.SelectMany(c => c.Nodes).Prepend(@this), this) |
The list of all subnodes of the given expression, including its own.
A depth-first enumeration is required by AngouriMath.Functions.TreeAnalyzer.GetMinimumSubtree
Traverses the tree the following order:
Output:
| double AngouriMath.SimplifiedRate => simplifiedRate.GetValue(MathS.Settings.ComplexityCriteria.Value, this) |
Shows how simple the given expression is.
The lower - the simpler the expression is. You might need it to pick the best expression to represent something. Unlike Complexity, which shows the number of nodes, SimplifiedRate shows how convenient it is to view the expression. This depends on MathS.Settings.ComplexityCriteria which can be changed by user. See MathS.Settings.ComplexityCriteria for more details.
|
protected |
Not NaN and not infinity
| IReadOnlyList<Variable> AngouriMath.Vars |
Set of unique variables, for example it extracts , x from goose(x + 2 * goose) - pi * x
Prints
| IReadOnlyCollection<Variable> AngouriMath.VarsAndConsts |
Set of unique variables, for example it extracts , x, goose from pi(x + 2 * goose) - pi * x
Prints
1.8.13