code: public void solve(double[] b, double[] x) {
          if (!full) {
              throw new IllegalStateException("This is not a FULL singular value decomposition.");
          }
  
          if (b.length != m || x.length != n) {
              throw new IllegalArgumentException("Dimensions do not agree.");
          }
  
          double[] tmp = new double[n];
          for (int j = 0; j < n; j++) {
              double r = 0.0;
              if (s[j] > tol) {
                  for (int i = 0; i < m; i++) {
                      r += U.get(i, j) * b[i];
                  }
                  r /= s[j];
              }
              tmp[j] = r;
          }
  
          for (int j = 0; j < n; j++) {
              double r = 0.0;
              for (int jj = 0; jj < n; jj++) {
                  r += V.get(j, jj) * tmp[jj];
              }
              x[j] = r;
          }
      }
docs: Solve the least squares A*x = b.
  @param b   right hand side of linear system.
  @param x   the output solution vector that minimizes the L2 norm of A*x - b.
  @exception  RuntimeException if matrix is rank deficient.