Package com.nr.eig

Examples of com.nr.eig.Symmeig


  public static void gaucof(final double[] a, final double[] b, final double amu0, final double[] x,
      final double[] w) {
    int n=a.length;
    for (int i=0;i<n;i++)
      if (i != 0) b[i]=sqrt(b[i]);
    Symmeig sym = new Symmeig(a,b);
    for (int i=0;i<n;i++) {
      x[i]=sym.d[i];
      w[i]=amu0*sym.z[0][i]*sym.z[0][i];
    }
  }
View Full Code Here


      for (j=0;j<i;j++) {
        a[i][j]=myran.doub();
        a[j][i]=a[i][j];
      }
    }
    Symmeig sym = new Symmeig(a);
   
    // test eigenvector/eigenvalue pairs
    for (i=0;i<N;i++) {   // for each eigenvector
      for (j=0;j<N;j++) vec[j]=sym.z[j][i];
      res=matmul(a,vec);
      for (j=0;j<N;j++) vec[j] *= sym.d[i];
//      System.out.printf(maxel(vecsub(res,vec)));
      localflag = localflag || (maxel(vecsub(res,vec)) > sbeps);
    }
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Symmeig: Matrix times eigenvector was not the same as lambda*eigenvector");
     
    }

    // test the sorting of the eigenvalues by eigsrt()
    for (i=1;i<N;i++)
      localflag = localflag || (sym.d[i] > sym.d[i-1]);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Symmeig: Eigenvalues not sorted in high-to-low order");
     
    }

    // Test Symmeig
    System.out.println("Testing Symmeig, interface2");
    double[] d=new double[N],e=new double[N];
    double[][] b=new double[N][N];
    ranvec(d);
    ranvec(e);
    for (i=0;i<N;i++) b[i][i]=d[i];
    for (i=1;i<N;i++) b[i][i-1]=b[i-1][i]=e[i];
    Symmeig sym2=new Symmeig(d,e);
   
    // test eigenvector/eigenvalue pairs
    for (i=0;i<N;i++) {   // for each eigenvector
      for (j=0;j<N;j++) vec[j]=sym2.z[j][i];
      res=matmul(b,vec);
View Full Code Here

TOP

Related Classes of com.nr.eig.Symmeig

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.