Package com.nr

Examples of com.nr.Complex


  @Test
  public void test() {
    int i,N=20,M=100;
    double err,errmax,sbeps;
    Complex aa,bb,cc,zz,res1,res2;
    Complex a[]={new Complex(1.0,0.0), new Complex(0.0,1.0),new Complex(1.0,0.0),new Complex(1.0,0.0),
      new Complex(1.0,0.0),new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(1.0,0.0),new Complex(0.0,1.0),new Complex(1.0,0.0),new Complex(1.0,0.0),
      new Complex(5.0,0.0),new Complex(0.0,3.0),new Complex(0.0,-4.0),new Complex(-5.0,0.0)};
    Complex b[]={new Complex(1.0,0.0),new Complex(1.0,0.0),new Complex(0.0,1.0),new Complex(1.0,0.0),
      new Complex(1.0,0.0),new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(1.0,0.0),new Complex(0.0,1.0),new Complex(0.0,1.0),new Complex(1.0,0.0),
      new Complex(0.0,5.0),new Complex(2.0,0.0),new Complex(0.0,-1.0),new Complex(3.0,0.0)};
    Complex c[]={new Complex(1.0,0.0),new Complex(1.0,0.0),new Complex(1.0,0.0),new Complex(0.0,1.0),
      new Complex(1.0,0.0),new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(2.0,0.0),new Complex(3.0,0.0),new Complex(3.0,0.0),new Complex(2.0,0.0),
      new Complex(1.0,0.0),new Complex(0.0,1.0),new Complex(1.0,0.0),new Complex(0.0,1.0),
      new Complex(0.0,-2.0),new Complex(0.0,-2.0),new Complex(7.0,0.0),new Complex(0.0,7.0)};  
    Complex z[]={new Complex(0.5,0.0),new Complex(0.5,0.0),new Complex(0.5,0.0),new Complex(0.5,0.0),
      new Complex(0.0,1.0),new Complex(0.0,1.0),new Complex(0.0,1.0),new Complex(0.0,0.0),
      new Complex(0.5,0.0),new Complex(0.5,0.0),new Complex(-0.5,0.0),new Complex(-0.5,0.0),
      new Complex(-0.5,0.0),new Complex(0.0,1.0),new Complex(1.0,1.0),new Complex(1.0,1.0),
      new Complex(1.0,1.0),new Complex(1.0,3.0),new Complex(2.0,-3.0),new Complex(5.0,7.0)};
    Complex eexpect[]={new Complex(2.0,0.0),
      new Complex(0.76923890136397212658,0.63896127631363480115),
      new Complex(0.76923890136397212658,0.63896127631363480115),
      new Complex(0.18874993960184887345,-0.73280804956611519935),
      new Complex(0.5,0.5),new Complex(0.0,0.5),new Complex(-0.25,0.25),
      new Complex(1.0,0.0),new Complex(4.0,0.0),new Complex(8.0,0.0),
      new Complex(0.29629629629629629630,0.0),
      new Complex(0.44444444444444444444,0.0),
      new Complex(0.66666666666666666667,0.0),
      new Complex(0.42882900629436784932,-0.15487175246424677819),
      new Complex(0.20787957635076190855,0.0),
      new Complex(2.4639512200927103386,5.0258643859042736965),
      new Complex(0.000782175555099748119,0.065075199065027035764),
      new Complex(-0.31205397840397702583,-0.04344693995132976350),
      new Complex(0.34836454596486382673,0.65394630061667130711),
      new Complex(617.9369000550522997,2595.6638964158808010)};
    Complex[] y=new Complex[N],expect=new Complex[N];
    System.arraycopy(eexpect, 0,expect,0, N);;
    boolean localflag, globalflag=false;

   

    // Test selected values
    System.out.println("Testing hypgeo");
    errmax=0.0;
    for (i=0;i<N;i++) {
      y[i]=hypgeo(a[i],b[i],c[i],z[i]);
      err=y[i].sub(expect[i]).abs()/expect[i].abs();
//      System.out.printf(y[i] << "  %f\n", expect[i] << "  %f\n", err);
      if (err > errmax) errmax=err;
    }
//    System.out.println("hypgeo: Maximum fractional discrepancy = %f\n", errmax);
    sbeps=1.e-10;
    localflag = errmax > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** hypgeo: Incorrect function values");
     
    }

    // Test symmetry of a and b
    sbeps=1.e-15;
    localflag=false;
    for (i=0;i<M;i++) {
      aa=new Complex(-0.5,-5.0+0.1*i);
      bb=new Complex(0.5,5.0-0.1*i);
      cc=new Complex(-5.0+0.1*i,1.0);
      zz=new Complex(-5.0+0.1*i,-5.0+0.1*i);

      res1=hypgeo(aa,bb,cc,zz);
      res2=hypgeo(bb,aa,cc,zz);
//      System.out.printf(abs(res1-res2));
      localflag = localflag || res1.sub(res2).abs() > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** hypgeo: Lack of symmetry in first two arguments");
     
    }

    // Test case a=c, b=1 where hypgeo=1/(1-z)
    sbeps=1.e-12;
    localflag=false;
    for (i=0;i<M;i++) {
      aa=new Complex(-0.5,-5.0+0.1*i);
      bb=new Complex(1.0,0.0);
      cc=new Complex(-0.5,-5.0+0.1*i);
      zz=new Complex(-5.0+0.1*i,-5.0+0.1*i);

      res1=hypgeo(aa,bb,cc,zz);
      res2=new Complex(1.0).div(new Complex(1.0).sub(zz));
//      System.out.printf(abs(res1-res2));
      localflag = localflag || res1.sub(res2).abs() > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** hypgeo: Failure of special case a=c, b=1");
     
    }
   
    // Test a contiguous relationship for aa (Abromowitz & Stegun, 15.2.13)
    sbeps=1.e-12;
    localflag=false;
    for (i=0;i<M;i++) {
      aa=new Complex(-0.5,-5.0+0.1*i);
      bb=new Complex(1.0,0.0);
      cc=new Complex(-0.5,-5.0+0.1*i);
      zz=new Complex(-5.0+0.1*i,-5.0+0.1*i);
     
      //res1=(cc-2.0*aa-(bb-aa)*zz)*hypgeo(aa,bb,cc,zz)
      //  + aa*(1.0-zz)*hypgeo(aa+1.0,bb,cc,zz);
      Complex r = bb.sub(aa).mul(zz);
      r = cc.sub(aa.mul(2.0)).sub(r);
      r = r.mul(hypgeo(aa,bb,cc,zz));
      res1 = r.add( aa.mul(new Complex(1.0).sub(zz)).mul(
          hypgeo(aa.add(new Complex(1.0)),bb,cc,zz)) );
     
      //res2=(cc-aa)*hypgeo(aa-1.0,bb,cc,zz);
      //      System.out.printf(abs(res1-res2));
      r = cc.sub(aa);
      res2 = r.mul(hypgeo(aa.sub(new Complex(1.0)),bb,cc,zz));
      localflag = localflag || res1.sub(res2).abs() > sbeps;
     
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** hypgeo: Failure of contiguous relationship for aa");
     
    }
   
    // Test a contiguous relationship for cc (Abromowitz & Stegun, 15.2.27)
    sbeps=1.e-10;
    localflag=false;
    for (i=0;i<M;i++) {
      aa=new Complex(-0.5,-5.0+0.1*i);
      bb=new Complex(1.0,0.0);
      cc=new Complex(-0.5,-5.0+0.1*i);
      zz=new Complex(-5.0+0.1*i,-5.0+0.1*i);
      Complex r = cc.mul(2.0).sub(aa).sub(bb).sub(new Complex(1.0));
      r = cc.sub(new Complex(1.0)).sub(r.mul(zz));
      r = cc.mul(r).mul(hypgeo(aa,bb,cc,zz));
      Complex rr =(cc.sub(aa)).mul(cc.sub(bb)).mul(zz).mul(hypgeo(aa,bb,cc.sub(new Complex(1.0)),zz));
      res1 = r.add(rr);
      //res1=cc*(cc-1.0-(2.0*cc-aa-bb-1.0)*zz)*hypgeo(aa,bb,cc,zz)
      //  + (cc-aa)*(cc-bb)*zz*hypgeo(aa,bb,cc+1.0,zz);
      res2 = cc.mul(cc.sub(new Complex(1.0))).mul(new Complex(1.0).sub(zz));
      res2 = res2.mul(hypgeo(aa,bb,cc.sub(new Complex(1.0)),zz));
      // res2=cc*(cc-1.0)*(1.0-zz)*hypgeo(aa,bb,cc-1.0,zz);
     
//      System.out.printf(abs(res1-res2));
      localflag = localflag || res1.sub(res2).abs() > sbeps;
     
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** hypgeo: Failure of contiguous relationship for cc");
     
    }
   
    // Test of mirror symmetry
    sbeps=1.e-15;
    localflag=false;
    for (i=0;i<M;i++) {
      aa=new Complex(-0.5,-5.0+0.1*i);
      bb=new Complex(0.5,5.0-0.1*i);
      cc=new Complex(-5.0+0.1*i,1.0);
      zz=new Complex(-5.0+0.1*i,-5.0+0.1*i);

      res1=hypgeo(aa,bb,cc,zz);
      res2=hypgeo(aa.conj(),bb.conj(),cc.conj(),zz.conj());
//      System.out.printf(res1 << " %f\n", res2);
      localflag = localflag || res1.sub(res2.conj()).abs() > sbeps;
View Full Code Here


      if(!found)
        throw new IllegalArgumentException("Roots must be conjugate");
    }

    Complex[] c = new Complex[z.length + 1];
    c[0] = z[0].neg(); c[1] = new Complex(1,0);
    for(int i=1; i<z.length; i++) {
      Complex d = c[0];
      c[0] = c[0].mul(z[i].neg());
      for(int j=1;j<i+1; j++) {
        Complex dd = c[j];
        c[j] = d.sub( z[i].mul(c[j]));
        d = dd;
      }
      c[i+1] = d;
    }
