Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BooleanMatrices.cs
1using System;
4
6{
10 public sealed class BooleanMatrices : Ring
11 {
12 private BooleanMatrix zero = null;
13 private readonly int rows;
14 private readonly int columns;
15
21 public BooleanMatrices(int Rows, int Columns)
22 {
23 this.rows = Rows;
24 this.columns = Columns;
25 }
26
30 public int Rows => this.rows;
31
35 public int Columns => this.columns;
36
40 public override IAbelianGroupElement Zero
41 {
42 get
43 {
44 if (this.zero is null)
45 this.zero = new BooleanMatrix(new bool[this.rows, this.columns]);
46
47 return this.zero;
48 }
49 }
50
54 public override bool IsCommutative
55 {
56 get { return this.columns == 1 && this.rows == 1; }
57 }
58
64 public override bool Contains(IElement Element)
65 {
66 if (Element is BooleanMatrix M)
67 return M.Rows == this.rows && M.Columns == this.columns;
68 else
69 return false;
70 }
71
77 public override bool Equals(object obj)
78 {
79 return (obj is BooleanMatrices S && S.rows == this.rows && S.columns == this.columns);
80 }
81
86 public override int GetHashCode()
87 {
88 return this.rows.GetHashCode() ^ (this.columns.GetHashCode() << 16);
89 }
90
91 }
92}
Base class for all types of elements.
Definition: Element.cs:13
Base class for all types of rings.
Definition: Ring.cs:9
Pseudo-ring of Boolean-valued matrices.
override int GetHashCode()
Calculates a hash code of the element.
override bool Contains(IElement Element)
Checks if the set contains an element.
override bool Equals(object obj)
Compares the element to another.
override bool IsCommutative
If the ring * operator is commutative or not.
override IAbelianGroupElement Zero
Returns the zero element of the group.
BooleanMatrices(int Rows, int Columns)
Pseudo-ring of Boolean-valued matrices.
Basic interface for all types of abelian group elements.
Basic interface for all types of elements.
Definition: IElement.cs:20