Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Cube.cs
1using System;
2using System.Collections.Generic;
7
9{
14 {
24 {
25 }
26
34 {
35 if (Operand.AssociatedObjectValue is double d)
36 return new DoubleNumber(d * d * d);
37
38 if (Operand is IRingElement E)
39 {
41 return Multiply.EvaluateMultiplication(E2, E, this);
42 }
43
44 if (Operand.IsScalar)
45 throw new ScriptRuntimeException("Scalar operands must be double values or ring elements.", this);
46
47 LinkedList<IElement> Result = new LinkedList<IElement>();
48
49 foreach (IElement Child in Operand.ChildElements)
50 Result.AddLast(this.Evaluate(Child, Variables));
51
52 return Operand.Encapsulate(Result, this);
53 }
54
61 public ScriptNode Differentiate(string VariableName, Variables Variables)
62 {
63 int Start = this.Start;
64 int Len = this.Length;
66
67 return this.DifferentiationChainRule(VariableName, Variables, this.op,
68 new Multiply(
70 new Square(this.op, Start, Len, Expression),
71 Start, Len, Expression));
72 }
73
74 }
75}
Class managing a script expression.
Definition: Expression.cs:39
Represents a constant element value.
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
ScriptNode DifferentiationChainRule(string VariableName, Variables Variables, ScriptNode Argument, ScriptNode Differentiation)
Implements the differentiation chain rule, by differentiating the argument and multiplying it to the ...
Definition: ScriptNode.cs:195
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
Base class for all unary operators.
static readonly DoubleNumber ThreeElement
3
Definition: DoubleNumber.cs:31
Cube(ScriptNode Operand, int Start, int Length, Expression Expression)
Cube operator.
Definition: Cube.cs:22
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
Definition: Cube.cs:61
override IElement Evaluate(IElement Operand, Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: Cube.cs:33
static IElement EvaluateMultiplication(IElement Left, IElement Right, ScriptNode Node)
Multiplies two operands.
Definition: Multiply.cs:69
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for all types of ring elements.
Definition: IRingElement.cs:10
Base interface for lambda expressions.