• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LAPACK类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.fommil.netlib.LAPACK的典型用法代码示例。如果您正苦于以下问题:Java LAPACK类的具体用法?Java LAPACK怎么用?Java LAPACK使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LAPACK类属于com.github.fommil.netlib包,在下文中一共展示了LAPACK类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public void solve(DenseMatrix B) {
    int m = lu.nrows();
    int n = lu.ncols();

    if (B.nrows() != m) {
        throw new IllegalArgumentException(String.format("Row dimensions do not agree: A is %d x %d, but B is %d x %d", lu.nrows(), lu.ncols(), B.nrows(), B.ncols()));
    }

    if (isSingular()) {
        throw new RuntimeException("Matrix is singular.");
    }

    intW info = new intW(0);
    LAPACK.getInstance().dgetrs(NLMatrix.Transpose, lu.nrows(), B.ncols(), lu.data(), lu.ld(), piv, B.data(), B.ld(), info);

    if (info.val < 0) {
        logger.error("LAPACK DGETRS error code: {}", info.val);
        throw new IllegalArgumentException("LAPACK DGETRS error code: " + info.val);
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:22,代码来源:LU.java


示例2: lu

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public LU lu() {
    boolean singular = false;

    int[] piv = new int[Math.min(nrows(), ncols())];
    intW info = new intW(0);
    LAPACK.getInstance().dgetrf(nrows(), ncols(), data(), ld(), piv, info);

    if (info.val > 0) {
        singular = true;
    }

    if (info.val < 0) {
        logger.error("LAPACK DGETRF error code: {}", info.val);
        throw new IllegalArgumentException("LAPACK DGETRF error code: " + info.val);
    }

    return new LU(this, piv, singular);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:20,代码来源:NLMatrix.java


示例3: cholesky

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public Cholesky cholesky() {
    if (nrows() != ncols()) {
        throw new UnsupportedOperationException("Cholesky decomposition on non-square matrix");
    }

    intW info = new intW(0);
    LAPACK.getInstance().dpotrf(NLMatrix.Lower, nrows(), data(), ld(), info);

    if (info.val > 0) {
        logger.error("LAPACK DPOTRF error code: {}", info.val);
        throw new IllegalArgumentException("The matrix is not positive definite.");
    }

    if (info.val < 0) {
        logger.error("LAPACK DPOTRF error code: {}", info.val);
        throw new IllegalArgumentException("LAPACK DPOTRF error code: " + info.val);
    }

    return new Cholesky(this);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:22,代码来源:NLMatrix.java


示例4: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Computes <code>A\B</code>, overwriting <code>B</code>
 */
public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException {
    if (notspd)
        throw new MatrixNotSPDException();
    if (B.numRows() != n)
        throw new IllegalArgumentException("B.numRows() != n");

    intW info = new intW(0);
    if (upper)
        LAPACK.getInstance().dpbtrs(UpLo.Upper.netlib(), n, kd,
                B.numColumns(), Cu.getData(), Matrices.ld(kd + 1),
                B.getData(), Matrices.ld(n), info);
    else
        LAPACK.getInstance().dpbtrs(UpLo.Lower.netlib(), n, kd,
                B.numColumns(), Cl.getData(), Matrices.ld(kd + 1),
                B.getData(), Matrices.ld(n), info);

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

    return B;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:25,代码来源:BandCholesky.java


示例5: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public Matrix solve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    intW info = new intW(0);
    LAPACK.getInstance()
            .dgtsv(numRows, X.numColumns(), subDiag.clone(), diag.clone(),
                    superDiag.clone(), Xd, Matrices.ld(numRows), info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:24,代码来源:TridiagMatrix.java


示例6: factor

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
private SymmBandEVD factor(Matrix A, double[] data, int kd)
        throws NotConvergedException {
    if (A.numRows() != n)
        throw new IllegalArgumentException("A.numRows() != n");

    intW info = new intW(0);
    LAPACK.getInstance().dsbevd(job.netlib(), uplo.netlib(), n, kd, data,
            Matrices.ld(kd + 1), w,
            job == JobEig.All ? Z.getData() : new double[0],
            Matrices.ld(n), work, work.length, iwork, iwork.length, info);

    if (info.val > 0)
        throw new NotConvergedException(
                NotConvergedException.Reason.Iterations);
    else if (info.val < 0)
        throw new IllegalArgumentException();

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:20,代码来源:SymmBandEVD.java


示例7: decompose

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
private DenseCholesky decompose(AbstractDenseMatrix A) {
    if (n != A.numRows())
        throw new IllegalArgumentException("n != A.numRows()");

    notspd = false;

    intW info = new intW(0);
    if (upper)
        LAPACK.getInstance().dpotrf(UpLo.Upper.netlib(), A.numRows(),
                A.getData(), Matrices.ld(A.numRows()), info);
    else
        LAPACK.getInstance().dpotrf(UpLo.Lower.netlib(), A.numRows(),
                A.getData(), Matrices.ld(A.numRows()), info);

    if (info.val > 0)
        notspd = true;
    else if (info.val < 0)
        throw new IllegalArgumentException();

    if (upper)
        Cu.set(A);
    else
        Cl.set(A);

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:27,代码来源:DenseCholesky.java


示例8: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Solves for <code>B</code>, overwriting it on return
 */
public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException {
    if (notspd)
        throw new MatrixNotSPDException();
    if (n != B.numRows())
        throw new IllegalArgumentException("n != B.numRows()");

    intW info = new intW(0);
    if (upper)
        LAPACK.getInstance().dpotrs(UpLo.Upper.netlib(), Cu.numRows(),
                B.numColumns(), Cu.getData(), Matrices.ld(Cu.numRows()),
                B.getData(), Matrices.ld(Cu.numRows()), info);
    else
        LAPACK.getInstance().dpotrs(UpLo.Lower.netlib(), Cl.numRows(),
                B.numColumns(), Cl.getData(), Matrices.ld(Cl.numRows()),
                B.getData(), Matrices.ld(Cl.numRows()), info);

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

    return B;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:25,代码来源:DenseCholesky.java


示例9: factor

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
private SymmDenseEVD factor(Matrix A, double[] data)
        throws NotConvergedException {
    if (A.numRows() != n)
        throw new IllegalArgumentException("A.numRows() != n");

    intW info = new intW(0);
    LAPACK.getInstance().dsyevr(job.netlib(), range.netlib(),
            uplo.netlib(), n, data, Matrices.ld(n), 0, 0, 0, 0, abstol,
            new intW(1), w,
            job == JobEig.All ? Z.getData() : new double[0],
            Matrices.ld(n), isuppz, work, work.length, iwork, iwork.length,
            info);

    if (info.val > 0)
        throw new NotConvergedException(
                NotConvergedException.Reason.Iterations);
    else if (info.val < 0)
        throw new IllegalArgumentException();

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:SymmDenseEVD.java


示例10: factor

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Computes the eigenvalue decomposition of the given matrix
 * 
 * @param A
 *            Matrix to factorize. Overwritten on return
 * @return The current eigenvalue decomposition
 * @throws NotConvergedException
 */
public SymmTridiagEVD factor(SymmTridiagMatrix A)
        throws NotConvergedException {
    if (A.numRows() != n)
        throw new IllegalArgumentException("A.numRows() != n");

    intW info = new intW(0);
    LAPACK.getInstance().dstevr(job.netlib(), range.netlib(), n,
            A.getDiagonal(), A.getOffDiagonal(), 0, 0, 0, 0, abstol,
            new intW(1), w,
            job == JobEig.All ? Z.getData() : new double[0],
            Matrices.ld(n), isuppz, work, work.length, iwork, iwork.length,
            info);

    if (info.val > 0)
        throw new NotConvergedException(
                NotConvergedException.Reason.Iterations);
    else if (info.val < 0)
        throw new IllegalArgumentException();

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:30,代码来源:SymmTridiagEVD.java


示例11: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public Matrix solve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    int[] ipiv = new int[numRows];

    intW info = new intW(0);
    LAPACK.getInstance().dspsv(uplo.netlib(), numRows, X.numColumns(),
            data.clone(), ipiv, Xd, Matrices.ld(numRows), info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:25,代码来源:AbstractSymmPackMatrix.java


示例12: SPDsolve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
Matrix SPDsolve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    intW info = new intW(0);
    LAPACK.getInstance().dppsv(uplo.netlib(), numRows, X.numColumns(),
            data.clone(), Xd, Matrices.ld(numRows), info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:AbstractSymmPackMatrix.java


示例13: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
Matrix solve(Matrix B, Matrix X, Transpose trans) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    intW info = new intW(0);
    LAPACK.getInstance().dtptrs(uplo.netlib(), trans.netlib(),
            diag.netlib(), numRows, X.numColumns(), data, Xd,
            Matrices.ld(numRows), info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:23,代码来源:AbstractTriangPackMatrix.java


示例14: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
@Override
public Matrix solve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);
    intW info = new intW(0);
    LAPACK.getInstance().dgtsv(numRows, X.numColumns(), offDiag.clone(),
            diag.clone(), offDiag.clone(), Xd, Matrices.ld(numRows), info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:SymmTridiagMatrix.java


示例15: factor

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Computes an SVD
 * 
 * @param A
 *            Matrix to decompose. Size must conform, and it will be
 *            overwritten on return. Pass a copy to avoid this
 * @return The current decomposition
 * @throws NotConvergedException
 */
public SVD factor(DenseMatrix A) throws NotConvergedException {
    if (A.numRows() != m)
        throw new IllegalArgumentException("A.numRows() != m");
    else if (A.numColumns() != n)
        throw new IllegalArgumentException("A.numColumns() != n");

    intW info = new intW(0);
    LAPACK.getInstance().dgesdd(job.netlib(), m, n, A.getData(),
            Matrices.ld(m), S, vectors ? U.getData() : new double[0],
            Matrices.ld(m), vectors ? Vt.getData() : new double[0],
            Matrices.ld(n), work, work.length, iwork, info);

    if (info.val > 0)
        throw new NotConvergedException(
                NotConvergedException.Reason.Iterations);
    else if (info.val < 0)
        throw new IllegalArgumentException();

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:30,代码来源:SVD.java


示例16: decompose

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
private PackCholesky decompose(AbstractPackMatrix A) {
    if (n != A.numRows())
        throw new IllegalArgumentException("n != A.numRows()");

    notspd = false;

    intW info = new intW(0);
    if (upper)
        LAPACK.getInstance().dpptrf(UpLo.Upper.netlib(), A.numRows(),
                A.getData(), info);
    else
        LAPACK.getInstance().dpptrf(UpLo.Lower.netlib(), A.numRows(),
                A.getData(), info);

    if (info.val > 0)
        notspd = true;
    else if (info.val < 0)
        throw new IllegalArgumentException();

    if (upper)
        Cu.set(A);
    else
        Cl.set(A);

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:27,代码来源:PackCholesky.java


示例17: solve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Solves for <code>B</code>, overwriting it on return
 */
public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException {
    if (notspd)
        throw new MatrixNotSPDException();
    if (B.numRows() != n)
        throw new IllegalArgumentException("B.numRows() != n");

    intW info = new intW(0);
    if (upper)
        LAPACK.getInstance().dpptrs(UpLo.Upper.netlib(), Cu.numRows(),
                B.numColumns(), Cu.getData(), B.getData(),
                Matrices.ld(Cu.numRows()), info);
    else
        LAPACK.getInstance().dpptrs(UpLo.Lower.netlib(), Cl.numRows(),
                B.numColumns(), Cl.getData(), B.getData(),
                Matrices.ld(Cl.numRows()), info);

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

    return B;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:25,代码来源:PackCholesky.java


示例18: SPDsolve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
Matrix SPDsolve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    intW info = new intW(0);
    LAPACK.getInstance().dposv(uplo.netlib(), numRows, X.numColumns(),
            data.clone(), Matrices.ld(numRows), Xd, Matrices.ld(numRows),
            info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:23,代码来源:AbstractSymmDenseMatrix.java


示例19: SPDsolve

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
Matrix SPDsolve(Matrix B, Matrix X) {
    if (!(X instanceof DenseMatrix))
        throw new UnsupportedOperationException("X must be a DenseMatrix");

    checkSolve(B, X);

    double[] Xd = ((DenseMatrix) X).getData();

    X.set(B);

    intW info = new intW(0);
    LAPACK.getInstance().dpbsv(uplo.netlib(), numRows, kd, X.numColumns(),
            data.clone(), Matrices.ld(kd + 1), Xd, Matrices.ld(numRows),
            info);

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

    return X;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:23,代码来源:AbstractSymmBandMatrix.java


示例20: factor

import com.github.fommil.netlib.LAPACK; //导入依赖的package包/类
/**
 * Creates an LU decomposition of the given matrix
 * 
 * @param A
 *            Matrix to decompose. It will be overwritten with the
 *            decomposition. Its number of superdiagonals must equal
 *            <code>kl+ku</code>
 * @return The current decomposition
 */
public BandLU factor(BandMatrix A) {
    if (!(A.isSquare()))
        throw new IllegalArgumentException("!A.isSquare()");
    if (n != A.numRows())
        throw new IllegalArgumentException("n != A.numRows()");
    if (A.ku != ku + kl)
        throw new IllegalArgumentException("A.ku != ku + kl");

    singular = false;

    intW info = new intW(0);
    LAPACK.getInstance().dgbtrf(n, n, kl, ku, A.getData(), 2 * kl + ku + 1,
            ipiv, info);

    if (info.val > 0)
        singular = true;
    else if (info.val < 0)
        throw new IllegalArgumentException();

    LU.set(A);

    return this;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:33,代码来源:BandLU.java



注:本文中的com.github.fommil.netlib.LAPACK类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Activity类代码示例发布时间:2022-05-22
下一篇:
Java ResourceArrayPropertyEditor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap