Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DotProduct.cs
1using System.Collections.Generic;
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 while (e1.MoveNext() && e2.MoveNext())
43 {
44 if (Result is null)
45 Result = Arithmetics.Multiply.EvaluateMultiplication(e1.Current, e2.Current, this);
46 else
47 {
48 Result = Arithmetics.Add.EvaluateAddition(Result,
49 Arithmetics.Multiply.EvaluateMultiplication(e1.Current, e2.Current, this), this);
50 }
51 }
52
53 if (Result is null)
54 throw new ScriptRuntimeException("Cannot operate on zero-dimension vectors.", this);
55
56 return Result;
57 }
58
59 }
60}
Class managing a script expression.
Definition: Expression.cs:39
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:20
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