Package com.github.fommil.netlib

Examples of com.github.fommil.netlib.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

TOP

Related Classes of com.github.fommil.netlib.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.