Exemplo n.º 1
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)
        {
            ComplexVector ComplexVector = obj as ComplexVector;

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

            int i;

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

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

            return(true);
        }
Exemplo n.º 2
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)
        {
            ComplexVector ComplexVector = Element as ComplexVector;

            if (ComplexVector == null)
            {
                return(null);
            }

            int i;

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

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

            return(new ComplexVector(v));
        }
Exemplo n.º 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)
        {
            ComplexVector v = Element as ComplexVector;

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

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