Package org.netlib.lapack

Examples of org.netlib.lapack.LAPACK


    int lwork1, lwork2;
    intW info = new intW(0);
    double dummy[] = new double[1];
    double ret[] = new double[1];

    LAPACK lapack = LAPACK.getInstance();

    // Query optimal workspace. First for computing the factorization
    lapack.dgeqrf(m, n, dummy, Matrices.ld(m), dummy, ret, -1, info);
    lwork1 = (info.val != 0) ? n : (int) ret[0];

    // Workspace needed for generating an explicit orthogonal matrix
    lapack.dorgqr(m, m, k, dummy, Matrices.ld(m), dummy, ret, -1, info);
    lwork2 = (info.val != 0) ? n : (int) ret[0];

    work = new double[Math.max(lwork1, lwork2)];
  }
View Full Code Here


    for (MatrixEntry e : A) {
      Afact.set(e.row(), e.column(), e.get());
    }

    intW info = new intW(0);
    LAPACK lapack = LAPACK.getInstance();

    /*
     * Calculate factorisation
     */
    lapack.dgeqp3(m, n, Afact.getData(), Matrices.ld(m), jpvt, tau, work,
      work.length, info);

    if (info.val < 0)
      throw new IllegalArgumentException();

    /*
     * Get R from Afact
     */
    R.zero();
    for (MatrixEntry e : Afact) {
      if (e.row() <= e.column() && e.column() < R.numColumns()) {
        R.set(e.row(), e.column(), e.get());
      }
    }

    /*
     * Calculate the rank based on a precision EPS
     */
    final double EPS = 1e-12;
    for (rank = 0; rank < k; rank++) {
      if (Math.abs(R.get(rank, rank)) < EPS)
        break;
    }

    /*
     * Explicit the orthogonal matrix
     */
    lapack.dorgqr(m, m, k, Afact.getData(), Matrices.ld(m), tau, work,
      work.length, info);
    for (MatrixEntry e : Afact) {
      if (e.column() < Q.numColumns())
        Q.set(e.row(), e.column(), e.get());
    }
View Full Code Here

    double v[] = vexp.toDoubleArray();
    double tmp[] = new double[1];
   
    int iwork[] = new int[8*(n<p ? n : p)];

    LAPACK lapack = LAPACK.getInstance();
  
    /* ask for optimal size of work array */
    int lwork = -1;
    intW info = new intW(0);
    lapack.dgesdd(jobu, n, p, xvals, n,  s, u, ldu, v, ldvt, tmp, lwork, iwork, info);
   
    if (info.val != 0) {
      throw new EvalException("error code %d from Lapack routine '%s'", info.val, "dgesdd");
    }
    
    lwork = (int) tmp[0];
    double work[] = new double[lwork];
   
    lapack.dgesdd(jobu, n, p, xvals, n, s, u, ldu, v, ldvt, work, lwork, iwork, info);
   
    return ListVector.newNamedBuilder()
      .add("d", DoubleArrayVector.unsafe(s, sexp.getAttributes()))
      .add("u", DoubleArrayVector.unsafe(u, uexp.getAttributes()))
      .add("vt", DoubleArrayVector.unsafe(v, vexp.getAttributes()))
View Full Code Here

    }

    int ipiv[] = new int[n];
    double avals[] = A.toDoubleArray();
   
    LAPACK lapack = LAPACK.getInstance();
    intW info = new intW(0);
   
    double[] result = B.toDoubleArray();
   
    lapack.dgesv(n, p, avals, n, ipiv, result, n, info);

    if (info.val < 0) {
      throw new EvalException("argument -" + info.val + " of Lapack routine 'dgsv' had invalid value");
    }
    if (info.val > 0) {
      throw new EvalException("Lapack routine dgesv: system is exactly singular");
    }

    anorm = lapack.dlange("1", n, n, A.toDoubleArray(), n, null);

    double[] arrWork = new double[4 * n];
    lapack.dgecon("1", n, avals, n, anorm, rcond, arrWork, ipiv, info);

    if (rcond.val < tolerance) {
      throw new EvalException("system is computationally singular: reciprocal condition number = " + rcond.val);
    }
    return DoubleArrayVector.unsafe(result, B.getAttributes());
View Full Code Here

    intW m = new intW(0);
    int itmp[] = new int[1];
   
    double tmp[] = new double[1];
   
    LAPACK lapack = LAPACK.getInstance();
    intW info = new intW(0);
    lapack.dsyevr(jobv, range, uplo, n, rx, n,
                       vl, vu, il, iu, abstol, m, rvalues,
                       rz, n, isuppz,
                       tmp, lwork, itmp, liwork, info);
      if (info.val != 0)
        throw new EvalException("error code %d from Lapack routine '%s'", info, "dsyevr");
     
      lwork = (int) tmp[0];
      liwork = itmp[0];
 
      double work[] new double[lwork];
      int iwork[] = new int[liwork];

      lapack.dsyevr(jobv, range, uplo, n, rx, n,
                       vl, vu, il, iu, abstol, m, rvalues,
                       rz, n, isuppz,
                       work, lwork, iwork, liwork, info);
      if (info.val != 0)
        throw new EvalException("error code %d from Lapack routine '%s'", info, "dsyevr");
View Full Code Here

      double wI[] = new double[n];
     
      /* ask for optimal size of work array */
      lwork = -1;

      LAPACK lapack = LAPACK.getInstance();

      tmp = new double[1];
      intW info = new intW(0);
      lapack.dgeev(jobVL, jobVR, n, xvals, n, wR, wI, left, n, right, n, tmp, lwork, info);

      if (info.val != 0)
          throw new EvalException("error code %d from Lapack routine '%s'", info, "dgeev");
     
      lwork = (int) tmp[0];
      work =  new double[lwork];
      lapack.dgeev(jobVL, jobVR, n, xvals, n, wR, wI, left, n, right, n, work, lwork, info);

      if (info.val != 0)
          throw new EvalException("error code %d from Lapack routine '%s'", info, "dgeev");

      ListVector.NamedBuilder ret = new ListVector.NamedBuilder();
View Full Code Here

TOP

Related Classes of org.netlib.lapack.LAPACK

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.