Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
zDivVariation.cs
1using System.Numerics;
4
6{
11 {
15 public ZDivVariation(ScriptNode Parameter1, ScriptNode Parameter2, int Start, int Length, Expression Expression)
16 : base(Parameter1, Parameter2, Start, Length, Expression)
17 {
18 }
19
24 : base(Parameter1, null, Start, Length, Expression)
25 {
26 }
27
31 private ZDivVariation(Complex z, ScriptNode Parameter, int Start, int Length, Expression Expression)
32 : base(z, Parameter, Start, Length, Expression)
33 {
34 }
35
36 private ZDivVariation(double Re, double Im, ScriptNode Parameter1, ScriptNode Parameter2,
38 : base(Re, Im, Parameter1, Parameter2, Start, Length, Expression)
39 {
40 }
41
46 {
47 if (Arguments[1] is null || Arguments[1].AssociatedObjectValue is null)
48 return new ZDivVariation(Expression.ToComplex(Arguments[0].AssociatedObjectValue), this.Arguments[0], this.Start, this.Length, this.Expression);
49 else
50 {
51 return new ZDivVariation(Expression.ToDouble(Arguments[0].AssociatedObjectValue),
52 Expression.ToDouble(Arguments[1].AssociatedObjectValue),
53 this.Arguments[0], this.Arguments[1], this.Start, this.Length, this.Expression);
54 }
55 }
56
60 public override void Operate(ref double x, ref double y)
61 {
62 // z/(x+iy)=(re+iim)*(x-iy)/(x^2+y^2)=(re*x+im*y)/r^2+i*(im*x-re*y)/r^2
63
64 double r = x * x + y * y + 1e-6;
65 double x2 = (x * this.re + y * this.im) / r;
66 y = this.im * x - this.re * y;
67 x = x2;
68 }
69
73 public override string FunctionName => nameof(ZDivVariation);
74 }
75}
Class managing a script expression.
Definition: Expression.cs:39
static Complex ToComplex(object Object)
Converts an object to a complex value.
Definition: Expression.cs:4942
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:4824
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override void Operate(ref double x, ref double y)
TODO
ZDivVariation(ScriptNode Parameter1, ScriptNode Parameter2, int Start, int Length, Expression Expression)
TODO
ZDivVariation(ScriptNode Parameter1, int Start, int Length, Expression Expression)
TODO
ScriptNode[] Arguments
Function arguments.
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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20