Ejemplo n.º 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()));
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 10
0
 @Override
 public IComplexNumber rsubi(Number a, IComplexNumber result) {
   return result.set(a.doubleValue() - realComponent().doubleValue(), imaginaryComponent());
 }
Ejemplo n.º 11
0
 @Override
 public IComplexNumber copy(IComplexNumber other) {
   return other.set(this);
 }
Ejemplo n.º 12
0
 @Override
 public IComplexNumber rsubi(IComplexNumber a, IComplexNumber result) {
   return result.set(a.sub(this));
 }
Ejemplo n.º 13
0
 @Override
 public IComplexNumber subi(Number a, IComplexNumber result) {
   return result.set(
       result.realComponent().floatValue() - a.floatValue(),
       result.imaginaryComponent().floatValue());
 }
Ejemplo n.º 14
0
 @Override
 public IComplexNumber divi(Number v, IComplexNumber result) {
   return result.set(
       result.realComponent().floatValue() / v.floatValue(),
       imaginaryComponent() / v.floatValue());
 }
Ejemplo n.º 15
0
 @Override
 public IComplexNumber rdivi(IComplexNumber c, IComplexNumber result) {
   return result.set(c.div(this));
 }
Ejemplo n.º 16
0
 @Override
 public IComplexNumber rdivi(Number v, IComplexNumber result) {
   return result.set(v.doubleValue() / real(), imaginaryComponent());
 }
Ejemplo n.º 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());
 }