Package com.nr.sf

Examples of com.nr.sf.Bessik


   

    // Test Bessik (i0)
    System.out.println("Testing Bessik (i0)");
    localflag=false;
    Bessik bess = new Bessik();
    sbeps=1.e-15;
    for (i=0;i<N;i++) zz1[i]=bess.i0(x[i]);
    for (i=0;i<N;i++) {
//      System.out.printf(fabs((zz1[i]-yy1[i])/yy1[i]));
      localflag = localflag || abs((zz1[i]-yy1[i])/yy1[i]) > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessik (i0): Incorrect function values");
     
    }

    // Test Bessik (i1)
    System.out.println("Testing Bessik (i1)");
    localflag=false;
    sbeps=1.e-15;
    for (i=0;i<N;i++) zz2[i]=bess.i1(x[i]);
    for (i=0;i<N;i++) {
      if (yy2[i] != 0.0) {
//        System.out.printf(abs((zz2[i]-yy2[i])/yy2[i]));
        localflag = localflag || abs((zz2[i]-yy2[i])/yy2[i]) > sbeps;
      }
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessik (i1): Incorrect function values");
     
    }

    N=10;
    double x3[]={0.001,0.01,0.1,0.5,1.0,2.0,4.0,8.0,16.0,32.0};
    double y3[]={7.023688800562382,4.721244730161095,2.427069024702017,
      9.244190712276657e-1,4.210244382407083e-1,1.138938727495334e-1,
      1.115967608585303e-2,1.464707052228154e-4,3.499411663936500e-8,
      2.795057518761980e-15};
    double y4[]={9.999962381560855e2,9.997389411829624e1,9.853844780870606,
      1.656441120003301,6.019072301972346e-1,1.398658818165225e-1,
      1.248349888726843e-2,1.553692118050012e-4,3.607157117528780e-8,
      2.838399271974671e-15};
    double[] yy3=buildVector(y3),yy4=buildVector(y4),zz3=new double[N],zz4=new double[N];

    // Test Bessik (k0)
    System.out.println("Testing Bessik (k0)");
    localflag=false;
    sbeps=5.e-15;
    for (i=0;i<N;i++) zz3[i]=bess.k0(x3[i]);
    for (i=0;i<N;i++) {
//      System.out.printf(abs((zz3[i]-yy3[i])/yy3[i]));
      localflag = localflag || abs((zz3[i]-yy3[i])/yy3[i]) > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessik (k0): Incorrect function values");
     
    }

    // Test Bessik (k1)
    System.out.println("Testing Bessik (k1)");
    localflag=false;
    sbeps=5.e-15;
    for (i=0;i<N;i++) zz4[i]=bess.k1(x3[i]);
    for (i=0;i<N;i++) {
//      System.out.printf(abs((zz4[i]-yy4[i])/yy4[i]));
      localflag = localflag || abs((zz4[i]-yy4[i])/yy4[i]) > sbeps;
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessik (k1): Incorrect function values");
     
    }

    N=16;
    int n5[]={2,2,2,2,5,5,5,5,10,10,10,10,20,20,20,20};
    double x5[]={0.01,0.1,1.0,10.0,0.01,0.1,1.0,10.0,0.01,0.1,1.0,10.0,0.01,0.1,1.0,10.0,};
    double y5[]={1.250010416699221e-5,1.251041992241759e-3,1.357476697670383e-1,
      2.281518967726005e3,2.604177517380490e-14,2.605251929893700e-9,
      2.714631559569721e-4,7.771882864032602e2,2.691150571711139e-30,
      2.691756142922153e-20,2.752948039836874e-10,2.189170616372337e1,
      3.919909016180170e-65,3.920371031419948e-45,3.966835985819000e-25,
      1.250799735644947e-4};
    double y6[]={1.999950006838941e4,1.995039646421141e2,1.624838898635177,
      2.150981700693276e-5,3.839976000100000e12,3.837600999583593e7,
      3.609605896012407e2,5.754184998531225e-5,1.857940439048064e28,
      1.857429584630401e18,1.807132899010295e8,1.614255300390669e-3,
      6.377698248601134e62,6.376867526661186e42,6.294369360424536e22,
      1.787442782077055e2};
    double[] yy5=buildVector(y5),yy6=buildVector(y6),zz5=new double[N],zz6=new double[N];

   

    // Test Bessik (in)
    System.out.println("Testing Bessik (in)");

    localflag=false;
    sbeps=5.e-14;
    for (i=0;i<N;i++) zz5[i]=bess.in(n5[i],x5[i]);
    for (i=0;i<N;i++) {
//      System.out.printf(abs((zz5[i]-yy5[i])/yy5[i]));
      localflag = localflag || abs((zz5[i]-yy5[i])/yy5[i]) > sbeps;
    }

    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Bessik (in): Incorrect function values");
     
    }

    // Test Bessik (kn)
    System.out.println("Testing Bessik (kn)");
    localflag=false;
    sbeps=5.e-15;
    for (i=0;i<N;i++) zz6[i]=bess.kn(n5[i],x5[i]);
    for (i=0;i<N;i++) {
//      System.out.printf(abs((zz6[i]-yy6[i])/yy6[i]));
      localflag = localflag || abs((zz6[i]-yy6[i])/yy6[i]) > sbeps;
    }
    globalflag = globalflag || localflag;
View Full Code Here


    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;
View Full Code Here

TOP

Related Classes of com.nr.sf.Bessik

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.