View Full Code Here

    Poly poly = new Poly(c);
    System.out.println(poly);
   
    poly = buildFromRoots(new double[]{2,3,1});
    System.out.println(poly);
    Complex p0 = new Complex(-0.00196389, 0.00196448);
    Complex p1 = new Complex(-0.00196389,-0.00196448);
    Complex p2 = new Complex(-3.1175, 3.90912);
    Complex p3 = new Complex(-3.1175, -3.90912);
    poly = buildFromRoots(new Complex[]{p0,p1,p2,p3});
    System.out.println(poly);
  }
View Full Code Here

  public void derivs(final double s, final double[] yy, final double[] dyyds){
    get(s, yy, dyyds);
  }
 
  public void get(final double s, final double[] yy, final double[] dyyds) {
    Complex z;
    Complex[] y = new Complex[2];
    Complex[] dyds = new Complex[2];
   
    y[0]=new Complex(yy[0],yy[1]);
    y[1]=new Complex(yy[2],yy[3]);
    z=z0.add(dz.scale(s));
    dyds[0]=y[1].mul(dz);
    //dyds[1]=(a*b*y[0]-(c-(a+b+1.0)*z)*y[1])*dz/(z*(1.0-z));
   
    Complex aa = c.sub((a.add(b).add(new Complex(1,0))).mul(z));
    Complex bb = a.mul(b).mul(y[0]).sub(aa.mul(y[1]));
    dyds[1]=bb.mul(dz).div(z.mul(new Complex(1.0,0).sub(z)));
   
    dyyds[0]=dyds[0].re();
    dyyds[1]=dyds[0].im();
    dyyds[2]=dyds[1].re();
    dyyds[3]=dyds[1].im();
View Full Code Here

        for (j=0;j<N;j++) vec[j] *= usym2.wri[i].re();
//        System.out.println("real eigenvalue  " << maxel(vecsub(res,vec)));
        localflag = localflag || (maxel(vecsub(res,vec)) > sbeps);
      } else {
        if (usym2.wri[i].im() > 0.0)
          for (j=0;j<N;j++) zvec[j]=new Complex(usym2.zz[j][i],usym2.zz[j][i+1]);
        else
          for (j=0;j<N;j++) zvec[j]=new Complex(usym2.zz[j][i-1],-usym2.zz[j][i]);
        for (j=0;j<N;j++) {
          zres[j]=new Complex(0.,0.);
          for (k=0;k<N;k++) zres[j] = zres[j].add(zvec[k].mul(a[j][k]));
        }
        for (j=0;j<N;j++) zvec[j] = zvec[j].mul(usym2.wri[i]);
        max=0.;
        for (j=0;j<N;j++) max = (max > zres[j].sub(zvec[j]).abs() ? max : zres[j].sub(zvec[j]).abs());
//        System.out.println("imag eigenvalue  " << max);
        localflag = localflag || (max > sbeps);
      }
      max=0.;
      for (j=0;j<N;j++) max = (max > zres[j].sub(zvec[j]).abs() ? max : zres[j].sub(zvec[j]).abs());
      localflag = localflag || (max > sbeps);
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Unsymmeig, non-symmetric, interface1: Matrix times eigenvector was not the same as lambda*eigenvector");
     
    }
   
    // Test the sorting of the eigenvalues
    for (i=1;i<N;i++)
      localflag = localflag || (usym2.wri[i].re() > usym2.wri[i-1].re());
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Unsymmeig, non-symmetric, interface1: Eigenvalues not sorted in high-to-low order of real part");
     
    }

    for (i=1;i<N;i++)
      localflag = localflag || (usym2.wri[i].im() > 0.0) && (!usym2.wri[i].equals(usym2.wri[i+1].conj()));
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Unsymmeig, non-symmetric, interface1: A complex eigenvalue with positive imag part is not followed by its conjugate");
     
    }

    //------------------------------------------------------------------------
    // Test Unsymmeig, non-symmetric, interface2
    System.out.println("Testing Unsymmeig, non-symmetric, interface2");
    for (i=0;i<N;i++)
      for (j=0;j<N;j++)
        a[i][j]= (i > j+1 ? 0.0 : myran.doub());
    Unsymmeig usym3 = new Unsymmeig(a,true,true);

