Example #1
0
        /// <summary>
        /// Tries to add an element to the current element.
        /// </summary>
        /// <param name="Element">Element to add.</param>
        /// <returns>Result, if understood, null otherwise.</returns>
        public override IAbelianGroupElement Add(IAbelianGroupElement Element)
        {
            BooleanVector BooleanVector = Element as BooleanVector;

            if (BooleanVector is null)
            {
                return(null);
            }

            int i;

            if (BooleanVector.dimension != this.dimension)
            {
                return(null);
            }

            bool[] Values  = this.Values;
            bool[] Values2 = BooleanVector.Values;
            bool[] v       = new bool[this.dimension];
            for (i = 0; i < this.dimension; i++)
            {
                v[i] = Values[i] ^ Values2[i];
            }

            return(new BooleanVector(v));
        }
Example #2
0
        /// <summary>
        /// Compares the element to another.
        /// </summary>
        /// <param name="obj">Other element to compare against.</param>
        /// <returns>If elements are equal.</returns>
        public override bool Equals(object obj)
        {
            BooleanVector BooleanVector = obj as BooleanVector;

            if (BooleanVector is null)
            {
                return(false);
            }

            int i;

            if (BooleanVector.dimension != this.dimension)
            {
                return(false);
            }

            bool[] Values  = this.Values;
            bool[] Values2 = BooleanVector.Values;
            for (i = 0; i < this.dimension; i++)
            {
                if (Values[i] != Values2[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// Checks if the set contains an element.
        /// </summary>
        /// <param name="Element">Element.</param>
        /// <returns>If the element is contained in the set.</returns>
        public override bool Contains(IElement Element)
        {
            BooleanVector v = Element as BooleanVector;

            if (v == null)
            {
                return(false);
            }

            return(v.Dimension == this.dimension);
        }