Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Diagonal.cs
1using System;
6
8{
13 {
23 {
24 }
25
29 public override string FunctionName => nameof(Diagonal);
30
34 public override string[] Aliases => new string[] { "diag" };
35
43 {
44 if (Argument is IMatrix M)
45 {
46 int N = Math.Min(M.Columns, M.Rows);
47 IElement[] Elements = new IElement[N];
48 int i;
49
50 for (i = 0; i < N; i++)
51 Elements[i] = M.GetElement(i, i);
52
53 return VectorDefinition.Encapsulate(Elements, false, this);
54 }
55 else
56 throw new ScriptRuntimeException("Expected matrix argument.", this);
57 }
58 }
59}
Class managing a script expression.
Definition: Expression.cs:39
override string[] Aliases
Optional aliases. If there are no aliases for the function, null is returned.
Definition: Diagonal.cs:34
Diagonal(ScriptNode Argument, int Start, int Length, Expression Expression)
Diagonal(x)
Definition: Diagonal.cs:21
override string FunctionName
Name of the function
Definition: Diagonal.cs:29
override IElement Evaluate(IElement Argument, Variables Variables)
Evaluates the function.
Definition: Diagonal.cs:42
Base class for funcions of one 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
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
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 matrices.
Definition: IMatrix.cs:9