Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PhysicalQuantities.cs
1using System;
6
8{
12 public sealed class PhysicalQuantities : Field, IOrderedSet
13 {
14 private static readonly int hashCode = typeof(PhysicalQuantities).FullName.GetHashCode();
15
20 {
21 }
22
27 {
28 get { return PhysicalQuantity.OneElement; }
29 }
30
34 public override IAbelianGroupElement Zero
35 {
36 get { return PhysicalQuantity.ZeroElement; }
37 }
38
44 public override bool Contains(IElement Element)
45 {
46 return Element is PhysicalQuantity;
47 }
48
50 public override bool Equals(object obj)
51 {
52 return obj is PhysicalQuantities;
53 }
54
56 public override int GetHashCode()
57 {
58 return hashCode;
59 }
60
67 public int Compare(IElement x, IElement y)
68 {
71
72 if (Unit.TryConvert(d2.Magnitude, d2.Unit, d1.Unit, out double Magnitude2))
73 return d1.Magnitude.CompareTo(Magnitude2);
74 else
75 throw new ScriptException("Incompatible units.");
76 }
77 }
78}
Base class for all types of elements.
Definition: Element.cs:13
Base class for all types of fields.
Definition: Field.cs:10
Base class for script exceptions.
Pseudo-field of physical quantities.
PhysicalQuantities()
Pseudo-field of physical quantities.
override ICommutativeRingWithIdentityElement One
Returns the identity element of the commutative ring with identity.
override int GetHashCode()
Calculates a hash code of the element. Hash code.
override IAbelianGroupElement Zero
Returns the zero element of the group.
override bool Equals(object obj)
Compares the element to another. If elements are equal.
override bool Contains(IElement Element)
Checks if the set contains an element.
int Compare(IElement x, IElement y)
Compares two double values.
static readonly PhysicalQuantity ZeroElement
0
static readonly PhysicalQuantity OneElement
1
Represents a unit.
Definition: Unit.cs:15
static bool TryConvert(double From, Unit FromUnit, Unit ToUnit, out double To)
Tries to convert a magnitude in one unit to a magnitude in another.
Definition: Unit.cs:1201
Basic interface for all types of abelian group elements.
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 ordered sets.
Definition: IOrderedSet.cs:11