Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Pivot.cs
1using System;
6
8{
14 {
25 {
26 }
27
31 public override string FunctionName => nameof(Pivot);
32
36 public override string[] DefaultArgumentNames => new string[] { "Object" };
37
45 {
47 {
48 int Rows = M.Columns - 1;
49 int Columns = M.Rows + 1;
50 string[] Names = new string[Columns];
51 string[] Names0 = M.ColumnNames;
52 IElement[,] Elements = new IElement[Rows, Columns];
53 IElement[,] Elements0 = M.Values;
54 int Column, Row;
55
56 Names[0] = Names0[0];
57 for (Column = 1; Column < Columns; Column++)
58 Names[Column] = Elements0[Column - 1, 0].AssociatedObjectValue?.ToString();
59
60 for (Row = 0; Row < Rows; Row++)
61 Elements[Row, 0] = new StringValue(Names0[Row + 1]);
62
63 for (Column = 1; Column < Columns; Column++)
64 {
65 for (Row = 0; Row < Rows; Row++)
66 Elements[Row, Column] = Elements0[Column - 1, Row + 1];
67 }
68
69 return new ObjectMatrix(Elements)
70 {
71 ColumnNames = Names
72 };
73 }
74 else
75 return Argument.Transpose();
76 }
77
78 }
79}
Class managing a script expression.
Definition: Expression.cs:39
Base class for funcions of one matrix variable.
ScriptNode Argument
Function argument.
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
override string ToString()
Definition: ScriptNode.cs:359
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
bool HasColumnNames
If the matrix has column names defined.
Pivots a result matrix so columns become rows, and vice versa. It is similar to the matrix transpose ...
Definition: Pivot.cs:14
Pivot(ScriptNode Argument, int Start, int Length, Expression Expression)
Pivots a result matrix so columns become rows, and vice versa. It is similar to the matrix transpose ...
Definition: Pivot.cs:23
override IElement EvaluateMatrix(IMatrix Argument, Variables Variables)
Evaluates the function on a matrix argument.
Definition: Pivot.cs:44
override string FunctionName
Name of the function
Definition: Pivot.cs:31
override string[] DefaultArgumentNames
Default Argument names
Definition: Pivot.cs:36
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for matrices.
Definition: IMatrix.cs:9