2using System.Collections.Generic;
4using System.Reflection;
5using System.Threading.Tasks;
75 Result = LE.MultiplyRight(RE);
76 if (!(Result is
null))
79 Result = RE.MultiplyLeft(LE);
80 if (!(Result is
null))
91 if (!LeftSet.Equals(RightSet))
97 if (!(LE is
null) && !(RE is
null))
99 Result = LE.MultiplyRight(RE);
100 if (!(Result is
null))
103 Result = RE.MultiplyLeft(LE);
104 if (!(Result is
null))
111 if (!(Result is
null))
116 if (LeftObj is
double D)
123 else if (LeftObj is BigInteger I)
133 if (RightObj is
double D2)
140 else if (RightObj is BigInteger I2)
152 LinkedList<IElement> Elements =
new LinkedList<IElement>();
164 LinkedList<IElement> Elements =
new LinkedList<IElement>();
176 if (LeftChildren.Count == RightChildren.Count)
178 LinkedList<IElement> Elements =
new LinkedList<IElement>();
179 IEnumerator<IElement> eLeft = LeftChildren.GetEnumerator();
180 IEnumerator<IElement> eRight = RightChildren.GetEnumerator();
184 while (eLeft.MoveNext() && eRight.MoveNext())
197 LinkedList<IElement> LeftResult =
new LinkedList<IElement>();
199 foreach (
IElement LeftChild
in LeftChildren)
201 LinkedList<IElement> RightResult =
new LinkedList<IElement>();
203 foreach (
IElement RightChild
in RightChildren)
206 LeftResult.AddLast(Right.
Encapsulate(RightResult, Node));
241 return Negate(Result, Node);
255 if (N != Math.Floor(N))
258 if (N <= long.MaxValue && N >=
long.MinValue)
270 if (Math.IEEERemainder(N, 2) != 0)
281 return Negate(Result, Node);
295 bool Sign = N.Sign < 0;
304 N = BigInteger.DivRem(N, two, out BigInteger Rem);
312 return Negate(Result, Node);
345 return Negate(Result, Node);
359 Type T = Value.GetType();
360 MethodInfo MI = T.GetRuntimeMethod(
"Negate",
Types.
NoTypes);
370 return E.AssociatedGroup.AdditiveIdentity;
376 Type T = Value.GetType();
377 PropertyInfo PI = T.GetRuntimeProperty(
"Zero");
381 FieldInfo FI = T.GetRuntimeField(
"Zero");
397 if (N != Math.Floor(N))
400 if (N <= long.MaxValue && N >=
long.MinValue)
412 if (Math.IEEERemainder(N, 2) != 0)
425 return Negate(Result, Node);
439 bool Sign = N.Sign < 0;
448 N = BigInteger.DivRem(N, two, out BigInteger Rem);
458 return Negate(Result, Node);
464 private static readonly BigInteger two =
new BigInteger(2);
484 Left.Differentiate(VariableName,
Variables),
489 Right.Differentiate(VariableName,
Variables),
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type[] NoTypes
Contains an empty array of types.
static object[] NoParameters
Contains an empty array of parameter values.
Base class for all types of elements.
abstract object AssociatedObjectValue
Associated object value.
Base class for all types of group elements.
Script runtime exception.
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
static bool UpgradeField(ref IElement E1, ref ISet Set1, ref IElement E2, ref ISet Set2)
Upgrades elements if necessary, to a common field extension, trying to make them compatible.
Base class for all binary operators.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
static IElement EvaluateNamedOperator(string Name, IElement Left, IElement Right, ScriptNode Node)
Evaluates a named operator available in code-behind.
bool isAsync
If subtree is asynchroneous.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
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 IElement EvaluateAddition(IElement Left, IElement Right, ScriptNode Node)
Adds two operands.
static IElement EvaluateMultiplication(IElement Left, IElement Right, ScriptNode Node)
Multiplies two operands.
static IElement EvaluateScalarMultiplication(BigInteger N, IGroupElement Element, ScriptNode Node)
Performs a scalar multiplication.
static IElement EvaluateScalarMultiplication(double N, IElement Element, ScriptNode Node)
Performs a scalar multiplication.
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
static IElement EvaluateScalarMultiplication(double N, IGroupElement Element, ScriptNode Node)
Performs a scalar multiplication.
Multiply(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Multiplication operator.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
static IElement EvaluateScalarMultiplication(long N, IElement Element, ScriptNode Node)
Performs a scalar multiplication.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
static IElement EvaluateScalarMultiplication(long N, IGroupElement Element, ScriptNode Node)
Performs a scalar multiplication.
static IElement EvaluateScalarMultiplication(BigInteger N, IElement Element, ScriptNode Node)
Performs a scalar multiplication.
Negate(ScriptNode Operand, int Start, int Length, Expression Expression)
Negation operator.
Basic interface for all types of abelian group 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.
ISet AssociatedSet
Associated Set.
bool IsScalar
If the element represents a scalar value.
Basic interface for all types of group elements.
Basic interface for all types of ring elements.
Basic interface for all types of semigroup elements.
ISemiGroupElement AddRight(ISemiGroupElement Element)
Tries to add an element to the current element, from the right.
Basic interface for all types of sets.
Base interface for lambda expressions.