Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DotProduct.cs
5
7{
12 {
22 : base(Left, Right, Start, Length, Expression)
23 {
24 }
25
34 {
35 if (Left.Dimension != Right.Dimension)
36 throw new ScriptRuntimeException("Vectors of different dimensions.", this);
37
38 IEnumerator<IElement> e1 = Left.VectorElements.GetEnumerator();
39 IEnumerator<IElement> e2 = Right.VectorElements.GetEnumerator();
40 IElement Result = null;
41
42 try
43 {
44 while (e1.MoveNext() && e2.MoveNext())
45 {
46 if (Result is null)
47 Result = Arithmetics.Multiply.EvaluateMultiplication(e1.Current, e2.Current, this);
48 else
49 {
50 Result = Arithmetics.Add.EvaluateAddition(Result,
51 Arithmetics.Multiply.EvaluateMultiplication(e1.Current, e2.Current, this), this);
52 }
53 }
54
55 if (Result is null)
56 throw new ScriptRuntimeException("Cannot operate on zero-dimension vectors.", this);
57
58 return Result;
59 }
60 finally
61 {
62 e1.Dispose();
63 e2.Dispose();
64 }
65 }
66
67 }
68}
Class managing a script expression.
Definition: Expression.cs:41
Base class for binary vector operators.
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
DotProduct(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Dot-product operator.
Definition: DotProduct.cs:21
override IElement EvaluateVector(IVector Left, IVector Right, Variables Variables)
Evaluates the operator on vector operands.
Definition: DotProduct.cs:33
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21
Basic interface for vectors.
Definition: IVector.cs:9
ICollection< IElement > VectorElements
An enumeration of vector elements.
Definition: IVector.cs:22
int Dimension
Dimension of vector.
Definition: IVector.cs:14