//    for (i=0;i<N;i++) System.out.printf(usym3.wri[i]);

    // Test eigenvector/eigenvalue pairs
    for (i=0;i<N;i++) {   // for each eigenvector
      if (usym3.wri[i].im() == 0.0) {
        for (j=0;j<N;j++) vec[j]=usym3.zz[j][i];
        res=matmul(a,vec);
        for (j=0;j<N;j++) vec[j] *= usym3.wri[i].re();
//        System.out.println("real eigenvalue  " << maxel(vecsub(res,vec)));
        localflag = localflag || (maxel(vecsub(res,vec)) > sbeps);
      } else {
        if (usym3.wri[i].im() > 0.0)
          for (j=0;j<N;j++) zvec[j]=new Complex(usym3.zz[j][i],usym3.zz[j][i+1]);
        else
          for (j=0;j<N;j++) zvec[j]=new Complex(usym3.zz[j][i-1],-usym3.zz[j][i]);
        for (j=0;j<N;j++) {
          zres[j]=new Complex(0.,0.);
          for (k=0;k<N;k++) zres[j] = zres[j].add(zvec[k].mul(a[j][k]));
        }
        for (j=0;j<N;j++) zvec[j] = zvec[j].mul(usym3.wri[i]);
        max=0.;
        for (j=0;j<N;j++) max = (max > zres[j].sub(zvec[j]).abs() ? max : zres[j].sub(zvec[j]).abs());
View Full Code Here

  public static void fixrts(final double[] d) {
    boolean polish=true;
    int i,j,m=d.length;
    Complex[] a = new Complex[m+1];
    Complex[] roots = new Complex[m];
    a[m]=new Complex(1.0,0.0);
    for (j=0;j<m;j++)   // Set up complex coefficients for polynomial root finder
      a[j]= new Complex(-d[m-1-j],0.0);
    Roots.zroots(a,roots,polish);       // Find all the roots
    for (j=0;j<m;j++)       // Look for a root outside the unti circle, and reflect it back inside
      if (roots[j].mod() > 1.0)
        roots[j]=new Complex(1.0,0).div(roots[j].conj());
    a[0]= roots[0].neg();   // Now reconstruct the polynomial coefficients
    a[1]=new Complex(1.0,0);
    for (j=1;j<m;j++) {   // by looping over the roots
      a[j+1]=new Complex(1.0,0);
      for (i=j;i>=1;i--)    // and synthetically multiplying
        a[i]=a[i-1].sub(roots[j].mul(a[i]));
      a[0]= roots[j].neg().mul(a[0]);
    }
    for (j=0;j<m;j++)     // The polynomial coefficients are guaranteed to be real, so we need to return the real part
View Full Code Here

  @Test
  public void test() {
    int i,N=16;
    double sbeps=1.0e-15;
    Complex zz1,zz2;
    double x[]={0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.5,3.0,3.5,4.0,4.5};
    double u[]={-0.1777840788066129,-0.02227070695927976,0.1005147070088978,
      0.1982786159524672,0.2760678304677729,0.3374039229009681,
      0.4204591828942405,0.4620065850946773,0.4717325169318778,
      0.4568111294183369,0.4229808287748650,0.2858711963653835,
      0.1196297860080003,-0.03212854851248112,-0.1409816978869304,
      -0.1934911221017388};
    double v[]={0.4931074180430667,0.5881288096080801,0.6812222391166113,
      0.7720957854819966,0.8604707107452929,0.9460830703671830,
      1.108047199013719,1.256226732779218,1.389180485870438,
      1.505816780255579,1.605412976802695,1.778520173443827,
      1.848652527999468,1.833125398665997,1.758203138949053,
      1.654140414379244};
    double[] uu=buildVector(u),vv=buildVector(v),zreal = new double[N],zimag = new double[N];
    Complex[] zz = new Complex[N];
    boolean localflag=false, globalflag=false;

   

    // Test cisi
    System.out.println("Testing cisi");

    for (i=0;i<N;i++) {
      zz[i]=cisi(x[i]);
      zreal[i]=zz[i].re();
      zimag[i]=zz[i].im();
    }
    System.out.printf("cisi: Maximum discrepancy of cosine integral = %f\n", maxel(vecsub(zreal,uu)));
    localflag = maxel(vecsub(zreal,uu)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** cisi: Incorrect function values for cosine integral");
     
    }

    System.out.printf("cisi: Maximum discrepancy of sine integral = %f\n", maxel(vecsub(zimag,vv)));
    localflag = maxel(vecsub(zimag,vv)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** cisi: Incorrect function values for sine integral");
     
    }

    // Test symmetries
    for (i=0;i<N;i++) {
      zz1=cisi(x[i]);
      zz2=cisi(-x[i]);
      localflag = localflag || zz1.re() != zz2.re();
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** cisi: Incorrect symmetry for cosine integral");
       
      }

      localflag = localflag || zz1.im() != -zz2.im();
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** cisi: Incorrect symmetry for sine integral");
       
      }
View Full Code Here

    fourn(data1,nn,1);
    for (i=0;i<N/2;i++) {
      n2=i%nn[2];
      n1=((i-n2)/nn[2])%nn[1];
      n0=(i-n2-nn[2]*n1)/nn[1]/nn[2];
      Complex r1 = Complex.I.mul(2.0*pi*5.0*n0/nn[0]);
      Complex r2 = Complex.I.mul(2.0*pi*7.0*n1/nn[1]);
      Complex r3 = Complex.I.mul(2.0*pi*9.0*n2/nn[2]);
      Complex r = r1.exp().mul(r2.exp()).mul(r3.exp());         
      data2[2*i]=r.re();
      data2[2*i+1]=r.im();
    }
//    System.out.printf(maxel(vecsub(data1,data2)));
    localflag = localflag || maxel(vecsub(data1,data2)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
View Full Code Here

    // Test Wrapdouble[], interface1
    System.out.println("Testing WrapVecDoub[], interface1");

    WrapVecDoub data = new WrapVecDoub(2*N);
    for (i=0;i<N;i++) data.set(i,new Complex(2*i,2*i+1));
    for (i=0;i<N;i++)
      localflag = localflag || (data.real(i) != 2*i) || (data.imag(i) != 2*i+1);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface1: Failure to write complex, and read with .real() and .imag()");
     
    }

    for (i=0;i<N;i++) {
      data.setReal(i,2.0*(N-1)-2.0*i+1.0);
      data.setImag(i,2.0*(N-1)-2.0*i);
    }
    for (i=0;i<N;i++)
      localflag = localflag || (!data.get(i).equals(new Complex(2.0*(N-1)-2.0*i+1.0,2.0*(N-1)-2.0*i)));
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface1: Failure to write with .real() and .imag(), and read complex");
     
    }

    // test conversion operator
    localflag = localflag || maxel(data.get()) != 2.0*N-1.0;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface1: Failure to convert WrapVecDoub[] to double[]");
     
    }

    // test the periodic indexing
    for (i=0;i<N;i++)
      localflag = localflag || data.get(i).sub(data.get(i-N)).abs()!= 0;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface1: Failure of indexing to have period of N");
     
    }
   
    // Test WrapVecDoub[], interface2
    System.out.println("Testing WrapVecDoub[], interface2");
    double[] dat = new double[2*N];
    for (i=0;i<2*N;i++) dat[i]=i;
    WrapVecDoub data2 = new WrapVecDoub(dat);

    for (i=0;i<N;i++)
      localflag = localflag || (data2.real(i) != 2*i) || (data2.imag(i) != 2*i+1);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface2: Incorrect values recovered with .real() and .imag() from initialized WrapVecDoub[]");
     
    }

    for (i=0;i<N;i++)
      localflag = localflag || !data2.get(i).equals(new Complex(2.0*i,2.0*i+1.0));
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** WrapVecDoub[], interface: Incorrect values recovered with [] from initialized WrapVecDoub[]");
     
    }
