Package org.apache.commons.math.complex

Examples of org.apache.commons.math.complex.Complex


  private static ComplexVector toComplex(double[] array) {
    int n = array.length / 2;
    ComplexArrayVector.Builder result = new ComplexArrayVector.Builder(0, n);
    for(int i=0;i!=n;++i) {
      result.add(new Complex(array[i*2], array[i*2+1]));
    }
    return result.build();
  }
View Full Code Here


    }
  }
 
  @Override
  public Complex getElementAsComplex(int index) {
    return new Complex(getElementAsDouble(index), 0);
  }
View Full Code Here

  }
 
  @Builtin("-")
  @DataParallel(PreserveAttributeStyle.ALL)
  public static Complex negative(Complex x) {
    return new Complex(-x.getReal(), -x.getImaginary());
  }
View Full Code Here

        double rd = convertInf(d);
        x = 0.0 * (a * rc + b * rd);
        y = 0.0 * (b * rc - a * rd);
      }
    }
    return new Complex(x, y);
  }
View Full Code Here

      if (recalc) {
        real = Double.POSITIVE_INFINITY * (ra * rc - rb * rd);
        imag = Double.POSITIVE_INFINITY * (ra * rd + rb * rc);
      }
    }
    return new Complex(real, imag);
  }
View Full Code Here

  public static Complex power(Complex x, Complex y) {
    // handle common cases with better precision than the log(exp(x)*y) trick used by Apache Commons
    if(y.getImaginary() == 0) {
      double yr = y.getReal();
      if(yr == 0) {
        return new Complex(1, 0);
      } else if (yr == 1) {
        return x;
      } else {
        int k = (int)yr;
        if(k == yr && k < 65536) {
View Full Code Here

   */
  private static Complex power(Complex x, int k) {
    if(k < 0) {
      return reciprocal(power(x, -k));
    } else {
      Complex result = new Complex(1, 0);
      while(k > 0) {
        result = multiply(result, x);
        k--;
      }
      return result;
View Full Code Here

        double rd = convertInf(d);
        x = 0.0 * rc;
        y = 0.0 * (-rd);
      }
    }
    return new Complex(x, y);
  }
View Full Code Here

  private SEXP readComplexExp(int flags) throws IOException {
    int length = in.readInt();
    Complex[] values = new Complex[length];
    for(int i=0;i!=length;++i) {
      values[i] = new Complex(in.readDouble(), in.readDouble());
    }
    return new ComplexArrayVector(values, readAttributes(flags));
  }
View Full Code Here

    return new IntArrayVector(getElementAsInt(index));
  }

  @Override
  public Complex getElementAsComplex(int index) {
    return new Complex(getElementAsDouble(index), 0);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.complex.Complex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.