Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ObjectVectors.cs
1using System;
5
7{
11 public sealed class ObjectVectors : VectorSpace
12 {
13 private readonly ObjectVector referenceVector;
14 private readonly int dimension;
15
20 public ObjectVectors(ObjectVector ReferenceVector)
21 {
22 this.dimension = ReferenceVector.Dimension;
23 this.referenceVector = ReferenceVector;
24 }
25
29 public int Dimension => this.dimension;
30
34 public override IRing ScalarRing
35 {
36 get
37 {
38 if (!(this.scalarRing is null))
39 return this.scalarRing;
40
41 IElement Ref = null;
42 IElement Ref2 = null;
43 ISet Set = null;
44 ISet Set2;
45
46 foreach (IElement Element in this.referenceVector.Elements)
47 {
48 if (Set is null)
49 {
50 Ref = Element;
52 }
53 else
54 {
56 if (!Set.Equals(Set2))
57 {
58 if (!Expression.UpgradeField(ref Ref, ref Set, ref Ref2, ref Set2))
59 throw new ScriptException("No common scalar ring found.");
60 }
61 }
62 }
63
64 this.scalarRing = Set as IRing;
65 if (this.scalarRing is null)
66 throw new ScriptException("No common scalar ring found.");
67
68 return this.scalarRing;
69 }
70 }
71
72 private IRing scalarRing = null;
73
77 public override IField ScalarField
78 {
79 get
80 {
81 if (!(this.scalarField is null))
82 return this.scalarField;
83
84 this.scalarField = this.ScalarRing as IField;
85 if (this.scalarField is null)
86 throw new ScriptException("No common scalar field found.");
87
88 return this.scalarField;
89 }
90 }
91
92 private IField scalarField = null;
93
97 public override IAbelianGroupElement Zero
98 {
99 get
100 {
101 return this.ScalarRing.Zero;
102 }
103 }
104
110 public override bool Contains(IElement Element)
111 {
112 if (Element is ObjectVector v)
113 return v.Dimension == this.dimension;
114 else
115 return false;
116 }
117
123 public override bool Equals(object obj)
124 {
125 return (obj is ObjectVectors v && v.dimension == this.dimension);
126 }
127
132 public override int GetHashCode()
133 {
134 return this.dimension.GetHashCode();
135 }
136
137 }
138}
Base class for all types of elements.
Definition: Element.cs:13
abstract ISet AssociatedSet
Associated Set.
Definition: Element.cs:38
Element()
Base class for all types of elements.
Definition: Element.cs:17
Base class for all types of sets.
Definition: Set.cs:14
abstract override bool Equals(object obj)
Compares the element to another.
Base class for all types of vector spaces.
Definition: VectorSpace.cs:10
Base class for script exceptions.
Class managing a script expression.
Definition: Expression.cs:39
static bool UpgradeField(ref IElement E1, ref ISet Set1, ref IElement E2, ref ISet Set2)
Upgrades elements if necessary, to a common field extension, trying to make them compatible.
Definition: Expression.cs:5070
override int Dimension
Dimension of vector.
Pseudo-vector space of Object-valued vectors.
override bool Equals(object obj)
Compares the element to another.
ObjectVectors(ObjectVector ReferenceVector)
Pseudo-vector space of Object-valued vectors.
override int GetHashCode()
Calculates a hash code of the element.
override IField ScalarField
Scalar field.
override bool Contains(IElement Element)
Checks if the set contains an element.
override IAbelianGroupElement Zero
Returns the zero element of the group.
int Dimension
Dimension of vector space.
Basic interface for all types of abelian group elements.
Basic interface for all types of elements.
Definition: IElement.cs:20
IAbelianGroupElement Zero
Returns the zero element of the group.
Basic interface for all types of fields.
Definition: IField.cs:9
Basic interface for all types of rings.
Definition: IRing.cs:10
Basic interface for all types of sets.
Definition: ISet.cs:10