2using System.Collections.Generic;
3using System.Threading.Tasks;
75 if (DR >=
long.MinValue && DR <=
long.MaxValue && Math.Truncate(DR) == DR)
125 LinkedList<IElement> Elements =
new LinkedList<IElement>();
137 LinkedList<IElement> Elements =
new LinkedList<IElement>();
149 if (LeftChildren.Count == RightChildren.Count)
151 LinkedList<IElement> Elements =
new LinkedList<IElement>();
152 IEnumerator<IElement> eLeft = LeftChildren.GetEnumerator();
153 IEnumerator<IElement> eRight = RightChildren.GetEnumerator();
157 while (eLeft.MoveNext() && eRight.MoveNext())
158 Elements.AddLast(
EvaluatePower(eLeft.Current, eRight.Current, Node));
170 LinkedList<IElement> LeftResult =
new LinkedList<IElement>();
172 foreach (
IElement LeftChild
in LeftChildren)
174 LinkedList<IElement> RightResult =
new LinkedList<IElement>();
176 foreach (
IElement RightChild
in RightChildren)
177 RightResult.AddLast(
EvaluatePower(LeftChild, RightChild, Node));
179 LeftResult.AddLast(Right.
Encapsulate(RightResult, Node));
213 return Left.Differentiate(VariableName,
Variables);
240 Left.Differentiate(VariableName,
Variables),
244 Right.Differentiate(VariableName,
Variables),
Script runtime exception.
Class managing a script expression.
Base class for all binary operators.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
bool isAsync
If subtree is asynchroneous.
Represents a constant element value.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
ScriptNode DifferentiationChainRule(string VariableName, Variables Variables, ScriptNode Argument, ScriptNode Differentiation)
Implements the differentiation chain rule, by differentiating the argument and multiplying it to the ...
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
abstract IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
static readonly DoubleNumber OneElement
1
static readonly DoubleNumber TwoElement
2
static IElement EvaluateMultiplication(IElement Left, IElement Right, ScriptNode Node)
Multiplies two operands.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Power(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Power operator.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
static IElement EvaluatePower(IElement Left, IElement Right, ScriptNode Node)
Calculates Left ^ Right.
static IElement EvaluateSubtraction(IElement Left, IElement Right, ScriptNode Node)
Subtracts the right operand from the left one.
Basic interface for all types of commutative ring with identity elements.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
ICollection< IElement > ChildElements
An enumeration of child elements. If the element is a scalar, this property will return null.
IElement Encapsulate(ICollection< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.
bool IsScalar
If the element represents a scalar value.
Basic interface for all types of ring elements.
Base interface for lambda expressions.