本文整理了Java中org.ujmp.core.Matrix.qr()
方法的一些代码示例,展示了Matrix.qr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.qr()
方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:qr
暂无
代码示例来源:origin: ujmp/universal-java-matrix-package
public Object call() {
Matrix[] result = getMatrixObject().getMatrix().qr();
result[0].showGUI();
result[1].showGUI();
return result;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
Matrix diff = prod.minus(a);
代码示例来源:origin: ujmp/universal-java-matrix-package
public final Matrix[] svd(int k) {
// how many iterations for self-multiplication, good values seem to be
// in the range 3 to 8
final int iterations = 3;
// self-multiplication
Matrix aSquared = this.mtimes(transpose());
for (int i = 0; i < iterations; i++) {
aSquared = aSquared.mtimes(aSquared);
}
// multiply with random matrix
Matrix o = Matrix.Factory.randn(getRowCount(), k);
Matrix y = aSquared.mtimes(this).mtimes(o);
// decompose
Matrix[] qr = y.qr();
Matrix q = qr[0];
// calculate low rank SVD
Matrix b = q.transpose().mtimes(this);
Matrix[] svd = b.svd();
Matrix uHat = svd[0];
Matrix s = svd[1];
Matrix v = svd[2];
Matrix u = q.mtimes(uHat);
return new Matrix[] { u, s, v };
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRRandSquareSmall() throws Exception {
Matrix a = createMatrixWithAnnotation(7, 7);
a.randn(Ret.ORIG);
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: org.ujmp/ujmp-examples
Matrix[] eigenValueDecomposition = dense.eig();
Matrix[] luDecomposition = dense.lu();
Matrix[] qrDecomposition = dense.qr();
Matrix choleskyDecomposition = dense.chol();
代码示例来源:origin: ujmp/universal-java-matrix-package
Matrix[] eigenValueDecomposition = dense.eig();
Matrix[] luDecomposition = dense.lu();
Matrix[] qrDecomposition = dense.qr();
Matrix choleskyDecomposition = dense.chol();
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRFixedSquareSmall() throws Exception {
Matrix a = createMatrixWithAnnotation(5, 5);
setAscending(a);
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRRandLarge() throws Exception {
if (!isTestLarge()) {
return;
}
Matrix a = createMatrixWithAnnotation(123, 123);
a.randn(Ret.ORIG);
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRFixedSquareLarge() throws Exception {
if (!isTestLarge()) {
return;
}
Matrix a = createMatrixWithAnnotation(151, 151);
setAscending(a);
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRTallLarge() throws Exception {
if (!isTestLarge()) {
return;
}
Matrix a = createMatrixWithAnnotation(168, 143);
for (int r = 0, v = 1; r < a.getRowCount(); r++) {
for (int c = 0; c < a.getColumnCount(); c++) {
a.setAsDouble(v++, r, c);
}
}
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRFatSmall() throws Exception {
Matrix a = createMatrixWithAnnotation(4, 6);
if (!isSupported(a, MatrixLibraries.QR, MatrixLayout.FAT, Size.SMALL, null)) {
return;
}
for (int r = 0, v = 1; r < a.getRowCount(); r++) {
for (int c = 0; c < a.getColumnCount(); c++) {
a.setAsDouble(v++, r, c);
}
}
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRTallSmall() throws Exception {
Matrix a = createMatrixWithAnnotation(6, 4);
if (!isSupported(a, MatrixLibraries.QR, MatrixLayout.TALL, Size.SMALL, null)) {
return;
}
for (int r = 0, v = 1; r < a.getRowCount(); r++) {
for (int c = 0; c < a.getColumnCount(); c++) {
a.setAsDouble(v++, r, c);
}
}
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testQRFatLarge() throws Exception {
if (!isTestLarge()) {
return;
}
Matrix a = createMatrixWithAnnotation(140, 160);
if (!isSupported(a, MatrixLibraries.QR, MatrixLayout.FAT, Size.LARGE, null)) {
return;
}
for (int r = 0, v = 1; r < a.getRowCount(); r++) {
for (int c = 0; c < a.getColumnCount(); c++) {
a.setAsDouble(v++, r, c);
}
}
Matrix[] qr = a.qr();
Matrix prod = qr[0].mtimes(qr[1]);
assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
if (a instanceof Erasable) {
((Erasable) a).erase();
}
if (prod instanceof Erasable) {
((Erasable) prod).erase();
}
}
内容来源于网络,如有侵权,请联系作者删除!