Beispiel #1
0
 /// <summary>
 /// Obtém o complexo conjugado do número actual.
 /// </summary>
 /// <param name="group">O grupo responsável pelas operações.</param>
 /// <returns>O complexo conjugado do número actual.</returns>
 /// <exception cref="ArgumentNullException">Se o grupo for nulo.</exception>
 public ComplexNumber <ObjectType> Conjugate(IGroup <ObjectType> group)
 {
     if (group == null)
     {
         throw new ArgumentNullException("group");
     }
     else
     {
         var result = new ComplexNumber <ObjectType>();
         result.realPart      = this.realPart;
         result.imaginaryPart = group.AdditiveInverse(this.imaginaryPart);
         return(result);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Obtém a diferença entre a matriz corrente e outra matriz.
        /// </summary>
        /// <param name="right">A outra matriz.</param>
        /// <param name="group">O grupo.</param>
        /// <returns>O resultado da diferença.</returns>
        public ArrayMathMatrix <ObjectType> Subtract(ArrayMathMatrix <ObjectType> right, IGroup <ObjectType> group)
        {
            if (right == null)
            {
                throw new ArgumentNullException("right");
            }
            else if (group == null)
            {
                throw new ArgumentNullException("semigroup");
            }
            else
            {
                if (this.numberOfLines == right.numberOfLines &&
                    this.numberOfColumns == right.numberOfColumns)
                {
                    var result = new ArrayMathMatrix <ObjectType>(
                        this.numberOfLines,
                        this.numberOfColumns);
                    for (int i = 0; i < this.numberOfLines; ++i)
                    {
                        for (int j = 0; j < this.numberOfColumns; ++j)
                        {
                            result.elements[i][j] = group.Add(
                                this.elements[i][j],
                                group.AdditiveInverse(right.elements[i][j]));
                        }
                    }

                    return(result);
                }
                else
                {
                    throw new ArgumentException("Matrices don't have the same dimensions.");
                }
            }
        }