Package Jama

Examples of Jama.SingularValueDecomposition


    if ((y.length < ndata) || (x.length < ndata) || ((sd != null) && (sd.length < ndata))) {
      throw new IllegalArgumentException("data paramenters incorrect too short vector");
    }
    Matrix A = new Matrix(ndata, order + 1);
    double[] b = new double[ndata];
    SingularValueDecomposition SVD;
    double[] a = new double[order + 1];
    double xVal;
    double yVal;
    double small = 0.0000000001 * ndata;
    double[] coeff = new double[order + 1];
    double[][] U;
    double[][] V;
    double[] w;

    if (sd == null) {
      sd = new double[ndata];
      for (int i = 0; i < ndata; i++) {
        sd[i] = 1;
      }
    }

    for (int i = 0; i < ndata; i++) {
      A.set(i, 0, 1 / sd[i]);
    }
    for (int i = 0; i < ndata; i++) {
      xVal = 1;
      yVal = 1;
      for (int j = 1; j <= order; j++) {
        xVal *= x[i];
        yVal += xVal;
        A.set(i, j, xVal / sd[i]);
      }
      b[i] = yVal / sd[i];
    }
    SVD = A.svd();
    U = (SVD.getU()).getArray();
    V = (SVD.getV()).getArray();
    w = SVD.getSingularValues();

    for (int j = 0; j <= order; j++) {
      coeff[j] = 0;
      if (w[j] > small) {
        for (int i = 0; i < ndata; i++) {
View Full Code Here


            try_success("QRDecomposition...", "");
        } catch (java.lang.RuntimeException e) {
            errorCount = try_failure(errorCount, "QRDecomposition...",
                    "incorrect QR decomposition calculation");
        }
        SingularValueDecomposition SVD = A.svd();

        try {
            check(A, SVD.getU().times(SVD.getS().times(SVD.getV().transpose())));
            try_success("SingularValueDecomposition...", "");
        } catch (java.lang.RuntimeException e) {
            errorCount = try_failure(errorCount, "SingularValueDecomposition...",
                    "incorrect singular value decomposition calculation");
        }
        DEF = new Matrix(rankdef);
        try {
            check(DEF.rank(),
                    Math.min(DEF.getRowDimension(), DEF.getColumnDimension())
                    - 1);
            try_success("rank()...", "");
        } catch (java.lang.RuntimeException e) {
            errorCount = try_failure(errorCount, "rank()...",
                    "incorrect rank calculation");
        }
        B = new Matrix(condmat);
        SVD = B.svd();
        double[] singularvalues = SVD.getSingularValues();

        try {
            check(B.cond(),
                    singularvalues[0]
                    / singularvalues[Math.min(B.getRowDimension(), B.getColumnDimension()) - 1]);
View Full Code Here

        }

    if (result==null) {

      Matrix m = new Matrix(matrix);
      SingularValueDecomposition svd = m.svd();
      Matrix sInv = svd.getS().inverse();

      int i = 0;
      while (i < svd.getS().getRowDimension() && svd.getS().get(i, i) > minSV && (nSV <= 0 || i < nSV)) {
                i++;
            }

      if(!myQuiet) {
                ourLogger.info("Using " + i + " singular values for pseudo-inverse");
            }

      for (int j = i; j < matrix.length; j++) {
        sInv.set(j, j, 0d);
      }

      result = svd.getV().times(sInv).times(svd.getU().transpose()).getArray();

    }

    return result;
  }
View Full Code Here

TOP

Related Classes of Jama.SingularValueDecomposition

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.