Inheritance: global::java.lang.Object, global::java.io.Serializable
Beispiel #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)));
        }
Beispiel #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)));
        }
Beispiel #3
0
 public static BigComplex valueOfPolar(double radius, double angle, MathContext mathContext)
 {
     return(valueOfPolar(BigDecimal.valueOf(radius), BigDecimal.valueOf(angle), mathContext));
 }
Beispiel #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)));
 }
Beispiel #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)));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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)));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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)));
 }
Beispiel #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)));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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)));
 }