Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DivideElementWise.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 else
39 return Divide.EvaluateDivision(Left, Right, this);
40 }
41
48 public ScriptNode Differentiate(string VariableName, Variables Variables)
49 {
50 if (this.left is IDifferentiable Left &&
51 this.right is IDifferentiable Right)
52 {
53 int Start = this.Start;
54 int Len = this.Length;
56
57 return new DivideElementWise(
58 new Subtract(
60 Left.Differentiate(VariableName, Variables),
61 this.right,
62 Start, Len, Expression),
64 this.left,
65 Right.Differentiate(VariableName, Variables),
66 Start, Len, Expression),
67 Start, Len, Expression),
69 this.right, this.right, Start, Len, Expression),
70 Start, Len, Expression);
71 }
72 else
73 throw new ScriptRuntimeException("Factors not differentiable.", this);
74 }
75
76 }
77}
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
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
DivideElementWise(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Element-wise Division operator.
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
Evaluates the operator on scalar operands.
static IElement EvaluateDivision(IElement Left, IElement Right, ScriptNode Node)
Divides the right operand from the left one.
Definition: Divide.cs:65
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
Base interface for lambda expressions.