Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Log2.cs
1using System;
2using System.Numerics;
7
9{
14 {
24 {
25 }
26
30 public override string FunctionName => nameof(log2);
31
39 {
40 return new DoubleNumber(Math.Log(Argument) / log2);
41 }
42
49 public ScriptNode Differentiate(string VariableName, Variables Variables)
50 {
51 if (VariableName == this.DefaultVariableName)
52 {
53 int Start = this.Start;
54 int Len = this.Length;
56
57 return this.DifferentiationChainRule(VariableName, Variables, this.Argument,
58 new Invert(
59 new Multiply(
60 this.Argument,
61 new ConstantElement(new DoubleNumber(log2), Start, Len, Exp),
62 Start, Len, Exp),
63 Start, Len, Exp));
64 }
65 else
66 return new ConstantElement(DoubleNumber.ZeroElement, this.Start, this.Length, this.Expression);
67 }
68
69 private static readonly double log2 = Math.Log(2);
70
78 {
79 return new ComplexNumber(Complex.Log(Argument) / log2);
80 }
81 }
82}
Class managing a script expression.
Definition: Expression.cs:39
Log2(ScriptNode Argument, int Start, int Length, Expression Expression)
Log2(x)
Definition: Log2.cs:22
ScriptNode Differentiate(string VariableName, Variables Variables)
Differentiates a script node, if possible.
Definition: Log2.cs:49
override IElement EvaluateScalar(double Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Log2.cs:38
override string FunctionName
Name of the function
Definition: Log2.cs:30
override IElement EvaluateScalar(Complex Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Log2.cs:77
Represents a constant element value.
Base class for funcions of one scalar variable.
ScriptNode Argument
Function argument.
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
static readonly DoubleNumber ZeroElement
0
Definition: DoubleNumber.cs:16
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Base interface for lambda expressions.
string DefaultVariableName
Default variable name, if any, null otherwise.