Exemplo n.º 1
0
        /**
         * Returns whether the real and imaginary parts of this complex number are strictly equal.
         *
         * <p>This method uses the strict equality as defined by {@link BigDecimal#equals(Object)} on the real and imaginary parts.</p>
         * <p>Please note that {@link #equals(Object) BigComplex.equals(Object)} implements <strong>mathematical</strong> equality instead
         * (by calling {@link BigDecimal#compareTo(BigDecimal) on the real and imaginary parts}).</p>
         *
         * @param obj the object to compare for strict equality
         * @return {@code true} if the specified object is strictly equal to this complex number
         * @see #equals(Object)
         */
        public Boolean strictEquals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            BigComplex other = (BigComplex)obj;

            return(re.equals(other.re) && im.equals(other.im));
        }
Exemplo n.º 2
0
        /**
         * {@inheritDoc}
         *
         * <p>Contrary to {@link BigDecimal#equals(Object)} this method implements <strong>mathematical</strong> equality
         * (by calling {@link BigDecimal#compareTo(BigDecimal)} on the real and imaginary parts)
         * instead of strict equality.</p>
         *
         * @see #strictEquals(Object)
         */
        public Boolean equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            BigComplex other = (BigComplex)obj;

            return(re.compareTo(other.re) == 0 && im.compareTo(other.im) == 0);
        }
Exemplo n.º 3
0
 /**
  * Calculates the addition of the given complex value to this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to add
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex add(BigComplex value, MathContext mathContext)
 {
     return(valueOf(
                re.add(value.re, mathContext),
                im.add(value.im, mathContext)));
 }
Exemplo n.º 4
0
 /**
  * Calculates the addition of the given complex value to this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to add
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex add(BigComplex value)
 {
     return(valueOf(
                re.add(value.re),
                im.add(value.im)));
 }
Exemplo n.º 5
0
 /**
  * Calculates this complex number divided by the given complex value using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to divide by
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex divide(BigComplex value, MathContext mathContext)
 {
     return(multiply(value.reciprocal(mathContext), mathContext));
 }
Exemplo n.º 6
0
 /**
  * Calculates the multiplication of the given complex value with this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to multiply
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex multiply(BigComplex value, MathContext mathContext)
 {
     return(valueOf(
                re.multiply(value.re, mathContext).subtract(im.multiply(value.im, mathContext), mathContext),
                re.multiply(value.im, mathContext).add(im.multiply(value.re, mathContext), mathContext)));
 }
Exemplo n.º 7
0
 /**
  * Calculates the multiplication of the given complex value to this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to multiply
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex multiply(BigComplex value)
 {
     return(valueOf(
                re.multiply(value.re).subtract(im.multiply(value.im)),
                re.multiply(value.im).add(im.multiply(value.re))));
 }
Exemplo n.º 8
0
 /**
  * Calculates the subtraction of the given complex value from this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to subtract
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex subtract(BigComplex value, MathContext mathContext)
 {
     return(valueOf(
                re.subtract(value.re, mathContext),
                im.subtract(value.im, mathContext)));
 }
Exemplo n.º 9
0
 /**
  * Calculates the subtraction of the given complex value from this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to subtract
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex subtract(BigComplex value)
 {
     return(valueOf(
                re.subtract(value.re),
                im.subtract(value.im)));
 }