Exemple #1
0
 @Override
 public IComplexNumber exp() {
   IComplexNumber result = dup();
   double realExp = FastMath.exp(realComponent());
   return result.set(
       realExp * FastMath.cos(imaginaryComponent()), realExp * FastMath.sin(imaginaryComponent()));
 }
Exemple #2
0
 @Override
 public IComplexNumber powi(IComplexNumber c, IComplexNumber result) {
   IComplexNumber eval = log().muli(c).exp();
   result.set(eval.realComponent(), eval.imaginaryComponent());
   result.set(eval.realComponent(), eval.imaginaryComponent());
   return result;
 }
Exemple #3
0
 @Override
 public IComplexNumber divi(Number v, IComplexNumber result) {
   if (this == result) {
     set(real() / v.doubleValue(), imag());
   } else {
     result.set(result.realComponent().doubleValue() / v.doubleValue(), imaginaryComponent());
   }
   return result;
 }
Exemple #4
0
 /**
  * Multiply two complex numbers, inplace
  *
  * @param c
  * @param result
  */
 @Override
 public IComplexNumber muli(IComplexNumber c, IComplexNumber result) {
   double newR =
       (real() * c.realComponent().doubleValue() - imag() * c.imaginaryComponent().doubleValue());
   double newI =
       (real() * c.imaginaryComponent().doubleValue() + imag() * c.realComponent().doubleValue());
   result.set(newR, newI);
   return result;
 }
Exemple #5
0
 @Override
 public IComplexNumber rdivi(Number v, IComplexNumber result) {
   float d =
       result.realComponent().floatValue() * result.realComponent().floatValue()
           + result.imaginaryComponent().floatValue() * result.imaginaryComponent().floatValue();
   return result.set(
       v.floatValue() * result.realComponent().floatValue() / d,
       -v.floatValue() * result.imaginaryComponent().floatValue() / d);
 }
Exemple #6
0
 /**
  * Multiply two complex numbers, inplace
  *
  * @param c
  * @param result
  */
 @Override
 public IComplexNumber muli(IComplexNumber c, IComplexNumber result) {
   float newR =
       real() * c.realComponent().floatValue() - imag() * c.imaginaryComponent().floatValue();
   float newI =
       real() * c.imaginaryComponent().floatValue() + imag() * c.realComponent().floatValue();
   result.set(newR, newI);
   return result;
 }
Exemple #7
0
 @Override
 public IComplexNumber log() {
   IComplexNumber result = dup();
   float real = (float) result.realComponent();
   float imaginary = (float) result.imaginaryComponent();
   double modulus = FastMath.sqrt(real * real + imaginary * imaginary);
   double arg = FastMath.atan2(imaginary, real);
   return result.set(FastMath.log(modulus), arg);
 }
Exemple #8
0
 /**
  * Subtract two complex numbers, in-place
  *
  * @param c
  * @param result
  */
 @Override
 public IComplexNumber subi(IComplexNumber c, IComplexNumber result) {
   if (this == result) {
     set(real() - c.realComponent().doubleValue(), imag() - c.imaginaryComponent().doubleValue());
   } else {
     result.set(
         result.realComponent().doubleValue() - c.realComponent().doubleValue(),
         result.imaginaryComponent().doubleValue() - c.imaginaryComponent().doubleValue());
   }
   return this;
 }
Exemple #9
0
 /**
  * Divide two complex numbers, in-place
  *
  * @param c
  * @param result
  */
 @Override
 public IComplexNumber divi(IComplexNumber c, IComplexNumber result) {
   float d =
       c.realComponent().floatValue() * c.realComponent().floatValue()
           + c.imaginaryComponent().floatValue() * c.imaginaryComponent().floatValue();
   float newR =
       (real() * c.realComponent().floatValue() + imag() * c.imaginaryComponent().floatValue())
           / d;
   float newI =
       (imag() * c.realComponent().floatValue() - real() * c.imaginaryComponent().floatValue())
           / d;
   result.set(newR, newI);
   return result;
 }
Exemple #10
0
 @Override
 public IComplexNumber rsubi(Number a, IComplexNumber result) {
   return result.set(a.doubleValue() - realComponent().doubleValue(), imaginaryComponent());
 }
Exemple #11
0
 @Override
 public IComplexNumber copy(IComplexNumber other) {
   return other.set(this);
 }
Exemple #12
0
 @Override
 public IComplexNumber rsubi(IComplexNumber a, IComplexNumber result) {
   return result.set(a.sub(this));
 }
Exemple #13
0
 @Override
 public IComplexNumber subi(Number a, IComplexNumber result) {
   return result.set(
       result.realComponent().floatValue() - a.floatValue(),
       result.imaginaryComponent().floatValue());
 }
Exemple #14
0
 @Override
 public IComplexNumber divi(Number v, IComplexNumber result) {
   return result.set(
       result.realComponent().floatValue() / v.floatValue(),
       imaginaryComponent() / v.floatValue());
 }
Exemple #15
0
 @Override
 public IComplexNumber rdivi(IComplexNumber c, IComplexNumber result) {
   return result.set(c.div(this));
 }
Exemple #16
0
 @Override
 public IComplexNumber rdivi(Number v, IComplexNumber result) {
   return result.set(v.doubleValue() / real(), imaginaryComponent());
 }
Exemple #17
0
 /**
  * Add two complex numbers in-place
  *
  * @param c
  * @param result
  */
 @Override
 public IComplexNumber addi(IComplexNumber c, IComplexNumber result) {
   return result.set(
       result.realComponent().floatValue() + c.realComponent().floatValue(),
       result.imaginaryComponent().floatValue() + c.imaginaryComponent().floatValue());
 }