Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ToMatrix.cs
1using System;
2using System.Collections.Generic;
6
8{
13 {
24 {
25 }
26
34 {
35 return this.ConvertToMatrix(Operand);
36 }
37
38 private IElement ConvertToMatrix(IElement Operand)
39 {
40 if (this.nullCheck && Operand.AssociatedObjectValue is null)
41 return Operand;
42
43 if (Operand is IMatrix)
44 return Operand;
45
46 if (Operand is IVector V)
47 return MatrixDefinition.Encapsulate(V.VectorElements, 1, V.Dimension, this);
48
49 if (Operand is ISet S)
50 {
51 ICollection<IElement> Elements = S.ChildElements;
52 return MatrixDefinition.Encapsulate(Elements, 1, Elements.Count, this);
53 }
54
55 if (Operand is IToMatrix ToMatrix)
56 return ToMatrix.ToMatrix();
57
58 if (Operand?.AssociatedObjectValue is IToMatrix ToMatrix2)
59 return ToMatrix2.ToMatrix();
60
61 return MatrixDefinition.Encapsulate(new IElement[] { Operand }, 1, 1, this);
62 }
63
70 public override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary<string, IElement> AlreadyFound)
71 {
72 return this.op.PatternMatch(this.ConvertToMatrix(CheckAgainst), AlreadyFound);
73 }
74 }
75}
Class managing a script expression.
Definition: Expression.cs:39
Base class for all unary operators performing operand null checks.
bool NullCheck
If null check is to be used.
readonly bool nullCheck
If null should be returned if operand is null.
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
virtual PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Definition: ScriptNode.cs:169
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
static IMatrix Encapsulate(ICollection< IElement > Rows, ScriptNode Node)
Encapsulates the elements of a matrix.
ToMatrix(ScriptNode Operand, bool NullCheck, int Start, int Length, Expression Expression)
To-Matrix operator.
Definition: ToMatrix.cs:22
override IElement Evaluate(IElement Operand, Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: ToMatrix.cs:33
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
Definition: ToMatrix.cs:70
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
ICollection< IElement > ChildElements
An enumeration of child elements. If the element is a scalar, this property will return null.
Definition: IElement.cs:49
IElement Encapsulate(ICollection< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.
Basic interface for matrices.
Definition: IMatrix.cs:9
Basic interface for vectors.
Definition: IVector.cs:9
Basic interface for all types of sets.
Definition: ISet.cs:10
PatternMatchResult
Status result of a pattern matching operation.
Definition: ScriptNode.cs:17