Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CartesianProduct.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 LinkedList<IElement> Elements = new LinkedList<IElement>();
39 IEnumerator<IElement> e1 = Left.VectorElements.GetEnumerator();
40 IEnumerator<IElement> e2 = Right.VectorElements.GetEnumerator();
41 IElement v1;
42
43 while (e1.MoveNext())
44 {
45 v1 = e1.Current;
46 while (e2.MoveNext())
47 Elements.AddLast(VectorDefinition.Encapsulate(new IElement[] { v1, e2.Current }, false, this));
48
49 e2.Reset();
50 }
51
52 return VectorDefinition.Encapsulate(Elements, false, this);
53 }
54 }
55}
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
CartesianProduct(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Cartesian-product operator.
override IElement EvaluateVector(IVector Left, IVector Right, Variables Variables)
Evaluates the operator on vector operands.
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
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