Package com.nr.la

Examples of com.nr.la.SVD


   

    // Test SVD (not very deeply, however)
    System.out.println("Testing SVD");
    SVD svd = new SVD(a);
    double[][] x = new double[b.length][b[0].length];
    svd.solve(b,x);
    sbeps = 1.e-14;
    localflag = maxel(matsub(matmul(a,x),b)) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** SVD: Inconsistent solution vector");
     
    }

//    System.out.println("svd: rank = " << svd.rank() << "  nullity = " << svd.nullity() << endl;
    localflag = (svd.rank() != 50 || svd.nullity() != 0);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** SVD: Unexpected rank or nullity in original matrix");
     
    }

    for (i=0;i<N;i++) {       // Decrease the matrix rank
      a[3][i]=a[2][i]-a[1][i];
      a[4][i]=0.0;
    }
    SVD svd2 = new SVD(a);
//    System.out.println("svd: rank = " << svd2.rank() << "  nullity = " << svd2.nullity() << endl;
    localflag = (svd2.rank() != 48 || svd2.nullity() != 2);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** SVD: Unexpected rank or nullity in modified matrix");
     
    }
View Full Code Here


          for (j=mm+1;j<ncof;j++) {
            power *= xs[i];
            u[i][j]=power;
          }
        }
        SVD svd = new SVD(u);
        svd.solve(bb,coff);
        devmax=sum=0.0;
        Ratfn rat = new Ratfn(coff,mm+1,kk+1);
        for (j=0;j<npt;j++) {
          ee[j]=rat.get(xs[j])-fs[j];
          wt[j]=abs(ee[j]);
View Full Code Here

public class SVD_Ex {
 
  public static void main(String[] args) {
    double[] a =  { 1, 2, 3, 4, 5, 6, 7, 8,9 };
    double[][]m = NRUtil.buildMatrix(3, 3, a);
    SVD svd = new SVD(m);
    double b[] = { 3, 1, 2 };
    double[] x = new double[3];
    System.out.println(svd.inv_condition());
    System.out.println(svd.rank());
    System.out.println(svd.nullity());
   
    svd.solve(b, x);
    System.out.println(NRUtil.toString(x));
  }
View Full Code Here

      else afunc=funcsmd.funk(row(xmd,i));   // Discussed in 15.4.4
      tmp=1.0/sig[i];
      for (j=0;j<ma;j++) aa[i][j]=afunc[j]*tmp;
      b[i]=y[i]*tmp;
    }
    SVD svd = new SVD(aa);   // Singular value decomposition
    thresh = (tol > 0. ? tol*svd.w[0] : -1.);
    svd.solve(b,a,thresh);    // Solve for the coefficients
    chisq=0.0;   // Evaluate chi-square
    for (i=0;i<ndat;i++) {
      sum=0.;
      for (j=0;j<ma;j++) sum += aa[i][j]*a[j];
      chisq += SQR(sum-b[i]);
View Full Code Here

TOP

Related Classes of com.nr.la.SVD

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.