Package com.nr.sf

Examples of com.nr.sf.Bessel


      1.15440105519259143,4.43020145207026971,21.0903075895088051,
      120.426893194368698};
    double[] uu1=buildVector(u1),uu2=buildVector(u2),uu3=buildVector(u3),uu4=buildVector(u4),zz=new double[N],zz1=new double[N],zz2=new double[N];
    boolean localflag, globalflag=false;

    Bessel bess = new Bessel();
    Bessjy bjy = new Bessjy();
    Bessik bik = new Bessik();

    // Test Bessel (besseljy and besselik)
    System.out.println("Testing Bessel (besseljy)");

    // Test for integer values of nu
    sbeps=1.e-10;
    for (i=0;i<5;i++) {
      nnu=(double)(i);

      for (j=0;j<N;j++) {
        xx=0.2*(j+1);
        if (i == 0) {
          zz1[j]=bjy.j0(xx);
          zz2[j]=bess.jnu(nnu,xx);
        } else if (i == 1) {
          zz1[j]=bjy.j1(xx);
          zz2[j]=bess.jnu(nnu,xx);
        } else {
          zz1[j]=bjy.jn(i,xx);
          zz2[j]=bess.jnu(nnu,xx);
        }
      }
      localflag = maxel(vecsub(zz1,zz2)) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Bessel (besseljy,jnu): Incorrect function values, integer order");
       
      }

      for (j=0;j<N;j++) {
        xx=0.2*(j+1);
        if (i == 0) {
          zz1[j]=bjy.y0(xx);
          zz2[j]=bess.ynu(nnu,xx);
        } else if (i == 1) {
          zz1[j]=bjy.y1(xx);
          zz2[j]=bess.ynu(nnu,xx);
        } else {
          zz1[j]=bjy.yn(i,xx);
          zz2[j]=bess.ynu(nnu,xx);
        }
      }
      localflag = maxel(vecsub(zz1,zz2)) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Bessel (besseljy,ynu): Incorrect function values, integer order");
       
      }

      for (j=0;j<N;j++) {
        xx=0.2*(j+1);
        if (i == 0) {
          zz1[j]=bik.i0(xx);
          zz2[j]=bess.inu(nnu,xx);
        } else if (i == 1) {
          zz1[j]=bik.i1(xx);
          zz2[j]=bess.inu(nnu,xx);
        } else {
          zz1[j]=bik.in(i,xx);
          zz2[j]=bess.inu(nnu,xx);
        }
      }
      localflag = maxel(vecsub(zz1,zz2)) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Bessel (besselik,inu): Incorrect function values, integer order");
       
      }

      for (j=0;j<N;j++) {
        xx=0.2*(j+1);
        if (i == 0) {
          zz1[j]=bik.k0(xx);
          zz2[j]=bess.knu(nnu,xx);
        } else if (i == 1) {
          zz1[j]=bik.k1(xx);
          zz2[j]=bess.knu(nnu,xx);
        } else {
          zz1[j]=bik.kn(i,xx);
          zz2[j]=bess.knu(nnu,xx);
        }
      }
      localflag = maxel(vecsub(zz1,zz2)) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Bessel (besselik,knu): Incorrect function values, integer order");
       
      }
    }

    // Test some non-integer values of nu
    // Test Bessel (besseljy)
    System.out.println("Testing Bessel (besseljy),jnu");
    for (i=0;i<N;i++)
      zz[i]=bess.jnu(nu[i],x[i]);
    System.out.printf("Bessel (besseljy),jnu: Maximum discrepancy = %f\n", maxel(vecsub(zz,uu1)));
    localflag = maxel(vecsub(zz,uu1)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessel (besselij),jnu: Incorrect function values, non-integer order");
     
    }

    System.out.println("Testing Bessel (besseljy),ynu");
    for (i=0;i<N;i++)
      zz[i]=bess.ynu(nu[i],x[i]);
    System.out.printf("Bessel (besseljy),ynu: Maximum discrepancy = %f\n", maxel(vecsub(zz,uu2)));
    localflag = maxel(vecsub(zz,uu2)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessel (besseljy),ynu: Incorrect function values, non-integer order");
     
    }

    // Test Bessel (besselik)
    System.out.println("Testing Bessel (besselik),inu");
    for (i=0;i<N;i++) zz[i]=bess.inu(nu[i],x[i]);
    System.out.printf("Bessel (besselik),inu: Maximum discrepancy = %f\n", maxel(vecsub(zz,uu3)));
    localflag = maxel(vecsub(zz,uu3)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessel (besselik),inu: Incorrect function values, non-integer order");
     
    }

    System.out.println("Testing Bessel (besselik),knu");
    for (i=0;i<N;i++) zz[i]=bess.knu(nu[i],x[i]);
    System.out.printf("Bessel (besselik),knu: Maximum discrepancy = %f\n", maxel(vecsub(zz,uu4)));
    localflag = maxel(vecsub(zz,uu4)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessel (besselik),knu: Incorrect function values, non-integer order");
View Full Code Here


   

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

    Bessel bess =new Bessel();
    y[0]=1.0/pow(3.0,2.0/3.0)/exp(gammln(2.0/3.0));     // Ai(x)
    y[nvar]=-1.0/pow(3.0,1.0/3.0)/exp(gammln(1.0/3.0));
    dydx[0]=0.0;
    y[1]=1.0/pow(3.0,1.0/6.0)/exp(gammln(2.0/3.0));     // Bi(x)
    y[nvar+1]=pow(3.0,1.0/6.0)/exp(gammln(1.0/3.0));
    dydx[1]=0.0;
   
    Output out=new Output(20);
    x1=0.0;x2=1.0;
    rhs_StepperStoerm d = new rhs_StepperStoerm();
    StepperStoerm s1= new StepperStoerm();
    Odeint ode1 = new Odeint(y,x1,x2,atol,rtol,h1,hmin,out,d,s1);
    ode1.integrate();
    yexp[0]=bess.airy_ai(1.0);
    yexp[1]=bess.airy_bi(1.0);

    for (i=0;i<nvar;i++) {
      yout[i]=out.ysave[i][out.count-1];
      System.out.printf("%f  %f\n", yout[i],yexp[i]);
    }

    sbeps = 1.e-8;
    System.out.println(maxel(vecsub(yout,yexp)));
    localflag = maxel(vecsub(yout,yexp)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** StepperStoerm: Inaccurate integration #1");
     
    }

    y[0]=1.0/pow(3.0,2.0/3.0)/exp(gammln(2.0/3.0));     // Ai(x)
    y[nvar]=-1.0/pow(3.0,1.0/3.0)/exp(gammln(1.0/3.0));
    dydx[0]=0.0;
    y[1]=1.0/pow(3.0,1.0/6.0)/exp(gammln(2.0/3.0));     // Bi(x)
    y[nvar+1]=pow(3.0,1.0/6.0)/exp(gammln(1.0/3.0));
    dydx[1]=0.0;

    x1=0.0;x2=-1.0;
    StepperStoerm s2 = new StepperStoerm();
    Odeint ode2 = new Odeint(y,x1,x2,atol,rtol,h1,hmin,out,d,s2);
    ode2.integrate();
    yexp[0]=bess.airy_ai(-1.0);
    yexp[1]=bess.airy_bi(-1.0);

    for (i=0;i<nvar;i++) {
      yout[i]=out.ysave[i][out.count-1];
      System.out.printf("%f  %f\n", yout[i],yexp[i]);
    }
View Full Code Here

  public double funk(final double x)
  {
    if (x == 0.0)
      return 0.0;
    else {
      Bessel bess = new Bessel();
      return x*bess.jnu(0.0,x)/(1.0+x*x);
    }
  }
View Full Code Here

  public double funk(double x) {
    if (x == 0.0)
      return 0.0;
    else {
      Bessel bess = new Bessel();
      return x*bess.jnu(0.0,x)/(1.0+x*x);
    }
  }
View Full Code Here

TOP

Related Classes of com.nr.sf.Bessel

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.