Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AddElementWise.cs
1using System;
6
8{
13 {
23 : base(Left, Right, Start, Length, Expression)
24 {
25 }
26
35 {
36 if (Left.AssociatedObjectValue is double DL && Right.AssociatedObjectValue is double DR)
37 return new DoubleNumber(DL + DR);
38
39 if (Left is ISemiGroupElementWise LE && Right is ISemiGroupElementWise RE)
40 {
42 if (!(Result is null))
43 return Result;
44
45 Result = RE.AddLeftElementWise(LE);
46 if (!(Result is null))
47 return Result;
48 }
49
50 return Add.EvaluateAddition(Left, Right, this);
51 }
52
59 public ScriptNode Differentiate(string VariableName, Variables Variables)
60 {
61 if (this.left is IDifferentiable Left &&
62 this.right is IDifferentiable Right)
63 {
64 return new AddElementWise(
65 Left.Differentiate(VariableName, Variables),
66 Right.Differentiate(VariableName, Variables),
67 this.Start, this.Length, this.Expression);
68 }
69 else
70 throw new ScriptRuntimeException("Terms not differentiable.", this);
71 }
72
73 }
74}
Class managing a script expression.
Definition: Expression.cs:39
Base class for binary element-wise operators.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
AddElementWise(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Element-wise Addition operator.
override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
Evaluates the operator on scalar operands.
static IElement EvaluateAddition(IElement Left, IElement Right, ScriptNode Node)
Adds two operands.
Definition: Add.cs:67
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
Basic interface for all types of element-wise semigroup elements.
ISemiGroupElementWise AddRightElementWise(ISemiGroupElementWise Element)
Tries to add an element to the current element, from the right, element-wise.
ISemiGroupElementWise AddLeftElementWise(ISemiGroupElementWise Element)
Tries to add an element to the current element, from the left, element-wise.
Base interface for lambda expressions.