本文整理汇总了Java中com.github.fommil.netlib.LAPACK类的典型用法代码示例。如果您正苦于以下问题:Java LAPACK类的具体用法?Java LAPACK怎么用?Java LAPACK使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LAPACK类属于com.github.fommil.netlib包,在下文中一共展示了LAPACK类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}