View Full Code Here

  @Test
  public void test() {
    int i,N=5;
    boolean polish=true;
    double sbeps=1.e-14;
    Complex re1 = new Complex(1.0,0.0),im1=new Complex(0.0,1.0);
    Complex a[]={
        re1.mul(2.0).add(im1),
        im1.mul(2.0),
        re1.mul(3.0).add(im1),
        re1.add(im1.mul(2.0)),
        re1.sub(im1),
        new Complex(1.0)
        };
   
    Complex[] aa = new Complex[N+1];System.arraycopy(a, 0, aa, 0 , N+1);
   
    Complex[] rts = new Complex[N];
    double[] dy=new double[N];
    boolean localflag, globalflag=false;

   

    // Test zroots
    System.out.println("Testing zroots");
    // Roots of polynomial x^5+(1-i)x^4+(1+2i)x^3+(3+i)x^2+(2i)x+(2+i)"
    // Roots are x=i, x=-i, x=sqrt(2i), x=-i*sqrt(2i), x=(i-1)
    zroots(aa,rts,polish);
    for (i=0;i<N;i++) {
      Complex r = a[4].add(rts[i].mul(a[5]));
      r = a[3].add(rts[i].mul(r));
      r = a[2].add(rts[i].mul(r));
      r = a[1].add(rts[i].mul(r));
      r = a[0].add(rts[i].mul(r));
      dy[i]=r.abs();
    }
    System.out.printf("zroots: Maximum discrepancy = %f\n", maxel(dy));
    localflag = maxel(dy) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
View Full Code Here

TOP

Related Classes of com.nr.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.