Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Determinant.cs
1using System;
7
9{
14 {
24 {
25 }
26
30 public override string FunctionName => nameof(Determinant);
31
35 public override string[] Aliases => new string[] { "det" };
36
44 {
45 if (Argument is IMatrix M)
46 {
47 int N = M.Columns;
48 if (N != M.Rows)
49 throw new ScriptRuntimeException("Expected square matrix argument.", this);
50
51 IMatrix M2 = M.Reduce(false, true, out int Rank, out ICommutativeRingWithIdentityElement Factor);
52 if (M2 is null || Rank < N || Factor is null)
53 return Factor?.Zero ?? new DoubleNumber(0);
54 else
55 return Factor;
56 }
57 else
58 throw new ScriptRuntimeException("Expected matrix argument.", this);
59 }
60 }
61}
Class managing a script expression.
Definition: Expression.cs:39
override string FunctionName
Name of the function
Definition: Determinant.cs:30
override string[] Aliases
Optional aliases. If there are no aliases for the function, null is returned.
Definition: Determinant.cs:35
override IElement Evaluate(IElement Argument, Variables Variables)
Evaluates the function.
Definition: Determinant.cs:43
Determinant(ScriptNode Argument, int Start, int Length, Expression Expression)
Determinant(x)
Definition: Determinant.cs:22
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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of commutative ring with identity elements.
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for matrices.
Definition: IMatrix.cs:9
IMatrix Reduce(bool Eliminate, bool BreakIfZero, out int Rank, out ICommutativeRingWithIdentityElement Factor)
Reduces a matrix.