Inheritance: global::java.lang.Object, global::java.io.Serializable
Ejemplo n.º 1
0
        /**
         * Calculates the reciprocal of this complex number using the specified {@link MathContext}.
         *
         * <p>This methods <strong>does not</strong> modify this instance.</p>
         *
         * @param mathContext the {@link MathContext} used to calculate the result
         * @return the calculated {@link BigComplex} result
         */
        public BigComplex reciprocal(MathContext mathContext)
        {
            BigDecimal scale = absSquare(mathContext);

            return(valueOf(
                       re.divide(scale, mathContext),
                       im.negate().divide(scale, mathContext)));
        }
Ejemplo n.º 2
0
        /**
         * Returns a complex number with the specified polar {@link BigDecimal} radius and angle using the specified {@link MathContext}.
         *
         * @param radius the {@link BigDecimal} radius of the polar representation
         * @param angle the {@link BigDecimal} angle in radians of the polar representation
         * @param mathContext the {@link MathContext} used to calculate the result
         * @return the complex number
         */
        public static BigComplex valueOfPolar(BigDecimal radius, BigDecimal angle, MathContext mathContext)
        {
            if (radius.signum() == 0)
            {
                return(ZERO);
            }

            return(valueOf(
                       radius.multiply(BigDecimalMath.cos(angle, mathContext), mathContext),
                       radius.multiply(BigDecimalMath.sin(angle, mathContext), mathContext)));
        }
Ejemplo n.º 3
0
 public static BigComplex valueOfPolar(double radius, double angle, MathContext mathContext)
 {
     return(valueOfPolar(BigDecimal.valueOf(radius), BigDecimal.valueOf(angle), mathContext));
 }
Ejemplo n.º 4
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)));
 }
Ejemplo n.º 5
0
 /**
  * Returns this complex nuber rounded to the specified precision.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the rounded {@link BigComplex} result
  */
 public BigComplex round(MathContext mathContext)
 {
     return(valueOf(re.round(mathContext), im.round(mathContext)));
 }
Ejemplo n.º 6
0
 /**
  * Calculates the square of the absolute value of this complex number.
  *
  * <p>This method is faster than {@link #abs(MathContext)} since it does not need to calculate the {@link BigDecimalMath#sqrt(BigDecimal, MathContext)}.</p>
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  * @see #abs(MathContext)
  */
 public BigDecimal absSquare(MathContext mathContext)
 {
     return(re.multiply(re, mathContext).add(im.multiply(im, mathContext), mathContext));
 }
Ejemplo n.º 7
0
 /**
  * Calculates the angle in radians (also known as argument) of this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigDecimal angle(MathContext mathContext)
 {
     return(BigDecimalMath.atan2(im, re, mathContext));
 }
Ejemplo n.º 8
0
 /**
  * Calculates the subtraction of the given real {@link BigDecimal} value from this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the real {@link BigDecimal} value to add
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex subtract(BigDecimal value, MathContext mathContext)
 {
     return(valueOf(
                re.subtract(value, mathContext),
                im));
 }
Ejemplo n.º 9
0
 /**
  * Calculates this complex number divided by the given real {@link BigDecimal} value using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigDecimal} value to divide by
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex divide(BigDecimal value, MathContext mathContext)
 {
     return(valueOf(
                re.divide(value, mathContext),
                im.divide(value, mathContext)));
 }
Ejemplo n.º 10
0
 /**
  * Calculates this complex number divided by the given real {@code double} value using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@code double} value to divide by
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex divide(double value, MathContext mathContext)
 {
     return(divide(BigDecimal.valueOf(value), mathContext));
 }
Ejemplo n.º 11
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));
 }
Ejemplo n.º 12
0
 /**
  * Calculates the multiplication of the given real {@link BigDecimal} value with this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the real {@link BigDecimal} value to multiply
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex multiply(BigDecimal value, MathContext mathContext)
 {
     return(valueOf(
                re.multiply(value, mathContext),
                im.multiply(value, mathContext)));
 }
Ejemplo n.º 13
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)));
 }
Ejemplo n.º 14
0
 /**
  * Calculates the addition of the given real {@link BigDecimal} value to this complex number using the specified {@link MathContext}.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the real {@link BigDecimal} value to add
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex add(BigDecimal value, MathContext mathContext)
 {
     return(valueOf(
                re.add(value, mathContext),
                im));
 }
Ejemplo n.º 15
0
 /**
  * Calculates the absolute value (also known as magnitude, length or radius) of this complex number.
  *
  * <p>This method is slower than {@link #absSquare(MathContext)} since it needs to calculate the {@link BigDecimalMath#sqrt(BigDecimal, MathContext)}.</p>
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param mathContext the {@link MathContext} used to calculate the result
  * @return the calculated {@link BigComplex} result
  * @see #absSquare(MathContext)
  */
 public BigDecimal abs(MathContext mathContext)
 {
     return(BigDecimalMath.sqrt(absSquare(mathContext), mathContext));
 }
Ejemplo n.º 16
0
 /**
  * Returns this rational number as a {@link BigDecimal} with the precision specified by the {@link MathContext}.
  *
  * @param mc the {@link MathContext} specifying the precision of the calculated result
  * @return the {@link BigDecimal}
  */
 public BigDecimal toBigDecimal(MathContext mc)
 {
     return(numerator.divide(denominator, mc));
 }
Ejemplo n.º 17
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)));
 }