Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Ones.cs
1using System;
6
8{
13 {
22 public Ones(ScriptNode Rows, ScriptNode Columns, int Start, int Length, Expression Expression)
23 : base(Rows, Columns, Start, Length, Expression)
24 {
25 }
26
30 public override string FunctionName => nameof(Ones);
31
35 public override string[] DefaultArgumentNames => new string[] { "Rows", "Columns" };
36
40 public override bool UpgradeScalarsToSameSet => true;
41
50 {
51 int Rows = (int)Argument1;
52 if (Rows != Argument1 || Rows <= 0)
53 throw new ScriptRuntimeException("Rows must be a positive integer.", this);
54
55 int Columns = (int)Argument2;
56 if (Columns != Argument2 || Columns <= 0)
57 throw new ScriptRuntimeException("Columns must be a positive integer.", this);
58
59 double[,] E = new double[Rows, Columns];
60 int i, j;
61
62 for (i = 0; i < Rows; i++)
63 {
64 for (j = 0; j < Columns; j++)
65 E[i, j] = 1;
66 }
67
68 return new DoubleMatrix(E);
69 }
70 }
71}
Class managing a script expression.
Definition: Expression.cs:41
Creates a matrix containing only ones.
Definition: Ones.cs:13
override string[] DefaultArgumentNames
Default Argument names
Definition: Ones.cs:35
override bool UpgradeScalarsToSameSet
If scalars should be upgraded to the same set before evaluation.
Definition: Ones.cs:40
override string FunctionName
Name of the function
Definition: Ones.cs:30
Ones(ScriptNode Rows, ScriptNode Columns, int Start, int Length, Expression Expression)
Creates a matrix containing only ones.
Definition: Ones.cs:22
override IElement EvaluateScalar(double Argument1, double Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: Ones.cs:49
Base class for funcions of two scalar variables.
ScriptNode Argument2
Function argument 2.
ScriptNode Argument1
Function argument 1.
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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21