@Override public Matrix matrixFactory(double[][] values) { Matrix base = new DenseMatrix(values); // for general tests, we just make a scrambled matrix and fill it // with the standard data. Then we can test the details of the // row and/or column swapping separately. PivotedMatrix pm = new PivotedMatrix(base.like()); pm.swap(0, 1); pm.swapRows(1, 2); pm.assign(base); return pm; }
private void decomposeWithPivoting(Matrix a) { int n = a.rowSize(); L.assign(a);
private void decompose(Matrix a) { int n = a.rowSize(); L.assign(a); // column-wise submatrix cholesky with simple pivoting for (int k = 0; k < n; k++) { double akk = L.get(k, k); // set upper part of column to 0. L.viewColumn(k).viewPart(0, k).assign(0); double epsilon = 1.0e-10 * L.viewColumn(k).aggregate(Functions.MAX, Functions.ABS); if (akk <= epsilon) { // degenerate column case. Set diagonal to 1, all others to zero L.viewColumn(k).viewPart(k, n - k).assign(0); isPositiveDefinite = false; // no need to subtract from remaining sub-matrix } else { // normalize column by diagonal element akk = Math.sqrt(Math.max(0, akk)); L.set(k, k, akk); L.viewColumn(k).viewPart(k + 1, n - k - 1).assign(Functions.div(akk)); // now subtract scaled version of column for (int j = k + 1; j < n; j++) { Vector columnJ = L.viewColumn(j).viewPart(j, n - j); Vector columnK = L.viewColumn(k).viewPart(j, n - j); columnJ.assign(columnK, Functions.minusMult(L.get(j, k))); } } } }
@Override public Matrix matrixFactory(double[][] values) { Matrix base = new DenseMatrix(values); // for general tests, we just make a scrambled matrix and fill it // with the standard data. Then we can test the details of the // row and/or column swapping separately. PivotedMatrix pm = new PivotedMatrix(base.like()); pm.swap(0, 1); pm.swapRows(1, 2); pm.assign(base); return pm; }
private void decomposeWithPivoting(Matrix a) { int n = a.rowSize(); L.assign(a);
private void decomposeWithPivoting(Matrix a) { int n = a.rowSize(); L.assign(a);
private void decompose(Matrix a) { int n = a.rowSize(); L.assign(a); // column-wise submatrix cholesky with simple pivoting for (int k = 0; k < n; k++) { double akk = L.get(k, k); // set upper part of column to 0. L.viewColumn(k).viewPart(0, k).assign(0); double epsilon = 1.0e-10 * L.viewColumn(k).aggregate(Functions.MAX, Functions.ABS); if (akk <= epsilon) { // degenerate column case. Set diagonal to 1, all others to zero L.viewColumn(k).viewPart(k, n - k).assign(0); isPositiveDefinite = false; // no need to subtract from remaining sub-matrix } else { // normalize column by diagonal element akk = Math.sqrt(Math.max(0, akk)); L.set(k, k, akk); L.viewColumn(k).viewPart(k + 1, n - k - 1).assign(Functions.div(akk)); // now subtract scaled version of column for (int j = k + 1; j < n; j++) { Vector columnJ = L.viewColumn(j).viewPart(j, n - j); Vector columnK = L.viewColumn(k).viewPart(j, n - j); columnJ.assign(columnK, Functions.minusMult(L.get(j, k))); } } } }
private void decompose(Matrix a) { int n = a.rowSize(); L.assign(a); // column-wise submatrix cholesky with simple pivoting for (int k = 0; k < n; k++) { double akk = L.get(k, k); // set upper part of column to 0. L.viewColumn(k).viewPart(0, k).assign(0); double epsilon = 1.0e-10 * L.viewColumn(k).aggregate(Functions.MAX, Functions.ABS); if (akk <= epsilon) { // degenerate column case. Set diagonal to 1, all others to zero L.viewColumn(k).viewPart(k, n - k).assign(0); isPositiveDefinite = false; // no need to subtract from remaining sub-matrix } else { // normalize column by diagonal element akk = Math.sqrt(Math.max(0, akk)); L.set(k, k, akk); L.viewColumn(k).viewPart(k + 1, n - k - 1).assign(Functions.div(akk)); // now subtract scaled version of column for (int j = k + 1; j < n; j++) { Vector columnJ = L.viewColumn(j).viewPart(j, n - j); Vector columnK = L.viewColumn(k).viewPart(j, n - j); columnJ.assign(columnK, Functions.minusMult(L.get(j, k))); } } } }