Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
zPowerBaseVariation.cs
1using System;
2using System.Numerics;
5
7{
12 {
16 public ZPowerBaseVariation(ScriptNode Parameter1, ScriptNode Parameter2, int Start, int Length, Expression Expression)
17 : base(Parameter1, Parameter2, Start, Length, Expression)
18 {
19 }
20
25 : base(Parameter1, null, Start, Length, Expression)
26 {
27 }
28
29 private ZPowerBaseVariation(Complex z, ScriptNode Parameter, int Start, int Length, Expression Expression)
30 : base(z, Parameter, Start, Length, Expression)
31 {
32 }
33
34 private ZPowerBaseVariation(double Re, double Im, ScriptNode Parameter1, ScriptNode Parameter2,
36 : base(Re, Im, Parameter1, Parameter2, Start, Length, Expression)
37 {
38 }
39
44 {
45 if (Arguments[1] is null || Arguments[1].AssociatedObjectValue is null)
46 return new ZPowerBaseVariation(Expression.ToComplex(Arguments[0].AssociatedObjectValue), this.Arguments[0], this.Start, this.Length, this.Expression);
47 else
48 {
49 return new ZPowerBaseVariation(Expression.ToDouble(Arguments[0].AssociatedObjectValue), Expression.ToDouble(Arguments[1].AssociatedObjectValue),
50 this.Arguments[0], this.Arguments[1], this.Start, this.Length, this.Expression);
51 }
52 }
53
57 public override void Operate(ref double x, ref double y)
58 {
59 // z^(x+iy)
60
61 double lnz = Math.Log(Math.Sqrt(this.re * this.re + this.im * this.im));
62 double argz = Math.Atan2(this.im, this.re);
63 double amp = Math.Exp(x * lnz - y * argz);
64 double phi = y * lnz + x * argz;
65
66 x = amp * Math.Cos(phi);
67 y = amp * Math.Sin(phi);
68 }
69
73 public override string FunctionName => nameof(ZPowerBaseVariation);
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
ZPowerBaseVariation(ScriptNode Parameter1, ScriptNode Parameter2, int Start, int Length, Expression Expression)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
ZPowerBaseVariation(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