Package org.apache.commons.math.complex

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


                                                  boolean bitwiseComparisonNumbers, boolean bitwiseComparisonNaN) {

    assert x.length() == y.length();

    for(int i=0;i!=x.length();++i) {
      Complex xi = x.getElementAsComplex(i);
      Complex yi = y.getElementAsComplex(i);
      if(!equals(xi.getReal(), yi.getReal(), bitwiseComparisonNumbers, bitwiseComparisonNaN) ||
         !equals(xi.getImaginary(), yi.getImaginary(), bitwiseComparisonNumbers, bitwiseComparisonNaN)) {
        return false;
      }
    }
    return true;
  }
View Full Code Here


          if(vector.isElementNA(i)) {
            if(!removeNA) {
              return new ComplexArrayVector(ComplexVector.NA);
            }
          } else {
            Complex z = vector.getElementAsComplex(i);
            realSum += z.getReal();
            imaginarySum += z.getImaginary();
          }
        }

      } else {
        throw new EvalException("invalid 'type' (" + argument.getTypeName() + ") of argument");
      }
    }
    if(haveComplex) {
      return new ComplexArrayVector(new Complex(realSum, imaginarySum));

    } else if(haveDouble) {
      return new DoubleArrayVector(realSum);

    } else {
View Full Code Here

  @Generic
  @Builtin("as.complex")
  @DataParallel
  public static Complex asComplex(@Recycle double x) {
    return new Complex(x,0);
  }
View Full Code Here

  private void writeComplexVector(ComplexVector vector) throws IOException {
    writeFlags(SerializationFormat.CPLXSXP, vector);
    out.writeInt(vector.length());
    for(int i=0;i!=vector.length();++i) {
      Complex value = vector.getElementAsComplex(i);
      out.writeDouble(value.getReal());
      out.writeDouble(value.getImaginary());
    }
    writeAttributes(vector);
  }
View Full Code Here

    return Double.isNaN(value) ? IntVector.NA : (int) value;
  }

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

  /**
   * TODO ensure ordering of the two complex conjugates (if there are any)
   */
    @Override
    public int compareTo(ComplexEntry that) {
      Complex o1=this.z;
      Complex o2=that.z;
      if(o1.getImaginary()==0 && o2.getImaginary()!=0){
        return -1;
      }else if(o1.getImaginary()!=0 && o2.getImaginary()==0){
        return 1;
      }else{
        return (int)(ComplexGroup.Mod(o2)-ComplexGroup.Mod(o1));
      }
    }
View Full Code Here

     */
    public static Complex[] getEigenvectors(List<ComplexEntry> complexes){
      int n = complexes.size();
      Complex[] result = new Complex[n*n];
      for(int j=0; j<n; j++){
        Complex z = complexes.get(j).z;
        if(z.getImaginary()==0){
          // v(j) = VR(:,j)
          for(int index=0; index<n; index++){
            result[n*j+index]=complex(complexes.get(j).vector[index]);
          }
        }else if(j+1<n && isConjugate(z,complexes.get(j+1).z)){
View Full Code Here

import org.renjin.sexp.*;


public class RInternalDSL {
  public static Complex complex(double real) {
    return new Complex(real, 0);
  }
View Full Code Here

  public static Complex complex(double real) {
    return new Complex(real, 0);
  }
 
  public static Complex complex(double real, double imaginary) {
    return new Complex(real, imaginary);
  }
View Full Code Here

  @Builtin
  @Deferrable
  @DataParallel
  public static Complex round(Complex x, int digits) {
    return new Complex(round(x.getReal(), digits), round(x.getImaginary(), digits));
  }
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.